-
Notifications
You must be signed in to change notification settings - Fork 8
219 lines (186 loc) · 7.56 KB
/
ci-nym-vpn-core.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
name: ci-nym-vpn-core
on:
# push:
pull_request:
paths:
- "nym-vpn-core/**"
- ".github/workflows/ci-nym-vpn-core.yml"
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
AGENT_ISSELFHOSTED: 1 # https://github.com/actions/setup-go/issues/432
jobs:
build:
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04-arc, custom-runner-mac-m1, custom-windows-11]
target: [native]
include:
- os: ubuntu-22.04-arc
target: android
runs-on: ${{ matrix.os }}
steps:
- name: "Cleanup working directory"
if: contains(matrix.os, 'custom')
shell: bash
run: |
ls -la ./
rm -rf ./* || true
rm -rf ./.??* || true
ls -la ./
- name: Install system dependencies
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
- name: Install rust toolchain
uses: brndnmtthws/rust-action-rustup@v1
with:
toolchain: stable
components: rustfmt, clippy
- name: Install cargo ndk
if: contains(matrix.target, 'android')
run: cargo install cargo-ndk
- name: Setup NDK
uses: nttld/setup-ndk@v1
id: setup-ndk
if: contains(matrix.target, 'android')
with:
ndk-version: r26c
add-to-path: false
- name: Add iOS target
if: contains(matrix.os, 'macos') || contains(matrix.os, 'mac-m1')
run: rustup target add aarch64-apple-ios
- name: Add Android target
if: contains(matrix.target, 'android')
run: rustup target add aarch64-linux-android
- name: Set env
shell: bash
run: |
if ${{ contains(matrix.os, 'ubuntu') && contains(matrix.target, 'native') }}; then
triplet=x86_64-unknown-linux-gnu
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
elif ${{ matrix.os == 'macos-12' || matrix.os == 'macos-13' }}; then
triplet=x86_64-apple-darwin
elif ${{ contains(matrix.os, 'macos') || contains(matrix.os, 'mac-m1') }}; then
triplet=universal-apple-darwin
elif ${{ contains(matrix.os, 'windows') }}; then
triplet=x86_64-pc-windows-msvc
else
echo " ✗ unknown platform/arch [${{ matrix.os }}]"
exit 1
fi
echo "TRIPLET=$triplet" >> $GITHUB_ENV
echo "RUSTFLAGS=-L ${GITHUB_WORKSPACE}/build/lib/${triplet}" >> $GITHUB_ENV
- name: Set extra env for Windows
if: contains(matrix.os, 'windows')
shell: bash
run: |
echo "RUSTFLAGS=-L ${GITHUB_WORKSPACE}/build/lib/x86_64-pc-windows-msvc -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@v2
if: contains(matrix.os, 'macos') || contains(matrix.os, 'windows')
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup MSBuild.exe
if: contains(matrix.os, 'windows')
uses: microsoft/setup-msbuild@v2
- name: Build wireguard
shell: bash
run: |
./wireguard/build-wireguard-go.sh
- name: Build wireguard (Android)
if: contains(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: |
cargo fmt --check
- name: Build
if: "!contains(matrix.target, 'android')"
working-directory: nym-vpn-core
run: |
cargo build --verbose
- name: Build (Android)
if: contains(matrix.target, 'android')
working-directory: nym-vpn-core
run: |
cargo ndk -t aarch64-linux-android -o ./build build -p nym-vpn-lib
rustflags="-L ${GITHUB_WORKSPACE}/build/lib/x86_64-unknown-linux-gnu"
RUSTFLAGS=$rustflags cargo run --bin uniffi-bindgen generate --library target/aarch64-linux-android/debug/libnym_vpn_lib.so --language kotlin --out-dir build -n
diff -B build/nym_vpn_lib/nym_vpn_lib.kt nym-vpn-lib/uniffi/nym_vpn_lib.kt
- name: Build (iOS)
if: contains(matrix.os, 'macos') || contains(matrix.os, 'mac-m1')
working-directory: nym-vpn-core
run: |
cargo build --verbose --target aarch64-apple-ios -p nym-vpn-lib
cargo run --bin uniffi-bindgen generate --library target/aarch64-apple-ios/debug/libnym_vpn_lib.a --language swift --out-dir build -n
diff -B build/nym_vpn_lib.swift nym-vpn-lib/uniffi/nym_vpn_lib.swift
- name: Run tests
if: "!contains(matrix.target, 'android')"
working-directory: nym-vpn-core
run: |
cargo test --verbose
- name: Clippy
working-directory: nym-vpn-core
run: |
cargo clippy -- -Dwarnings
- name: Clippy (Android)
if: contains(matrix.target, 'android')
working-directory: nym-vpn-core
run: |
cargo ndk -t aarch64-linux-android clippy -p nym-vpn-lib -- -Dwarnings
- name: Clippy (iOS)
if: contains(matrix.os, 'macos') || contains(matrix.os, 'mac-m1')
working-directory: nym-vpn-core
run: |
cargo clippy --target aarch64-apple-ios -p nym-vpn-lib -- -Dwarnings