Skip to content

Commit 1c6749e

Browse files
authored
Merge pull request #192 from rust-random/ci
Update Github Actions CI for the master branch
2 parents 6c94834 + 7b8f2ba commit 1c6749e

File tree

4 files changed

+162
-66
lines changed

4 files changed

+162
-66
lines changed

.cargo/config

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
# Allow normal use of "cargo run" and "cargo test" on these wasm32 platforms.
12
[target.wasm32-unknown-unknown]
23
runner = 'wasm-bindgen-test-runner'
3-
44
[target.wasm32-wasi]
55
runner = 'wasmtime'

.clippy.toml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
msrv = "1.34"

.github/workflows/tests.yml

+160-63
Original file line numberDiff line numberDiff line change
@@ -14,36 +14,47 @@ env:
1414

1515
jobs:
1616
check-doc:
17-
name: Doc deadlinks
17+
name: Docs, deadlinks, minimal dependencies
1818
runs-on: ubuntu-latest
1919
steps:
2020
- uses: actions/checkout@v2
21-
- name: Install toolchain
22-
uses: actions-rs/toolchain@v1
21+
- uses: actions-rs/toolchain@v1
2322
with:
2423
profile: minimal
25-
toolchain: nightly
24+
toolchain: nightly # Needed for -Z minimal-versions
2625
override: true
27-
- run: cargo install cargo-deadlinks
28-
- run: cargo deadlinks -- --features custom
26+
- name: Install precompiled cargo-deadlinks
27+
run: |
28+
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')
29+
wget -O /tmp/cargo-deadlinks $URL
30+
chmod +x /tmp/cargo-deadlinks
31+
mv /tmp/cargo-deadlinks ~/.cargo/bin
32+
- run: cargo deadlinks -- --features=custom,std
33+
- run: |
34+
cargo generate-lockfile -Z minimal-versions
35+
cargo test --features=custom,std
2936
3037
main-tests:
3138
name: Main tests
3239
runs-on: ${{ matrix.os }}
3340
strategy:
3441
matrix:
35-
os: [ubuntu-latest, macos-latest, windows-latest]
42+
os: [ubuntu-latest, windows-latest]
3643
toolchain: [nightly, beta, stable, 1.34]
44+
# Only Test macOS on stable to reduce macOS CI jobs
45+
include:
46+
- os: macos-latest
47+
toolchain: stable
3748
steps:
3849
- uses: actions/checkout@v2
39-
- name: Install toolchain
40-
uses: actions-rs/toolchain@v1
50+
- uses: actions-rs/toolchain@v1
4151
with:
4252
profile: minimal
4353
toolchain: ${{ matrix.toolchain }}
4454
override: true
4555
- run: cargo test
46-
- run: cargo test --features std
56+
- run: cargo test --features=std
57+
- run: cargo test --features=custom # custom should do nothing here
4758
- if: ${{ matrix.toolchain == 'nightly' }}
4859
run: cargo build --benches
4960

@@ -59,18 +70,40 @@ jobs:
5970
]
6071
steps:
6172
- uses: actions/checkout@v2
62-
- name: Install toolchain
63-
uses: actions-rs/toolchain@v1
73+
- uses: actions-rs/toolchain@v1
6474
with:
6575
profile: minimal
6676
target: ${{ matrix.target }}
6777
toolchain: stable
68-
override: true
69-
# update is needed to fix the 404 error on install, see:
70-
# https://github.com/actions/virtual-environments/issues/675
71-
- run: sudo apt-get update
72-
- run: sudo apt-get install gcc-multilib
73-
- run: cargo test --target ${{ matrix.target }}
78+
- name: Install multilib
79+
# update is needed to fix the 404 error on install, see:
80+
# https://github.com/actions/virtual-environments/issues/675
81+
run: |
82+
sudo apt-get update
83+
sudo apt-get install gcc-multilib
84+
- run: cargo test --target=${{ matrix.target }} --features=std
85+
86+
# We can only Build/Link on these targets for now.
87+
# TODO: Run the iOS binaries in the simulator
88+
# TODO: build/run aarch64-apple-darwin binaries on a x86_64 Mac
89+
apple-tests:
90+
name: Additional Apple targets
91+
runs-on: macos-latest
92+
strategy:
93+
matrix:
94+
target: [
95+
aarch64-apple-ios,
96+
x86_64-apple-ios,
97+
]
98+
steps:
99+
- uses: actions/checkout@v2
100+
- uses: actions-rs/toolchain@v1
101+
with:
102+
profile: minimal
103+
target: ${{ matrix.target }}
104+
toolchain: stable
105+
- name: Build Tests
106+
run: cargo test --no-run --target=${{ matrix.target }} --features=std
74107

75108
windows-tests:
76109
name: Additional Windows targets
@@ -90,88 +123,149 @@ jobs:
90123
profile: minimal
91124
toolchain: ${{ matrix.toolchain }}
92125
override: true
93-
- run: cargo test
126+
- run: cargo test --features=std
94127

128+
# TODO: Add emscripten when it's working with Cross
95129
cross-tests:
96-
name: Cross tests
97-
runs-on: ${{ matrix.os }}
130+
name: Cross Test
131+
runs-on: ubuntu-latest
98132
strategy:
99133
matrix:
100-
include:
101-
- os: ubuntu-latest
102-
target: mips-unknown-linux-gnu
103-
toolchain: stable
134+
target: [
135+
aarch64-unknown-linux-gnu,
136+
aarch64-linux-android,
137+
mips-unknown-linux-gnu,
138+
]
104139
steps:
105140
- uses: actions/checkout@v2
106-
- name: Install toolchain
107-
uses: actions-rs/toolchain@v1
141+
- uses: actions-rs/toolchain@v1
108142
with:
109143
profile: minimal
110144
target: ${{ matrix.target }}
111-
toolchain: ${{ matrix.toolchain }}
112-
override: true
113-
- name: Cache cargo plugins
114-
uses: actions/cache@v1
115-
with:
116-
path: ~/.cargo/bin/
117-
key: ${{ runner.os }}-cargo-plugins
118-
- name: Install cross
119-
run: cargo install cross || true
145+
toolchain: stable
146+
- name: Install precompiled cross
147+
run: |
148+
export URL=$(curl -s https://api.github.com/repos/rust-embedded/cross/releases/latest | jq -r '.assets[] | select(.name | contains("x86_64-unknown-linux-gnu.tar.gz")) | .browser_download_url')
149+
wget -O /tmp/binaries.tar.gz $URL
150+
tar -C /tmp -xzf /tmp/binaries.tar.gz
151+
mv /tmp/cross ~/.cargo/bin
120152
- name: Test
121-
run: cross test --no-fail-fast --target ${{ matrix.target }}
153+
run: cross test --no-fail-fast --target=${{ matrix.target }} --features=std
122154

123-
build:
124-
name: Build-only
155+
cross-link:
156+
name: Cross Build/Link
125157
runs-on: ubuntu-latest
126158
strategy:
127159
matrix:
128160
target: [
129161
x86_64-sun-solaris,
162+
x86_64-unknown-netbsd,
163+
]
164+
steps:
165+
- uses: actions/checkout@v2
166+
- uses: actions-rs/toolchain@v1
167+
with:
168+
profile: minimal
169+
target: ${{ matrix.target }}
170+
toolchain: stable
171+
- name: Install precompiled cross
172+
run: |
173+
export URL=$(curl -s https://api.github.com/repos/rust-embedded/cross/releases/latest | jq -r '.assets[] | select(.name | contains("x86_64-unknown-linux-gnu.tar.gz")) | .browser_download_url')
174+
wget -O /tmp/binaries.tar.gz $URL
175+
tar -C /tmp -xzf /tmp/binaries.tar.gz
176+
mv /tmp/cross ~/.cargo/bin
177+
- name: Build Tests
178+
run: cross test --no-run --target=${{ matrix.target }} --features=std
179+
180+
web-tests:
181+
name: Web tests
182+
runs-on: ubuntu-latest
183+
steps:
184+
- uses: actions/checkout@v2
185+
- uses: actions-rs/toolchain@v1
186+
with:
187+
profile: minimal
188+
target: wasm32-unknown-unknown
189+
toolchain: stable
190+
- name: Install precompiled wasm-bindgen-test-runner
191+
run: |
192+
export VERSION=$(cargo metadata --format-version=1 | jq -r '.packages[] | select ( .name == "wasm-bindgen" ) | .version')
193+
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
194+
tar -C /tmp -xzf /tmp/binaries.tar.gz --strip-components=1
195+
mv /tmp/wasm-bindgen-test-runner ~/.cargo/bin
196+
- name: Test (Node)
197+
run: cargo test --target=wasm32-unknown-unknown --features=js
198+
- name: Test (Firefox)
199+
env:
200+
GECKODRIVER: /usr/bin/geckodriver
201+
run: cargo test --target=wasm32-unknown-unknown --features=js,test-in-browser
202+
- name: Test (Chrome)
203+
env:
204+
CHROMEDRIVER: /usr/bin/chromedriver
205+
run: cargo test --target=wasm32-unknown-unknown --features=js,test-in-browser
206+
- name: Build Tests (with custom, without JS)
207+
run: cargo test --no-run --target=wasm32-unknown-unknown --features=custom
208+
209+
wasi-tests:
210+
name: WASI test
211+
runs-on: ubuntu-latest
212+
steps:
213+
- uses: actions/checkout@v2
214+
- uses: actions-rs/toolchain@v1
215+
with:
216+
profile: minimal
217+
target: wasm32-wasi
218+
toolchain: stable
219+
- name: Install precompiled wasmtime
220+
run: |
221+
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')
222+
wget -O /tmp/binaries.tar.xz $URL
223+
tar -C /tmp -xf /tmp/binaries.tar.xz --strip-components=1
224+
mv /tmp/wasmtime ~/.cargo/bin
225+
- run: cargo test --target wasm32-wasi
226+
227+
build:
228+
name: Build only
229+
runs-on: ubuntu-latest
230+
strategy:
231+
matrix:
232+
target: [
130233
x86_64-unknown-freebsd,
131234
x86_64-fuchsia,
132-
x86_64-unknown-netbsd,
133235
x86_64-unknown-redox,
134236
x86_64-fortanix-unknown-sgx,
135237
]
136238
steps:
137239
- uses: actions/checkout@v2
138-
- name: Install toolchain
139-
uses: actions-rs/toolchain@v1
240+
- uses: actions-rs/toolchain@v1
140241
with:
141242
profile: minimal
142243
target: ${{ matrix.target }}
143-
toolchain: nightly
244+
toolchain: nightly # Required to build libc for Redox
144245
override: true
145246
- name: Build
146-
run: cargo build --target ${{ matrix.target }}
247+
run: cargo build --target=${{ matrix.target }} --features=std
147248

148-
build-rdrand:
149-
name: Build-only RDRAND
249+
build-std:
250+
name: Build-only (build-std)
150251
runs-on: ubuntu-latest
151252
steps:
152253
- uses: actions/checkout@v2
153254
- name: Install toolchain
154255
uses: actions-rs/toolchain@v1
155256
with:
156257
profile: minimal
157-
toolchain: nightly
258+
toolchain: nightly # Required to build libcore
158259
components: rust-src
159260
override: true
160-
- name: Cache cargo plugins
161-
uses: actions/cache@v1
162-
with:
163-
path: ~/.cargo/bin/
164-
key: ${{ runner.os }}-cargo-plugins
165-
- name: Install xbuild
166-
run: cargo install cargo-xbuild || true
167-
- name: UEFI
168-
run: cargo xbuild --features=rdrand --target x86_64-unknown-uefi
169-
- name: Hermit
170-
run: cargo xbuild --features=rdrand --target x86_64-unknown-hermit
171-
- name: L4Re
172-
run: cargo xbuild --features=rdrand --target x86_64-unknown-l4re-uclibc
261+
- name: UEFI (RDRAND)
262+
run: cargo build -Z build-std=core --features=rdrand --target=x86_64-unknown-uefi
263+
- name: Hermit (RDRAND)
264+
run: cargo build -Z build-std=core --features=rdrand --target=x86_64-unknown-hermit
265+
- name: L4Re (RDRAND)
266+
run: cargo build -Z build-std=core --features=rdrand --target=x86_64-unknown-l4re-uclibc
173267
- name: VxWorks
174-
run: cargo xbuild --features=rdrand --target x86_64-wrs-vxworks
268+
run: cargo build -Z build-std=core --target=x86_64-wrs-vxworks
175269

176270
clippy-fmt:
177271
name: Clippy + rustfmt
@@ -181,9 +275,12 @@ jobs:
181275
- uses: actions-rs/toolchain@v1
182276
with:
183277
profile: minimal
184-
toolchain: stable
278+
# https://github.com/rust-lang/rust-clippy/pull/6379 added MSRV
279+
# support, so we need to use nightly until this is on stable.
280+
toolchain: nightly
185281
components: rustfmt, clippy
282+
override: true
186283
- name: clippy
187-
run: cargo clippy --all
284+
run: cargo clippy --all --features=custom,std
188285
- name: fmt
189286
run: cargo fmt --all -- --check

src/lib.rs

-2
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,6 @@
146146
)]
147147
#![no_std]
148148
#![warn(rust_2018_idioms, unused_lifetimes, missing_docs)]
149-
// `matches!` macro was added only in Rust 1.42, which is bigger than our MSRV
150-
#![allow(clippy::match_like_matches_macro)]
151149

152150
#[macro_use]
153151
extern crate cfg_if;

0 commit comments

Comments
 (0)