-
Notifications
You must be signed in to change notification settings - Fork 182
507 lines (482 loc) · 16.9 KB
/
tests.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
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
name: Tests
on:
push:
branches: master
pull_request:
branches: master
schedule:
- cron: "0 12 * * 1"
permissions:
contents: read
env:
CARGO_INCREMENTAL: 0
RUSTFLAGS: "-Dwarnings"
jobs:
main-tests:
name: Tier 1 Test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04, windows-2022]
toolchain: [nightly, beta, stable, "1.60"]
# Only Test macOS on stable to reduce macOS CI jobs
include:
# x86_64-apple-darwin.
- os: macos-12
toolchain: stable
# aarch64-apple-darwin.
- os: macos-14
toolchain: stable
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.toolchain }}
- uses: Swatinem/rust-cache@v2
- run: cargo test
# Make sure enabling the std feature doesn't break anything
- run: cargo test --features=std
- if: ${{ matrix.toolchain == 'nightly' }}
run: cargo test --benches
linux-tests:
name: Linux Test
runs-on: ubuntu-22.04
strategy:
matrix:
target: [x86_64-unknown-linux-musl, i686-unknown-linux-musl]
include:
- target: i686-unknown-linux-gnu
packages: libc6-dev-i386 lib32gcc-11-dev
- target: x86_64-unknown-linux-gnux32
packages: libc6-dev-x32 libx32gcc-11-dev
# TODO: Find a Linux image/runner with CONFIG_X86_X32_ABI set
cargo_test_opts: --no-run
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install libc and libgcc
if: matrix.packages
run: |
sudo apt-get update
sudo apt-get install --no-install-recommends ${{ matrix.packages }}
- uses: Swatinem/rust-cache@v2
- run: cargo test ${{ matrix.cargo_test_opts }} --target=${{ matrix.target }} --features=std
- env:
RUSTFLAGS: -Dwarnings --cfg getrandom_backend="linux_getrandom"
run: cargo test ${{ matrix.cargo_test_opts }} --target=${{ matrix.target }} --features=std
- env:
RUSTFLAGS: -Dwarnings --cfg getrandom_backend="linux_rustix"
run: cargo test ${{ matrix.cargo_test_opts }} --target=${{ matrix.target }} --features=std
- env:
RUSTFLAGS: -Dwarnings --cfg getrandom_test_linux_fallback
run: cargo test --features=std
- env:
RUSTFLAGS: -Dwarnings --cfg getrandom_backend="rdrand"
run: cargo test --features=std
ios-tests:
name: iOS Simulator Test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-12, macos-14]
# Only test on stable to reduce macOS CI jobs
toolchain: [stable]
include:
# The Aarch64 device simulator doesn't seem to work on an x86-64 host
# and the x86_64 device simulator doesn't seem to work on an Aarch64
# host, at least within GitHub Actions.
- os: macos-12
target: x86_64-apple-ios
ios_platform: auto-ios-x86_64
- os: macos-14
target: aarch64-apple-ios-sim
ios_platform: auto-ios-aarch64-sim
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install precompiled cargo-dinghy
run: |
VERSION=0.7.2
URL="https://github.com/sonos/dinghy/releases/download/${VERSION}/cargo-dinghy-macos-${VERSION}.tgz"
wget -O - $URL | tar -xz --strip-components=1 -C ~/.cargo/bin
- name: Check cargo-dinghy version.
run: cargo dinghy --version
- name: Setup Simulator
# Use the first installed iOS runtime and the first (i.e. oldest) supported iPhone device.
run: |
RUNTIME=$(xcrun simctl list runtimes --json | jq '.runtimes | map(select(.name | contains("iOS"))) | .[0]')
RUNTIME_ID=$(echo $RUNTIME | jq -r '.identifier')
echo "Using runtime:" $RUNTIME_ID
DEVICE_ID=$(echo $RUNTIME | jq -r '.supportedDeviceTypes | map(select(.productFamily == "iPhone")) | .[0].identifier')
echo "Using device:" $DEVICE_ID
SIM_ID=$(xcrun simctl create Test-iPhone $DEVICE_ID $RUNTIME_ID)
echo "Created simulator:" $SIM_ID
xcrun simctl boot $SIM_ID
echo "device=$SIM_ID" >> $GITHUB_ENV
- uses: Swatinem/rust-cache@v2
- name: Run tests
run: cargo dinghy -p ${{ matrix.ios_platform }} -d ${{ env.device }} test
windows-tests:
name: Windows Test
runs-on: windows-2022
strategy:
matrix:
toolchain: [
stable-x86_64-gnu,
stable-i686-gnu,
stable-i686-msvc,
]
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.toolchain }}
- uses: Swatinem/rust-cache@v2
- run: cargo test --features=std
windows7:
name: Test Windows 7 impl on Windows 10
runs-on: windows-2022
steps:
- uses: actions/checkout@v4
# Win7 targets are Tier3, so pin a nightly where libstd builds.
- uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly-2024-05-20
components: rust-src
- uses: Swatinem/rust-cache@v2
- run: cargo test --target=x86_64-win7-windows-msvc -Z build-std --features=std
- run: cargo test --target=i686-win7-windows-msvc -Z build-std --features=std
sanitizer-test:
name: Sanitizer Test
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly-2024-10-08
components: rust-src
- env:
RUSTFLAGS: -Dwarnings -Zsanitizer=memory --cfg getrandom_sanitize
# `--all-targets` is used to skip doc tests which currently fail linking
run: cargo test -Zbuild-std --target=x86_64-unknown-linux-gnu --all-targets
cross-tests:
name: Cross Test
runs-on: ubuntu-22.04
strategy:
matrix:
target: [
aarch64-unknown-linux-gnu,
# TODO: add Android tests back when the cross cuts a new release.
# See: https://github.com/cross-rs/cross/issues/1222
# aarch64-linux-android,
powerpc-unknown-linux-gnu,
wasm32-unknown-emscripten,
]
steps:
- uses: actions/checkout@v4
- name: Install precompiled cross
run: |
VERSION=v0.2.5
URL=https://github.com/cross-rs/cross/releases/download/${VERSION}/cross-x86_64-unknown-linux-gnu.tar.gz
wget -O - $URL | tar -xz -C ~/.cargo/bin
cross --version
- name: Test
run: cross test --no-fail-fast --target=${{ matrix.target }} --features=std
macos-link:
name: macOS ARM64 Build/Link
# visionOS requires Xcode 15.2+, which is only available on the arm64 runners.
runs-on: macos-14
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
with:
targets: aarch64-apple-darwin, aarch64-apple-ios
components: rust-src
- uses: Swatinem/rust-cache@v2
- run: cargo test --no-run --target=aarch64-apple-darwin --features=std
- run: cargo test --no-run --target=aarch64-apple-ios --features=std
- run: cargo test --no-run --target=aarch64-apple-tvos -Zbuild-std --features=std
- run: cargo test --no-run --target=aarch64-apple-watchos -Zbuild-std --features=std
# visionOS requires Xcode 15.2+, GitHub Actions defaults to an older version.
- run: sudo xcode-select -switch /Applications/Xcode_15.2.app
- run: cargo test --no-run --target=aarch64-apple-visionos -Zbuild-std --features=std
freebsd:
name: FreeBSD VM Test
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Test in FreeBSD
uses: vmactions/freebsd-vm@v1
with:
envs: 'RUSTFLAGS'
usesh: true
prepare: |
pkg install -y rust
run: cargo test
openbsd:
name: OpenBSD VM Test
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Test in OpenBSD
uses: vmactions/openbsd-vm@v1
with:
envs: 'RUSTFLAGS'
usesh: true
prepare: |
pkg_add rust
run: cargo test
netbsd:
name: NetBSD VM Test
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Test in NetBSD
uses: vmactions/netbsd-vm@v1
with:
envs: 'RUSTFLAGS'
usesh: true
prepare: |
/usr/sbin/pkg_add rust
run: cargo test
# This job currently fails:
# https://github.com/rust-random/getrandom/actions/runs/11405005618/job/31735653874?pr=528
# dragonflybsd:
# name: DragonflyBSD VM Test
# runs-on: ubuntu-22.04
# steps:
# - uses: actions/checkout@v4
# - name: Test in DragonflyBSD
# uses: vmactions/dragonflybsd-vm@v1
# with:
# envs: 'RUSTFLAGS'
# usesh: true
# prepare: |
# pkg install -y rust
# run: cargo test
cross-link:
name: Cross Build/Link
runs-on: ubuntu-22.04
strategy:
matrix:
target: [
sparcv9-sun-solaris,
x86_64-unknown-illumos,
x86_64-unknown-freebsd,
x86_64-unknown-netbsd,
]
steps:
- uses: actions/checkout@v4
- name: Install precompiled cross
run: |
VERSION=v0.2.5
URL=https://github.com/cross-rs/cross/releases/download/${VERSION}/cross-x86_64-unknown-linux-gnu.tar.gz
wget -O - $URL | tar -xz -C ~/.cargo/bin
cross --version
- name: Build Tests
run: cross test --no-run --target=${{ matrix.target }} --features=std
web-tests:
name: Web Test
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-22.04
host: x86_64-unknown-linux-musl
- os: macos-12
host: x86_64-apple-darwin
# We get spurious failures on Windows, see:
# https://github.com/rust-random/getrandom/issues/400
# - os: windows-2022
# host: x86_64-pc-windows-msvc
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- run: choco install wget
if: runner.os == 'Windows'
- name: Install precompiled wasm-pack
shell: bash
run: |
VERSION=v0.12.1
URL=https://github.com/rustwasm/wasm-pack/releases/download/${VERSION}/wasm-pack-${VERSION}-${{ matrix.host }}.tar.gz
wget -O - $URL | tar -xz --strip-components=1 -C ~/.cargo/bin
wasm-pack --version
- uses: Swatinem/rust-cache@v2
- name: Test (Node)
env:
RUSTFLAGS: -Dwarnings --cfg getrandom_backend="wasm_js"
run: wasm-pack test --node
- name: Test (Firefox)
env:
RUSTFLAGS: -Dwarnings --cfg getrandom_backend="wasm_js" --cfg getrandom_browser_test
run: wasm-pack test --headless --firefox
- name: Test (Chrome)
env:
RUSTFLAGS: -Dwarnings --cfg getrandom_backend="wasm_js" --cfg getrandom_browser_test
run: wasm-pack test --headless --chrome
- name: Test (Edge)
if: runner.os == 'Windows'
env:
RUSTFLAGS: -Dwarnings --cfg getrandom_backend="wasm_js" --cfg getrandom_browser_test
run: wasm-pack test --headless --chrome --chromedriver $Env:EDGEWEBDRIVER\msedgedriver.exe
- name: Test (Safari)
if: runner.os == 'macOS'
env:
RUSTFLAGS: -Dwarnings --cfg getrandom_backend="wasm_js" --cfg getrandom_browser_test
run: wasm-pack test --headless --safari
wasm64-build:
name: Wasm64 Build
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly # Need to build libstd
with:
components: rust-src
- uses: Swatinem/rust-cache@v2
- name: Build and Link tests (build-std)
env:
RUSTFLAGS: -Dwarnings --cfg getrandom_backend="wasm_js"
# This target is Tier 3, so we have to build libstd ourselves.
# We currently cannot run these tests because wasm-bindgen-test-runner
# does not yet support memory64.
run: cargo test --no-run -Z build-std=std,panic_abort --target=wasm64-unknown-unknown
wasi-tests:
name: WASI Tests
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.82
targets: wasm32-wasip1,wasm32-wasip2
- name: Install Wasmtime
run: |
VERSION=v24.0.0
URL=https://github.com/bytecodealliance/wasmtime/releases/download/${VERSION}/wasmtime-${VERSION}-x86_64-linux.tar.xz
wget -O - $URL | tar -xJ --strip-components=1 -C ~/.cargo/bin
wasmtime --version
- uses: Swatinem/rust-cache@v2
- name: WASI 0.1 Test
run: cargo test --target wasm32-wasip1
- name: WASI 0.2 Test
run: cargo test --target wasm32-wasip2
build-tier2:
name: Tier 2 Build
runs-on: ubuntu-22.04
strategy:
matrix:
target: [
x86_64-unknown-fuchsia,
x86_64-unknown-redox,
x86_64-fortanix-unknown-sgx,
]
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
- name: Build
run: cargo build --target=${{ matrix.target }} --features=std
build-tier3:
name: Tier 3 Build
runs-on: ubuntu-22.04
strategy:
matrix:
# Supported tier 3 targets without libstd support
target: [
x86_64-unknown-hermit,
x86_64-wrs-vxworks,
aarch64-kmc-solid_asp3,
armv6k-nintendo-3ds,
armv7-sony-vita-newlibeabihf,
aarch64-unknown-nto-qnx710,
]
# Supported tier 3 targets with libstd support
include:
- target: aarch64-unknown-nto-qnx710
features: ["std"]
- target: x86_64-unknown-openbsd
features: ["std"]
- target: x86_64-unknown-dragonfly
features: ["std"]
- target: x86_64-unknown-haiku
features: ["std"]
- target: i686-unknown-hurd-gnu
features: ["std"]
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly # Required to build libcore
with:
components: rust-src
- uses: Swatinem/rust-cache@v2
- run: cargo build -Z build-std=${{ contains(matrix.features, 'std') && 'std' || 'core'}} --target=${{ matrix.target }} --features="${{ join(matrix.features, ',') }}"
build-rdrand:
name: RDRAND Build
runs-on: ubuntu-22.04
strategy:
matrix:
target: [
x86_64-unknown-uefi,
x86_64-unknown-l4re-uclibc,
]
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly # Required to build libcore
with:
components: rust-src
- uses: Swatinem/rust-cache@v2
- env:
RUSTFLAGS: -Dwarnings --cfg getrandom_backend="rdrand"
run: cargo build -Z build-std=core --target=${{ matrix.target }}
build-rndr:
name: RNDR Build
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
targets: aarch64-unknown-linux-gnu, aarch64-apple-darwin
- uses: Swatinem/rust-cache@v2
- name: RNDR enabled at compile time (Linux)
env:
RUSTFLAGS: -Dwarnings --cfg getrandom_backend="rndr" -C target-feature=+rand
run: cargo build --target=aarch64-unknown-linux-gnu
- name: Runtime RNDR detection without std (Linux)
env:
RUSTFLAGS: -Dwarnings --cfg getrandom_backend="rndr"
run: cargo build --target=aarch64-unknown-linux-gnu
- name: Runtime RNDR detection with std (macOS)
env:
RUSTFLAGS: -Dwarnings --cfg getrandom_backend="rndr"
run: cargo build --target=aarch64-unknown-linux-gnu --features std
build-esp-idf:
name: ESP-IDF Build
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly # Required to build libcore
with:
components: rust-src
- uses: Swatinem/rust-cache@v2
- env:
RUSTFLAGS: -Dwarnings --cfg getrandom_backend="esp_idf"
run: cargo build -Z build-std=core --target=riscv32imc-esp-espidf
build-no-atomics:
name: No Atomics Build
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: riscv32i-unknown-none-elf
- uses: Swatinem/rust-cache@v2
- env:
RUSTFLAGS: -Dwarnings --cfg getrandom_backend="custom"
run: cargo build --target riscv32i-unknown-none-elf