Skip to content

Commit

Permalink
Re-enable windows for nym-vpn-core CI and release (#1401)
Browse files Browse the repository at this point in the history
* Re-enable windows for nym-vpn-core CI and release

* Use msys2 to build wireguard-go

* Use msys2 shell

* Install build tools

* Add silent flag

* Try new plugin

* use winget --disable-interactivity

* Add --passive

* Use powershell to set PATH

* Use pwshcore

* ignore error if winget package is already installed

* Use correct value

* Build wireguard for windows with msys2

* Fix msys2 inherit env

* Remove no longer needed RUSTFLAGS

* Add msbuild to path

* Fix typo

* Exclude gateway-probe on windows

* Use CC name instead of full path

* clippy: fix

* Disable nym-gateway-probe in windows builds

* Extract windows core ci into its own workflow

* Exclude gateway-probe.exe

* Move MSYS env into step

* Rename workflow for windows

* Update step name

* Remove winpcap from CI

* Remove trailing whitespace

* Remove Packet

---------

Co-authored-by: Andrej Mihajlov <andrej@nymtech.net>
  • Loading branch information
octol and pronebird authored Oct 29, 2024
1 parent 934b228 commit 3f9b682
Show file tree
Hide file tree
Showing 7 changed files with 193 additions and 89 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-nym-vpn-core-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ jobs:
- name: Build nym-vpn-core
working-directory: nym-vpn-core
run: |
cargo build --${{ env.CARGO_TARGET }}
cargo build --${{ env.CARGO_TARGET }} --workspace --exclude nym-gateway-probe
- name: Get rust version used for build
id: rust-version
Expand All @@ -99,7 +99,7 @@ jobs:
echo "moving binaries into ${{ env.UPLOAD_DIR_WINDOWS }}"
rm -rf ${{ env.UPLOAD_DIR_WINDOWS }} || true
mkdir ${{ env.UPLOAD_DIR_WINDOWS }}
cp -vpr ${{ env.SRC_BINARY }}/nym-gateway-probe.exe ${{ env.UPLOAD_DIR_WINDOWS }}
#cp -vpr ${{ env.SRC_BINARY }}/nym-gateway-probe.exe ${{ env.UPLOAD_DIR_WINDOWS }}
cp -vpr ${{ env.SRC_BINARY }}/nym-vpn-cli.exe ${{ env.UPLOAD_DIR_WINDOWS }}
cp -vpr ${{ env.SRC_BINARY }}/nym-vpnc.exe ${{ env.UPLOAD_DIR_WINDOWS }}
cp -vpr ${{ env.SRC_BINARY }}/nym-vpnd.exe ${{ env.UPLOAD_DIR_WINDOWS }}
Expand Down
30 changes: 27 additions & 3 deletions .github/workflows/build-wireguard-go-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,35 @@ jobs:
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Setup MSBuild.exe
uses: microsoft/setup-msbuild@v2
- name: Install build tools
shell: cmd
run: |
winget install --disable-interactivity --id=Microsoft.VisualStudio.2022.BuildTools --override "--wait --passive --add Microsoft.VisualStudio.Workload.VCTools;includeRecommended"
if %ERRORLEVEL% EQU -1978335189 (
exit /b 0
)
- name: Update path with vctools
shell: pwsh
run: |
$path = "$Env:ProgramFiles (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Tools/MSVC"
$contents = Get-ChildItem $path | Select-Object -First 1
$subdir = $contents[0].Name
$vctoolsdir = "$path/$subdir/bin/Hostx64/x64"
echo "Add vctools dir to path: $vctoolsdir"
Add-Content $env:GITHUB_PATH "$vctoolsdir"
- name: Setup msys2
uses: msys2/setup-msys2@v2
with:
update: false
msystem: MINGW64
install: mingw-w64-x86_64-clang

- name: Build wireguard
shell: bash
shell: msys2 {0}
env:
MSYS2_PATH_TYPE: inherit
run: |
./wireguard/build-wireguard-go.sh
Expand Down
148 changes: 148 additions & 0 deletions .github/workflows/ci-nym-vpn-core-windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
name: ci-nym-vpn-core-windows

on:
# push:
pull_request:
paths:
- "nym-vpn-core/**"
- ".github/workflows/ci-nym-vpn-core-windows.yml"
workflow_dispatch:

env:
CARGO_TERM_COLOR: always
AGENT_ISSELFHOSTED: 1 # https://github.com/actions/setup-go/issues/432

jobs:
build:
runs-on: custom-windows-11

steps:
- name: "Cleanup working directory"
shell: bash
run: |
ls -la ./
rm -rf ./* || true
rm -rf ./.??* || true
ls -la ./
- name: Support longpaths on windows
run: git config --system core.longpaths true

- name: Checkout repo
uses: actions/checkout@v4

- name: Install rust toolchain
uses: brndnmtthws/rust-action-rustup@v1
with:
toolchain: stable
components: rustfmt, clippy

- name: Set env
shell: bash
run: |
triplet=x86_64-pc-windows-msvc
echo "TRIPLET=$triplet" >> $GITHUB_ENV
echo "RUSTFLAGS=-L ${GITHUB_WORKSPACE}/build/lib -Clink-args=/LIBPATH:${GITHUB_WORKSPACE}/build/lib/x64-Debug" >> $GITHUB_ENV
mkdir -p ${GITHUB_WORKSPACE}/build/lib/
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: "stable"

- name: Install Protoc
uses: arduino/setup-protoc@v3
with:
version: "21.12" # 3.21.12: the version on ubuntu 24.04. Don't change this!
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Install build tools
shell: cmd
run: |
winget install --disable-interactivity --id=Microsoft.VisualStudio.2022.BuildTools --override "--wait --passive --add Microsoft.VisualStudio.Workload.VCTools;includeRecommended"
if %ERRORLEVEL% EQU -1978335189 (
exit /b 0
)
- name: Update path with vctools
shell: pwsh
run: |
$buildtoolspath = "$Env:ProgramFiles (x86)/Microsoft Visual Studio/2022/BuildTools"
$msbuildpath = "$buildtoolspath/MSBuild/Current/Bin"
echo "Add msbuild dir to path: $msbuildpath"
Add-Content $env:GITHUB_PATH "$msbuildpath"
$msvctoolspath = "$buildtoolspath/VC/Tools/MSVC"
$contents = Get-ChildItem $msvctoolspath | Select-Object -First 1
$subdir = $contents[0].Name
$vctoolsdir = "$msvctoolspath/$subdir/bin/Hostx64/x64"
echo "Add vctools dir to path: $vctoolsdir"
Add-Content $env:GITHUB_PATH "$vctoolsdir"
- name: Setup msys2
uses: msys2/setup-msys2@v2
with:
update: false
msystem: MINGW64
install: mingw-w64-x86_64-clang

- name: Build wireguard
shell: msys2 {0}
env:
MSYS2_PATH_TYPE: inherit
run: |
./wireguard/build-wireguard-go.sh
- name: Download wintun.zip
shell: bash
run: |
curl --output ${GITHUB_WORKSPACE}/wintun.zip https://www.wintun.net/builds/wintun-0.14.1.zip
- name: Unzip wintun.zip
shell: bash
run: |
unzip ${GITHUB_WORKSPACE}/wintun.zip
- name: Move wintun.dll and packet.lib to build directory
shell: bash
run: |
mv ${GITHUB_WORKSPACE}/wintun/bin/amd64/wintun.dll ${GITHUB_WORKSPACE}/build/lib/
- name: Checkout mullvad libs for Windows
uses: actions/checkout@v4
with:
repository: nymtech/nym-vpn-mullvad-libs
ref: main
path: "nym-vpn-mullvad-libs"
submodules: true

- name: Build winfw.dll from mullvad
shell: bash
run: |
cd ${GITHUB_WORKSPACE}/nym-vpn-mullvad-libs
./build-windows-modules.sh
- name: Move winfw.dll to build directory
shell: bash
run: |
mv ${GITHUB_WORKSPACE}/nym-vpn-mullvad-libs/windows/winfw/bin/x64-Debug ${GITHUB_WORKSPACE}/build/lib/
- name: rustfmt check
working-directory: nym-vpn-core
run: |
cargo fmt --check
- name: Build (excluding gateway probe)
working-directory: nym-vpn-core
run: |
cargo build --verbose --workspace --exclude nym-gateway-probe
- name: Run tests (excluding gateway probe)
working-directory: nym-vpn-core
run: |
cargo test --verbose --workspace --exclude nym-gateway-probe
- name: Clippy
working-directory: nym-vpn-core
run: |
cargo clippy -- -Dwarnings
70 changes: 1 addition & 69 deletions .github/workflows/ci-nym-vpn-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ jobs:
strategy:
fail-fast: false
matrix:
# os: [arc-ubuntu-22.04, custom-runner-mac-m1, custom-windows-11]
os: [arc-ubuntu-22.04, custom-runner-mac-m1]
target: [native]
include:
Expand All @@ -41,10 +40,6 @@ jobs:
run: sudo apt-get update && sudo apt-get install -y libdbus-1-dev libmnl-dev libnftnl-dev protobuf-compiler git curl gcc g++ make unzip
if: contains(matrix.os, 'ubuntu')

- name: Support longpaths on windows
if: contains(matrix.os, 'windows')
run: git config --system core.longpaths true

- name: Checkout repo
uses: actions/checkout@v4

Expand Down Expand Up @@ -80,30 +75,20 @@ jobs:
if ${{ contains(matrix.os, 'ubuntu') && contains(matrix.target, 'native') }}; then
triplet=x86_64-unknown-linux-gnu
echo "TRIPLET=$triplet" >> $GITHUB_ENV
echo "RUSTFLAGS=-L ${GITHUB_WORKSPACE}/build/lib/${triplet}" >> $GITHUB_ENV
elif ${{ matrix.target == 'android' }}; then
triplet=aarch64-linux-android
echo "ANDROID_NDK_HOME=${{ steps.setup-ndk.outputs.ndk-path }}" >> $GITHUB_ENV
echo "NDK_TOOLCHAIN_DIR=${{ steps.setup-ndk.outputs.ndk-path }}/toolchains/llvm/prebuilt/linux-x86_64/bin" >> $GITHUB_ENV
echo "TRIPLET=$triplet" >> $GITHUB_ENV
echo "RUSTFLAGS=-L ${GITHUB_WORKSPACE}/build/lib/${triplet} -L ${GITHUB_WORKSPACE}/build/lib/x86_64-unknown-linux-gnu" >> $GITHUB_ENV
elif ${{ matrix.target == 'ios' }}; then
triplet=aarch64-apple-ios
echo "TRIPLET=$triplet" >> $GITHUB_ENV
echo "RUSTFLAGS=-L ${GITHUB_WORKSPACE}/build/lib/${triplet}" >> $GITHUB_ENV
elif ${{ matrix.os == 'macos-12' || matrix.os == 'macos-13' }}; then
triplet=x86_64-apple-darwin
echo "TRIPLET=$triplet" >> $GITHUB_ENV
echo "RUSTFLAGS=-L ${GITHUB_WORKSPACE}/build/lib/${triplet}" >> $GITHUB_ENV
elif ${{ contains(matrix.os, 'macos') || contains(matrix.os, 'mac-m1') }}; then
triplet=universal-apple-darwin
echo "TRIPLET=$triplet" >> $GITHUB_ENV
echo "RUSTFLAGS=-L ${GITHUB_WORKSPACE}/build/lib/${triplet}" >> $GITHUB_ENV
elif ${{ contains(matrix.os, 'windows') }}; then
triplet=x86_64-pc-windows-msvc
echo "TRIPLET=$triplet" >> $GITHUB_ENV
echo "RUSTFLAGS=-L ${GITHUB_WORKSPACE}/build/lib/${triplet} -L ${GITHUB_WORKSPACE}/build/lib/ -Clink-args=/LIBPATH:${GITHUB_WORKSPACE}/build/lib/x64-Debug" >> $GITHUB_ENV
mkdir -p ${GITHUB_WORKSPACE}/build/lib/
else
echo " ✗ unknown platform/arch [${{ matrix.os }}]"
exit 1
Expand All @@ -121,10 +106,6 @@ jobs:
version: "21.12" # 3.21.12: the version on ubuntu 24.04. Don't change this!
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Setup MSBuild.exe
if: contains(matrix.os, 'windows')
uses: microsoft/setup-msbuild@v2

- name: Build wireguard
if: matrix.target != 'ios' && matrix.target != 'android'
shell: bash
Expand All @@ -141,49 +122,6 @@ jobs:
if: matrix.target == 'android'
run: ./wireguard/libwg/build-android.sh

- name: Download wintun.zip and winpcap.zip
if: contains(matrix.os, 'windows')
shell: bash
run: |
curl --output ${GITHUB_WORKSPACE}/wintun.zip https://www.wintun.net/builds/wintun-0.14.1.zip
curl --output ${GITHUB_WORKSPACE}/winpcap.zip https://www.winpcap.org/install/bin/WpdPack_4_1_2.zip
- name: Unzip wintun.zip and winpcap.zip
if: contains(matrix.os, 'windows')
shell: bash
run: |
unzip ${GITHUB_WORKSPACE}/wintun.zip
unzip ${GITHUB_WORKSPACE}/winpcap.zip
- name: Move wintun.dll and packet.lib to build directory
if: contains(matrix.os, 'windows')
shell: bash
run: |
mv ${GITHUB_WORKSPACE}/wintun/bin/amd64/wintun.dll ${GITHUB_WORKSPACE}/build/lib/
mv ${GITHUB_WORKSPACE}/WpdPack/Lib/x64/Packet.lib ${GITHUB_WORKSPACE}/build/lib/
- name: Checkout mullvad libs for Windows
if: contains(matrix.os, 'windows')
uses: actions/checkout@v4
with:
repository: nymtech/nym-vpn-mullvad-libs
ref: main
path: "nym-vpn-mullvad-libs"
submodules: true

- name: Build winfw.dll from mullvad
if: contains(matrix.os, 'windows')
shell: bash
run: |
cd ${GITHUB_WORKSPACE}/nym-vpn-mullvad-libs
./build-windows-modules.sh
- name: Move winfw.dll to build directory
if: contains(matrix.os, 'windows')
shell: bash
run: |
mv ${GITHUB_WORKSPACE}/nym-vpn-mullvad-libs/windows/winfw/bin/x64-Debug ${GITHUB_WORKSPACE}/build/lib/
- name: rustfmt check
working-directory: nym-vpn-core
run: |
Expand Down Expand Up @@ -266,17 +204,11 @@ jobs:
run: exit 1

- name: Run tests (Linux, macOS)
if: matrix.target != 'android' && matrix.target != 'ios' && !contains(matrix.os, 'windows')
if: matrix.target != 'android' && matrix.target != 'ios'
working-directory: nym-vpn-core
run: |
cargo test --verbose
- name: Run tests (Windows excluding gateway probe)
if: contains(matrix.os, 'windows')
working-directory: nym-vpn-core
run: |
cargo test --verbose --workspace --exclude nym-gateway-probe
- name: Clippy
working-directory: nym-vpn-core
run: |
Expand Down
Loading

0 comments on commit 3f9b682

Please sign in to comment.