-
Notifications
You must be signed in to change notification settings - Fork 0
357 lines (348 loc) · 16.1 KB
/
ci.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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
on: [push, pull_request]
jobs:
build_cache_pc_tier1:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
version: [1.68.0, stable, beta, nightly]
prefix: [pc_test_target_tier1]
fail-fast: false
runs-on: ${{ matrix.os }}
env:
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
RUSTC_FORCE_INCREMENTAL: 1
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/cache_cargo
- uses: ./.github/actions/install_rust_by_version
- name: build
run: |
cargo build
cargo build --release
- name: build linux
if: matrix.os == 'ubuntu-latest'
run: |
target=("aarch64-unknown-linux-gnu" "i686-unknown-linux-gnu" "x86_64-unknown-linux-gnu")
for v in "${target[@]}"; do
rustup target add ${v}
cargo build --target ${v}
cargo build --target ${v} --release
done
- name: build macos
if: matrix.os == 'macos-latest'
run: |
target=("x86_64-apple-darwin")
for v in "${target[@]}"; do
rustup target add ${v}
cargo build --target ${v}
cargo build --target ${v} --release
done
- name: build windows
if: matrix.os == 'windows-latest'
run: |
$target = @("i686-pc-windows-gnu", "i686-pc-windows-msvc", "x86_64-pc-windows-gnu", "x86_64-pc-windows-msvc")
foreach ($v in $target) {
rustup target add $v
cargo build --target ${v}
cargo build --target ${v} --release
}
fmt_pc:
strategy:
matrix:
os: [ubuntu-latest]
version: [1.68.0, stable, beta, nightly]
prefix: [pc_test_target_tier1]
fail-fast: false
runs-on: ${{ matrix.os }}
env:
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
RUSTC_FORCE_INCREMENTAL: 1
needs: build_cache_pc_tier1
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/cache_cargo
- uses: ./.github/actions/install_rust_by_version
- run: rustup component add rustfmt
- name: fmt
run: cargo fmt --all -- --check
clippy_pc_tier1:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
version: [1.68.0, stable, beta, nightly]
prefix: [pc_test]
fail-fast: false
runs-on: ${{ matrix.os }}
env:
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
RUSTC_FORCE_INCREMENTAL: 1
needs: build_cache_pc_tier1
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/cache_cargo
- uses: ./.github/actions/install_rust_by_version
- run: rustup component add clippy
- name: clippy
run: |
cargo clippy --all-targets --all-features -- -D warnings
- name: clippy linux
if: matrix.os == 'ubuntu-latest'
run: |
target=("aarch64-unknown-linux-gnu" "i686-unknown-linux-gnu" "x86_64-unknown-linux-gnu")
for v in "${target[@]}"; do
rustup target add ${v}
cargo clippy --target ${v} --all-targets --all-features -- -D warnings
done
- name: clippy macos
if: matrix.os == 'macos-latest'
run: |
target=("x86_64-apple-darwin")
for v in "${target[@]}"; do
rustup target add ${v}
cargo clippy --target ${v} --all-targets --all-features -- -D warnings
done
- name: clippy windows
if: matrix.os == 'windows-latest'
run: |
$target = @("i686-pc-windows-gnu", "i686-pc-windows-msvc", "x86_64-pc-windows-gnu", "x86_64-pc-windows-msvc")
foreach ($v in $target) {
rustup target add $v
cargo clippy --target ${v} --all-targets --all-features -- -D warnings
}
test_pc_tier1:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
version: [1.68.0, stable, beta, nightly]
prefix: [pc_test]
fail-fast: false
runs-on: ${{ matrix.os }}
env:
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
RUSTC_FORCE_INCREMENTAL: 1
needs: build_cache_pc_tier1
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/cache_cargo
- uses: ./.github/actions/install_rust_by_version
- name: test
run: |
cargo test --all -- --nocapture
cargo test --all --release -- --nocapture
- name: test linux aarch64
if: matrix.os == 'ubuntu-latest'
# && matrix.version != '1.68.0'
uses: uraimo/run-on-arch-action@v2
with:
arch: aarch64
distro: ubuntu_latest
# Not required, but speeds up builds by reusing the cache from the previous job
# githubToken: ${{ github.token }}
run: |
apt-get update -q -y
apt-get install -y -q curl gcc
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain ${{ matrix.version }} --profile minimal
source "$HOME/.cargo/env"
CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse cargo test --all --target aarch64-unknown-linux-gnu -- --nocapture
CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse cargo test --all --target aarch64-unknown-linux-gnu --release -- --nocapture
- name: test linux i686
if: matrix.os == 'ubuntu-latest'
# until merged https://github.com/uraimo/run-on-arch-action/pull/94
uses: lalten/run-on-arch-action@amd64-support
with:
arch: i686
distro: ubuntu_latest
run: |
apt-get update -q -y
apt-get install -q -y curl gcc
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain ${{ matrix.version }} --profile minimal
source "$HOME/.cargo/env"
CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse cargo test --all --target i686-unknown-linux-gnu -- --nocapture
CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse cargo test --all --target i686-unknown-linux-gnu --release -- --nocapture
- name: test linux
if: matrix.os == 'ubuntu-latest'
# cargo test can only real platform
run: |
target=("x86_64-unknown-linux-gnu")
for v in "${target[@]}"; do
rustup target add ${v}
cargo test --all --target ${v} -- --nocapture
cargo test --all --release --target ${v} -- --nocapture
done
- name: test macos
if: matrix.os == 'macos-latest'
run: |
target=("x86_64-apple-darwin")
for v in "${target[@]}"; do
rustup target add ${v}
cargo test --all --target ${v} -- --nocapture
cargo test --all --release --target ${v} -- --nocapture
done
- name: test windows
if: matrix.os == 'windows-latest'
run: |
$target = @("i686-pc-windows-gnu", "i686-pc-windows-msvc", "x86_64-pc-windows-gnu", "x86_64-pc-windows-msvc")
foreach ($v in $target) {
rustup target add $v
cargo test --all --target $v -- --nocapture
cargo test --all --release --target $v -- --nocapture
}
build_and_clippy_target_tier2:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
version: [1.68.0, stable, beta, nightly]
prefix: [pc_test_target_tier2]
fail-fast: false
runs-on: ${{ matrix.os }}
env:
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
RUSTC_FORCE_INCREMENTAL: 1
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/cache_cargo
- uses: ./.github/actions/install_rust_by_version
- name: build linux
if: matrix.os == 'ubuntu-latest'
# note: not all platforms have the standard library pre-compiled: https://doc.rust-lang.org/nightly/rustc/platform-support.html
# "loongarch64-unknown-linux-gnu"
run: |
target=("aarch64-unknown-linux-musl" "arm-unknown-linux-gnueabi" "arm-unknown-linux-gnueabihf" "armv7-unknown-linux-gnueabihf" "powerpc-unknown-linux-gnu" "powerpc64-unknown-linux-gnu" "powerpc64le-unknown-linux-gnu" "riscv64gc-unknown-linux-gnu" "s390x-unknown-linux-gnu" "x86_64-unknown-freebsd" "x86_64-unknown-illumos" "x86_64-unknown-linux-musl" "x86_64-unknown-netbsd")
for v in "${target[@]}"; do
rustup target add ${v}
cargo build --target ${v}
cargo build --target ${v} --release
cargo clippy --target ${v} --all-targets --all-features -- -D warnings
cargo clippy --target ${v} --all-targets --all-features --release -- -D warnings
done
- name: build linux loongarch64
if: matrix.os == 'ubuntu-latest' && matrix.version != '1.68.0'
run: |
rustup target add loongarch64-unknown-linux-gnu
cargo build --target loongarch64-unknown-linux-gnu
cargo build --target loongarch64-unknown-linux-gnu --release
cargo clippy --target loongarch64-unknown-linux-gnu --all-targets --all-features -- -D warnings
cargo clippy --target loongarch64-unknown-linux-gnu --all-targets --all-features --release -- -D warnings
- name: build macos
if: matrix.os == 'macos-latest'
run: |
target=("aarch64-apple-darwin")
for v in "${target[@]}"; do
rustup target add ${v}
cargo build --target ${v}
cargo build --target ${v} --release
cargo clippy --target ${v} --all-targets --all-features -- -D warnings
cargo clippy --target ${v} --all-targets --all-features --release -- -D warnings
done
- name: build windows
if: matrix.os == 'windows-latest'
run: |
$target = @("aarch64-pc-windows-msvc")
foreach ($v in $target) {
rustup target add $v
cargo build --target ${v}
cargo build --target ${v} --release
cargo clippy --target ${v} --all-targets --all-features -- -D warnings
cargo clippy --target ${v} --all-targets --all-features --release -- -D warnings
}
build_cache_android:
strategy:
matrix:
os: [ubuntu-latest]
version: [1.68.0, stable, beta, nightly]
prefix: [android_test]
fail-fast: false
runs-on: ${{ matrix.os }}
env:
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
RUSTC_FORCE_INCREMENTAL: 1
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: ./.github/actions/cache_cargo
- uses: ./.github/actions/install_rust_by_version
- name: build android
run: |
target=("aarch64-linux-android" "arm-linux-androideabi" "armv7-linux-androideabi" "i686-linux-android" "x86_64-linux-android")
for v in "${target[@]}"; do
rustup target add ${v}
cargo build --target ${v}
cargo build --target ${v} --release
done
- name: build
run: cargo build
clippy_android:
strategy:
matrix:
os: [ubuntu-latest]
version: [1.68.0, stable, beta, nightly]
prefix: [android_test]
fail-fast: false
runs-on: ${{ matrix.os }}
env:
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
RUSTC_FORCE_INCREMENTAL: 1
needs: build_cache_android
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/cache_cargo
- uses: ./.github/actions/install_rust_by_version
- run: rustup component add clippy
- name: clippy
run: |
cargo clippy --all-targets --all-features -- -D warnings
- name: clippy linux
run: |
target=("aarch64-linux-android" "arm-linux-androideabi" "armv7-linux-androideabi" "i686-linux-android" "x86_64-linux-android")
for v in "${target[@]}"; do
rustup target add ${v}
cargo clippy --target ${v} --all-targets --all-features -- -D warnings
done
test_android:
strategy:
matrix:
os: [ubuntu-latest]
version: [1.68.0, stable, beta, nightly]
api-level: [24, 30, 33]
prefix: [android_test]
fail-fast: false
runs-on: ${{ matrix.os }}
env:
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
RUSTC_FORCE_INCREMENTAL: 1
needs: build_cache_android
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 1
- uses: ./.github/actions/cache_cargo
- uses: ./.github/actions/install_rust_by_version
- name: install rust_android_ndk
# run: rustup target add aarch64-linux-android arm-linux-androideabi armv7-linux-androideabi i686-linux-android x86_64-linux-android
run: rustup target add x86_64-linux-android
- name: install dinghy
run: |
if [ ${{matrix.version}} == "1.68.0" ]; then
if [ ${{matrix.os}} == "macos-latest" ]; then
cargo binstall -q --no-confirm --force --pkg-url="https://github.com/sonos/dinghy/releases/download/0.6.5/cargo-dinghy-macos-0.6.5.tgz" [email protected]
else
cargo binstall -q --no-confirm --force --pkg-url="https://github.com/sonos/dinghy/releases/download/0.6.5/cargo-dinghy-linux-0.6.5.tgz" [email protected]
fi
else
cargo binstall -q --no-confirm --force cargo-dinghy
fi
- name: start android emulator
uses: ReactiveCircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
target: default
arch: x86_64
profile: pixel_2
emulator-boot-timeout: 900
script: |
cargo dinghy --platform auto-android-x86_64 test
# https://zenn.dev/naokifujita/articles/c890954165c21f
# https://github.com/actix/actix-web/blob/master/.github/workflows/ci.yml
# https://github.com/rust-lang/cargo/issues/10781
# https://doc.rust-lang.org/cargo/reference/registries.html