Skip to content

Commit 2aabb63

Browse files
authored
Merge pull request #316 from rust-random/ci
CI: Run iOS targets and other improvements
2 parents 52a4c3c + 4917673 commit 2aabb63

File tree

1 file changed

+104
-126
lines changed

1 file changed

+104
-126
lines changed

.github/workflows/tests.yml

+104-126
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,15 @@ jobs:
1717
name: Docs, deadlinks, minimal dependencies
1818
runs-on: ubuntu-latest
1919
steps:
20-
- uses: actions/checkout@v2
21-
- uses: actions-rs/toolchain@v1
22-
with:
23-
profile: minimal
24-
toolchain: nightly # Needed for -Z minimal-versions and doc_cfg
25-
override: true
26-
- uses: Swatinem/rust-cache@v1
20+
- uses: actions/checkout@v3
21+
- uses: dtolnay/rust-toolchain@nightly # Needed for -Z minimal-versions and doc_cfg
2722
- name: Install precompiled cargo-deadlinks
2823
run: |
2924
export URL=$(curl -s https://api.github.com/repos/deadlinks/cargo-deadlinks/releases/latest | jq -r '.assets[] | select(.name | contains("cargo-deadlinks-linux")) | .browser_download_url')
3025
wget -O /tmp/cargo-deadlinks $URL
3126
chmod +x /tmp/cargo-deadlinks
3227
mv /tmp/cargo-deadlinks ~/.cargo/bin
28+
- uses: Swatinem/rust-cache@v2
3329
- name: Generate Docs
3430
env:
3531
RUSTDOCFLAGS: --cfg docsrs
@@ -38,8 +34,9 @@ jobs:
3834
cargo generate-lockfile -Z minimal-versions
3935
cargo test --features=custom,std
4036
37+
# TODO: add aarch64-based macOS runner when it's supported by Github Actions
4138
main-tests:
42-
name: Main tests
39+
name: Tier 1 Test
4340
runs-on: ${{ matrix.os }}
4441
strategy:
4542
matrix:
@@ -50,21 +47,19 @@ jobs:
5047
- os: macos-latest
5148
toolchain: stable
5249
steps:
53-
- uses: actions/checkout@v2
54-
- uses: actions-rs/toolchain@v1
50+
- uses: actions/checkout@v3
51+
- uses: dtolnay/rust-toolchain@master
5552
with:
56-
profile: minimal
5753
toolchain: ${{ matrix.toolchain }}
58-
override: true
59-
- uses: Swatinem/rust-cache@v1
54+
- uses: Swatinem/rust-cache@v2
6055
- run: cargo test
6156
- run: cargo test --features=std
6257
- run: cargo test --features=custom # custom should do nothing here
6358
- if: ${{ matrix.toolchain == 'nightly' }}
6459
run: cargo test --benches
6560

6661
linux-tests:
67-
name: Additional Linux targets
62+
name: Linux Test
6863
runs-on: ubuntu-latest
6964
strategy:
7065
matrix:
@@ -74,46 +69,45 @@ jobs:
7469
i686-unknown-linux-musl,
7570
]
7671
steps:
77-
- uses: actions/checkout@v2
78-
- uses: actions-rs/toolchain@v1
72+
- uses: actions/checkout@v3
73+
- uses: dtolnay/rust-toolchain@stable
7974
with:
80-
profile: minimal
81-
target: ${{ matrix.target }}
82-
toolchain: stable
83-
- uses: Swatinem/rust-cache@v1
75+
targets: ${{ matrix.target }}
8476
- name: Install multilib
8577
# update is needed to fix the 404 error on install, see:
8678
# https://github.com/actions/virtual-environments/issues/675
8779
run: |
8880
sudo apt-get update
8981
sudo apt-get install gcc-multilib
82+
- uses: Swatinem/rust-cache@v2
9083
- run: cargo test --target=${{ matrix.target }} --features=std
9184

92-
# We can only Build/Link on these targets for now.
93-
# TODO: Run the iOS binaries in the simulator
94-
# TODO: build/run aarch64-apple-darwin binaries on a x86_64 Mac
95-
apple-tests:
96-
name: Additional Apple targets
85+
ios-tests:
86+
name: iOS Simulator Test
9787
runs-on: macos-latest
98-
strategy:
99-
matrix:
100-
target: [
101-
aarch64-apple-ios,
102-
x86_64-apple-ios,
103-
]
10488
steps:
105-
- uses: actions/checkout@v2
106-
- uses: actions-rs/toolchain@v1
89+
- uses: actions/checkout@v3
90+
- uses: dtolnay/rust-toolchain@stable
10791
with:
108-
profile: minimal
109-
target: ${{ matrix.target }}
110-
toolchain: stable
111-
- uses: Swatinem/rust-cache@v1
112-
- name: Build Tests
113-
run: cargo test --no-run --target=${{ matrix.target }} --features=std
92+
targets: x86_64-apple-ios
93+
- name: Download cargo-dinghy
94+
run: |
95+
VERSION=0.6.2
96+
URL="https://github.com/sonos/dinghy/releases/download/${VERSION}/cargo-dinghy-macos-${VERSION}.tgz"
97+
curl -L $URL | tar -xz --strip-components=1 -C ~/.cargo/bin
98+
cargo dinghy --version
99+
- name: Setup Simulator
100+
run: |
101+
RUNTIME_ID=$(xcrun simctl list runtimes | grep iOS | cut -d ' ' -f 7 | tail -1)
102+
SIM_ID=$(xcrun simctl create My-iphone7 com.apple.CoreSimulator.SimDeviceType.iPhone-7 $RUNTIME_ID)
103+
xcrun simctl boot $SIM_ID
104+
echo "device=$SIM_ID" >> $GITHUB_ENV
105+
- uses: Swatinem/rust-cache@v2
106+
- name: Run tests
107+
run: cargo dinghy -d ${{ env.device }} test
114108

115109
windows-tests:
116-
name: Additional Windows targets
110+
name: Windows Test
117111
runs-on: windows-latest
118112
strategy:
119113
matrix:
@@ -123,14 +117,11 @@ jobs:
123117
stable-i686-msvc,
124118
]
125119
steps:
126-
- uses: actions/checkout@v2
127-
- name: Install toolchain
128-
uses: actions-rs/toolchain@v1
120+
- uses: actions/checkout@v3
121+
- uses: dtolnay/rust-toolchain@master
129122
with:
130-
profile: minimal
131123
toolchain: ${{ matrix.toolchain }}
132-
override: true
133-
- uses: Swatinem/rust-cache@v1
124+
- uses: Swatinem/rust-cache@v2
134125
- run: cargo test --features=std
135126

136127
cross-tests:
@@ -145,22 +136,29 @@ jobs:
145136
wasm32-unknown-emscripten,
146137
]
147138
steps:
148-
- uses: actions/checkout@v2
149-
- uses: actions-rs/toolchain@v1
150-
with:
151-
profile: minimal
152-
target: ${{ matrix.target }}
153-
toolchain: stable
154-
- uses: Swatinem/rust-cache@v1
139+
- uses: actions/checkout@v3
155140
- name: Install precompiled cross
156141
run: |
157142
export URL=$(curl -s https://api.github.com/repos/cross-rs/cross/releases/latest | jq -r '.assets[] | select(.name | contains("x86_64-unknown-linux-gnu.tar.gz")) | .browser_download_url')
158143
wget -O /tmp/binaries.tar.gz $URL
159144
tar -C /tmp -xzf /tmp/binaries.tar.gz
160145
mv /tmp/cross ~/.cargo/bin
146+
- uses: Swatinem/rust-cache@v2
161147
- name: Test
162148
run: cross test --no-fail-fast --target=${{ matrix.target }} --features=std
163149

150+
macos-link:
151+
name: macOS ARM64 Build/Link
152+
runs-on: macos-latest
153+
steps:
154+
- uses: actions/checkout@v3
155+
- uses: dtolnay/rust-toolchain@stable
156+
with:
157+
targets: aarch64-apple-darwin, aarch64-apple-ios
158+
- uses: Swatinem/rust-cache@v2
159+
- run: cargo test --no-run --target=aarch64-apple-darwin --features=std
160+
- run: cargo test --no-run --target=aarch64-apple-ios --features=std
161+
164162
cross-link:
165163
name: Cross Build/Link
166164
runs-on: ubuntu-latest
@@ -173,39 +171,32 @@ jobs:
173171
x86_64-unknown-netbsd,
174172
]
175173
steps:
176-
- uses: actions/checkout@v2
177-
- uses: actions-rs/toolchain@v1
178-
with:
179-
profile: minimal
180-
target: ${{ matrix.target }}
181-
toolchain: stable
182-
- uses: Swatinem/rust-cache@v1
174+
- uses: actions/checkout@v3
183175
- name: Install precompiled cross
184176
run: |
185177
export URL=$(curl -s https://api.github.com/repos/cross-rs/cross/releases/latest | jq -r '.assets[] | select(.name | contains("x86_64-unknown-linux-gnu.tar.gz")) | .browser_download_url')
186178
wget -O /tmp/binaries.tar.gz $URL
187179
tar -C /tmp -xzf /tmp/binaries.tar.gz
188180
mv /tmp/cross ~/.cargo/bin
181+
- uses: Swatinem/rust-cache@v2
189182
- name: Build Tests
190183
run: cross test --no-run --target=${{ matrix.target }} --features=std
191184

192185
web-tests:
193-
name: Web tests
186+
name: Web Test
194187
runs-on: ubuntu-latest
195188
steps:
196-
- uses: actions/checkout@v2
197-
- uses: actions-rs/toolchain@v1
189+
- uses: actions/checkout@v3
190+
- uses: dtolnay/rust-toolchain@stable
198191
with:
199-
profile: minimal
200-
target: wasm32-unknown-unknown
201-
toolchain: stable
202-
- uses: Swatinem/rust-cache@v1
192+
targets: wasm32-unknown-unknown
203193
- name: Install precompiled wasm-bindgen-test-runner
204194
run: |
205195
export VERSION=$(cargo metadata --format-version=1 | jq -r '.packages[] | select ( .name == "wasm-bindgen" ) | .version')
206196
wget -O /tmp/binaries.tar.gz https://github.com/rustwasm/wasm-bindgen/releases/download/$VERSION/wasm-bindgen-$VERSION-x86_64-unknown-linux-musl.tar.gz
207197
tar -C /tmp -xzf /tmp/binaries.tar.gz --strip-components=1
208198
mv /tmp/wasm-bindgen-test-runner ~/.cargo/bin
199+
- uses: Swatinem/rust-cache@v2
209200
- name: Test (Node)
210201
run: cargo test --target=wasm32-unknown-unknown --features=js
211202
- name: Test (Firefox)
@@ -220,44 +211,39 @@ jobs:
220211
run: cargo test --target=wasm32-unknown-unknown --features=custom
221212

222213
wasm64-tests:
223-
name: WASM memory64
214+
name: wasm64 Build/Link
224215
runs-on: ubuntu-latest
225216
steps:
226-
- uses: actions/checkout@v2
227-
- uses: actions-rs/toolchain@v1
217+
- uses: actions/checkout@v3
218+
- uses: dtolnay/rust-toolchain@nightly # Need to build libstd
228219
with:
229-
profile: minimal
230-
toolchain: nightly
231220
components: rust-src
232-
override: true
233-
- uses: Swatinem/rust-cache@v1
221+
- uses: Swatinem/rust-cache@v2
234222
- name: Build and Link tests (build-std)
235223
# This target is Tier 3, so we have to build libstd ourselves.
236224
# We currently cannot run these tests because wasm-bindgen-test-runner
237225
# does not yet support memory64.
238226
run: cargo test --no-run -Z build-std=std,panic_abort --target=wasm64-unknown-unknown --features=js
239227

240228
wasi-tests:
241-
name: WASI test
229+
name: WASI Test
242230
runs-on: ubuntu-latest
243231
steps:
244-
- uses: actions/checkout@v2
245-
- uses: actions-rs/toolchain@v1
232+
- uses: actions/checkout@v3
233+
- uses: dtolnay/rust-toolchain@stable
246234
with:
247-
profile: minimal
248-
target: wasm32-wasi
249-
toolchain: stable
250-
- uses: Swatinem/rust-cache@v1
235+
targets: wasm32-wasi
251236
- name: Install precompiled wasmtime
252237
run: |
253238
export URL=$(curl -s https://api.github.com/repos/bytecodealliance/wasmtime/releases/latest | jq -r '.assets[] | select(.name | contains("x86_64-linux.tar.xz")) | .browser_download_url')
254239
wget -O /tmp/binaries.tar.xz $URL
255240
tar -C /tmp -xf /tmp/binaries.tar.xz --strip-components=1
256241
mv /tmp/wasmtime ~/.cargo/bin
242+
- uses: Swatinem/rust-cache@v2
257243
- run: cargo test --target wasm32-wasi
258244

259-
build:
260-
name: Build only
245+
build-tier2:
246+
name: Tier 2 Build
261247
runs-on: ubuntu-latest
262248
strategy:
263249
matrix:
@@ -267,65 +253,57 @@ jobs:
267253
x86_64-fortanix-unknown-sgx,
268254
]
269255
steps:
270-
- uses: actions/checkout@v2
271-
- uses: actions-rs/toolchain@v1
256+
- uses: actions/checkout@v3
257+
- uses: dtolnay/rust-toolchain@stable
272258
with:
273-
profile: minimal
274-
target: ${{ matrix.target }}
275-
toolchain: stable
276-
override: true
277-
- uses: Swatinem/rust-cache@v1
259+
targets: ${{ matrix.target }}
260+
- uses: Swatinem/rust-cache@v2
278261
- name: Build
279262
run: cargo build --target=${{ matrix.target }} --features=std
280263

281-
build-std:
282-
name: Build-only (build-std)
264+
build-tier3:
265+
name: Tier 3 Build
283266
runs-on: ubuntu-latest
267+
strategy:
268+
matrix:
269+
# Supported tier 3 targets without libstd support
270+
target: [
271+
x86_64-unknown-hermit,
272+
x86_64-wrs-vxworks,
273+
aarch64-kmc-solid_asp3,
274+
armv6k-nintendo-3ds,
275+
riscv32imc-esp-espidf,
276+
]
277+
include:
278+
# Supported tier 3 targets without libstd support
279+
- target: x86_64-unknown-openbsd
280+
features: ["std"]
281+
- target: x86_64-unknown-dragonfly
282+
features: ["std"]
283+
- target: x86_64-unknown-haiku
284+
features: ["std"]
285+
# Unsupported tier 3 targets to test the rdrand feature
286+
- target: x86_64-unknown-uefi
287+
features: ["rdrand"]
288+
- target: x86_64-unknown-l4re-uclibc
289+
features: ["rdrand"]
284290
steps:
285-
- uses: actions/checkout@v2
286-
- name: Install toolchain
287-
uses: actions-rs/toolchain@v1
291+
- uses: actions/checkout@v3
292+
- uses: dtolnay/rust-toolchain@nightly # Required to build libcore
288293
with:
289-
profile: minimal
290-
toolchain: nightly # Required to build libcore
291294
components: rust-src
292-
override: true
293-
- uses: Swatinem/rust-cache@v1
294-
- name: Hermit (x86-64 only)
295-
run: cargo build -Z build-std=core --target=x86_64-unknown-hermit
296-
- name: UEFI (RDRAND)
297-
run: cargo build -Z build-std=core --features=rdrand --target=x86_64-unknown-uefi
298-
- name: L4Re (RDRAND)
299-
run: cargo build -Z build-std=core --features=rdrand --target=x86_64-unknown-l4re-uclibc
300-
- name: VxWorks
301-
run: cargo build -Z build-std=core --target=x86_64-wrs-vxworks
302-
- name: SOLID
303-
run: cargo build -Z build-std=core --target=aarch64-kmc-solid_asp3
304-
- name: Nintendo 3DS
305-
run: cargo build -Z build-std=core --target=armv6k-nintendo-3ds
306-
- name: RISC-V ESP-IDF
307-
run: cargo build -Z build-std=core --target=riscv32imc-esp-espidf
308-
- name: OpenBSD
309-
run: cargo build -Z build-std=std --target=x86_64-unknown-openbsd --features=std
310-
- name: Dragonfly BSD
311-
run: cargo build -Z build-std=std --target=x86_64-unknown-dragonfly --features=std
312-
- name: Haiku OS
313-
run: cargo build -Z build-std=std --target=x86_64-unknown-haiku --features=std
295+
- uses: Swatinem/rust-cache@v2
296+
- run: cargo build -Z build-std=${{ contains(matrix.features, 'std') && 'std' || 'core'}} --target=${{ matrix.target }} --features="${{ join(matrix.features, ',') }}"
314297

315298
clippy-fmt:
316299
name: Clippy + rustfmt
317300
runs-on: ubuntu-latest
318301
steps:
319302
- uses: actions/checkout@v1
320-
- uses: actions-rs/toolchain@v1
303+
- uses: dtolnay/rust-toolchain@stable
321304
with:
322-
profile: minimal
323-
# https://github.com/rust-lang/rust-clippy/pull/6379 added MSRV
324-
# support, so we need to use nightly until this is on stable.
325-
toolchain: nightly
326305
components: rustfmt, clippy
327-
override: true
328-
- uses: Swatinem/rust-cache@v1
306+
- uses: Swatinem/rust-cache@v2
329307
- name: clippy
330308
run: cargo clippy --all --features=custom,std
331309
- name: fmt

0 commit comments

Comments
 (0)