Skip to content

Commit a2fb453

Browse files
authored
Merge pull request #80 from Rust-for-Linux/dev/ci-more-tests
- ci: fix `apply` workflow when there are no new commits to apply - ci: add beta workflow - ci: rename tests to nightly & add strategy + use `cargo hack` - ci: also run `cargo check` in nightly tests - ci: also run tests in other versions than nightly - ci: separate ui & normal tests - ci: only run signed-off-by tests in pull requests - ci: split long lines to make the file more readable
2 parents 1a17c89 + be06808 commit a2fb453

File tree

3 files changed

+188
-25
lines changed

3 files changed

+188
-25
lines changed

.github/workflows/ci.yml

Lines changed: 183 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,35 @@ jobs:
6161
- run: cargo install cargo-hack
6262
- run: git config user.name "github-runner" && git config user.email "<>"
6363
# examples and tests require `alloc`, since they make extensive use of `Box` etc.
64-
- run: git rebase --exec 'cargo hack --clean-per-run --feature-powerset clippy --all-targets --locked --features alloc' --exec 'cargo clean' --root
64+
- run: |
65+
echo '#!/bin/bash
66+
set -e
67+
cargo hack \
68+
--clean-per-run \
69+
--feature-powerset \
70+
clippy \
71+
--all-targets \
72+
--locked \
73+
--features alloc
74+
cargo clean' > exec.sh
75+
git rebase --exec 'bash exec.sh' --root
6576
env:
6677
RUSTFLAGS: "-Dwarnings"
6778
# the core lib does not, so also check that without the alloc feature.
68-
- run: git rebase --exec 'cargo hack --clean-per-run --feature-powerset clippy --lib --locked' --exec 'cargo clean' --root
79+
- run: |
80+
echo '#!/bin/bash
81+
set -e
82+
cargo hack \
83+
--clean-per-run \
84+
--feature-powerset \
85+
clippy \
86+
--lib \
87+
--locked
88+
cargo clean' > exec.sh
89+
git rebase --exec "bash exec.sh" --root
6990
env:
7091
RUSTFLAGS: "-Dwarnings"
71-
test:
92+
ui-tests:
7293
runs-on: ubuntu-latest
7394
steps:
7495
- uses: actions/checkout@v4
@@ -80,19 +101,88 @@ jobs:
80101
components: rust-src
81102
- run: cargo install cargo-expand
82103
- run: git config user.name "github-runner" && git config user.email "<>"
83-
- run: git rebase --exec 'cargo test --locked --all-targets' --root
104+
- run: git rebase --exec 'cargo test ui_ --locked --all-targets' --root
105+
env:
106+
RUSTFLAGS: >
107+
-Dwarnings
108+
--cfg UI_TESTS
109+
nightly:
110+
runs-on: ubuntu-latest
111+
strategy:
112+
matrix:
113+
kind:
114+
- "check --all-targets"
115+
- "test --all-targets"
116+
# doctests are strangely not included in --all-targets
117+
- "--features default test --doc"
118+
name: "nightly/${{matrix.kind}}"
119+
steps:
120+
- uses: actions/checkout@v4
121+
with:
122+
fetch-depth: ${{github.event.pull_request.commits}}
123+
ref: ${{github.event.pull_request.head.sha}}
124+
- uses: dtolnay/rust-toolchain@nightly
125+
with:
126+
components: rust-src
127+
- run: cargo install cargo-expand
128+
- run: cargo install cargo-hack
129+
- run: git config user.name "github-runner" && git config user.email "<>"
130+
- run: |
131+
echo '#!/bin/bash
132+
set -e
133+
cargo hack \
134+
--clean-per-run \
135+
--feature-powerset \
136+
${{matrix.kind}} \
137+
--locked
138+
cargo clean' > exec.sh
139+
git rebase --exec "bash exec.sh" --root
84140
env:
85141
RUSTFLAGS: "-Dwarnings"
86-
# doctests are strangely not included in --all-targets
87-
- run: git rebase --exec 'cargo test --locked --doc' --root
142+
beta:
143+
runs-on: ubuntu-latest
144+
strategy:
145+
matrix:
146+
kind:
147+
- "check --all-targets"
148+
- "test --all-targets"
149+
# doctests are strangely not included in --all-targets
150+
- "--features default test --doc"
151+
name: "beta/${{matrix.kind}}"
152+
steps:
153+
- uses: actions/checkout@v4
154+
with:
155+
fetch-depth: ${{github.event.pull_request.commits}}
156+
ref: ${{github.event.pull_request.head.sha}}
157+
- uses: dtolnay/rust-toolchain@beta
158+
with:
159+
components: rust-src
160+
- run: cargo install cargo-expand
161+
- run: cargo install cargo-hack
162+
- run: git config user.name "github-runner" && git config user.email "<>"
163+
- run: |
164+
echo '#!/bin/bash
165+
set -e
166+
cargo hack \
167+
--clean-per-run \
168+
--feature-powerset \
169+
${{matrix.kind}} \
170+
--locked
171+
cargo clean' > exec.sh
172+
git rebase --exec "bash exec.sh" --root
88173
env:
89174
RUSTFLAGS: "-Dwarnings"
175+
RUSTC_BOOTSTRAP: 1
90176
miri:
91177
runs-on: ubuntu-latest
92178
name: "miri (${{matrix.MIRIFLAGS}})"
93179
strategy:
94180
matrix:
95-
MIRIFLAGS: ["", "-Zmiri-tree-borrows", "-Zmiri-strict-provenance", "-Zmiri-tree-borrows -Zmiri-strict-provenance"]
181+
MIRIFLAGS:
182+
- ""
183+
- "-Zmiri-tree-borrows"
184+
- "-Zmiri-strict-provenance"
185+
- "-Zmiri-tree-borrows -Zmiri-strict-provenance"
96186
steps:
97187
- uses: actions/checkout@v4
98188
with:
@@ -134,25 +224,61 @@ jobs:
134224
sudo apt install llvm
135225
- run: git config user.name "github-runner" && git config user.email "<>"
136226
# sed because of https://github.com/japaric/rust-san#unrealiable-leaksanitizer
137-
- run: git rebase --exec "sed -i '/\[features\]/i [profile.dev]' Cargo.toml && sed -i '/profile.dev/a opt-level = 1' Cargo.toml && cargo test --lib --tests --target x86_64-unknown-linux-gnu && git restore Cargo.toml" --root
227+
- run: |
228+
echo "#!/bin/bash
229+
set -e
230+
sed -i '/\[features\]/i [profile.dev]' Cargo.toml \
231+
&& sed -i '/profile.dev/a opt-level = 1' Cargo.toml \
232+
&& cargo test --lib --tests --target x86_64-unknown-linux-gnu \
233+
&& git restore Cargo.toml" > exec.sh
234+
git rebase --exec "bash exec.sh" --root
138235
env:
139236
ASAN_OPTIONS: "detect_odr_violation=0:detect_leaks=0"
140-
RUSTFLAGS: "--cfg NO_UI_TESTS --cfg NO_ALLOC_FAIL_TESTS -Z sanitizer=address -Dwarnings"
237+
RUSTFLAGS: >
238+
--cfg NO_ALLOC_FAIL_TESTS
239+
-Z sanitizer=address
240+
-Dwarnings
141241
# sed because of https://github.com/japaric/rust-san#unrealiable-leaksanitizer
142242
# doctests are strangely not included in --all-targets
143-
- run: git rebase --exec "sed -i '/\[features\]/i [profile.dev]' Cargo.toml && sed -i '/profile.dev/a opt-level = 1' Cargo.toml && cargo test --doc --target x86_64-unknown-linux-gnu && git restore Cargo.toml" --root
243+
- run: |
244+
echo "#!/bin/bash
245+
set -e
246+
sed -i '/\[features\]/i [profile.dev]' Cargo.toml \
247+
&& sed -i '/profile.dev/a opt-level = 1' Cargo.toml \
248+
&& cargo test --doc --target x86_64-unknown-linux-gnu \
249+
&& git restore Cargo.toml" > exec.sh
250+
git rebase --exec "bash exec.sh" --root
144251
env:
145252
ASAN_OPTIONS: "detect_odr_violation=0:detect_leaks=0"
146-
RUSTFLAGS: "--cfg NO_UI_TESTS --cfg NO_ALLOC_FAIL_TESTS -Z sanitizer=address -Dwarnings"
147-
- run: git rebase --exec 'cargo test --all-targets --target x86_64-unknown-linux-gnu' --root
253+
RUSTFLAGS: >
254+
--cfg NO_ALLOC_FAIL_TESTS
255+
-Z sanitizer=address
256+
-Dwarnings
257+
- run: |
258+
git rebase --exec \
259+
'cargo test --all-targets --target x86_64-unknown-linux-gnu' \
260+
--root
148261
env:
149-
RUSTFLAGS: "--cfg NO_UI_TESTS --cfg NO_ALLOC_FAIL_TESTS -Z sanitizer=leak -Dwarnings"
262+
RUSTFLAGS: >
263+
--cfg NO_ALLOC_FAIL_TESTS
264+
-Z sanitizer=leak
265+
-Dwarnings
150266
# doctests are strangely not included in --all-targets
151-
- run: git rebase --exec 'cargo test --doc --target x86_64-unknown-linux-gnu' --root
267+
- run: |
268+
git rebase --exec \
269+
'cargo test --doc --target x86_64-unknown-linux-gnu' \
270+
--root
152271
env:
153-
RUSTFLAGS: "--cfg NO_UI_TESTS --cfg NO_ALLOC_FAIL_TESTS -Z sanitizer=leak -Dwarnings"
272+
RUSTFLAGS: >
273+
--cfg NO_ALLOC_FAIL_TESTS
274+
-Z sanitizer=leak
275+
-Dwarnings
154276
msrv:
155277
runs-on: ubuntu-latest
278+
strategy:
279+
matrix:
280+
kind: ["check", "test"]
281+
name: "msrv/${{matrix.kind}}"
156282
steps:
157283
- uses: actions/checkout@v4
158284
with:
@@ -161,7 +287,22 @@ jobs:
161287
- uses: dtolnay/rust-toolchain@stable
162288
- run: cargo install cargo-hack
163289
- run: git config user.name "github-runner" && git config user.email "<>"
164-
- run: git rebase --exec 'cargo hack --clean-per-run --feature-powerset --exclude-features unsafe-pinned --exclude-features alloc --exclude-features default --version-range 1.82.. --clean-per-version check --locked --all-targets' --exec 'cargo clean' --root
290+
- run: |
291+
echo '#!/bin/bash
292+
set -e
293+
cargo hack \
294+
--clean-per-run \
295+
--feature-powerset \
296+
--exclude-features alloc \
297+
--exclude-features unsafe-pinned \
298+
--exclude-features default \
299+
--version-range 1.82.. \
300+
--clean-per-version \
301+
${{matrix.kind}} \
302+
--locked \
303+
--all-targets
304+
cargo clean' > exec.sh
305+
git rebase --exec "bash exec.sh" --root
165306
env:
166307
RUSTFLAGS: "-Dwarnings"
167308
nightly-msrv:
@@ -177,7 +318,19 @@ jobs:
177318
- run: cargo install cargo-hack
178319
- run: cargo install cargo-expand
179320
- run: git config user.name "github-runner" && git config user.email "<>"
180-
- run: git rebase --exec 'cargo hack --clean-per-run --feature-powerset --version-range 1.78.. --clean-per-version check --locked --all-targets' --exec 'cargo clean' --root
321+
- run: |
322+
echo '#!/bin/bash
323+
set -e
324+
cargo hack \
325+
--clean-per-run \
326+
--feature-powerset \
327+
--version-range 1.78.. \
328+
--clean-per-version \
329+
check \
330+
--locked \
331+
--all-targets
332+
cargo clean' > exec.sh
333+
git rebase --exec "bash exec.sh" --root
181334
env:
182335
RUSTC_BOOTSTRAP: 1
183336
RUSTFLAGS: "-Dwarnings"
@@ -206,15 +359,18 @@ jobs:
206359
env:
207360
RUSTFLAGS: "-Dwarnings"
208361
signed-off-by:
209-
if: github.event_name != 'schedule'
362+
if: github.event_name == 'pull_request'
210363
runs-on: ubuntu-latest
211364
steps:
212365
- uses: actions/checkout@v4
213366
with:
214367
fetch-depth: ${{github.event.pull_request.commits}}
215368
ref: ${{github.event.pull_request.head.sha}}
216369
- run: git config user.name "github-runner" && git config user.email "<>"
217-
- run: git rebase --exec 'git log --no-merges -1 --pretty=format:%B | grep -q "^Signed-off-by:"' --root
370+
- run: |
371+
git rebase --exec \
372+
'git log --no-merges -1 --pretty=format:%B | grep -q "^Signed-off-by:"' \
373+
--root
218374
apply:
219375
runs-on: ubuntu-latest
220376
steps:
@@ -236,6 +392,10 @@ jobs:
236392
pushd pin-init
237393
git config user.name "github-runner" && git config user.email "<>"
238394
git fetch
395+
if [ "$(git rev-parse HEAD)" = "$(git rev-parse origin/next)" ]; then
396+
# when there are no new commits, we can succeed directly
397+
exit 0
398+
fi
239399
if ! yes | bash ./to-kernel.sh ../kernel origin/next; then
240400
if ! git am --3way; then
241401
git am --show-current-patch=diff
@@ -256,7 +416,10 @@ jobs:
256416
components: rust-src
257417
- run: sudo apt-get install -y linkchecker
258418
- run: git config user.name "github-runner" && git config user.email "<>"
259-
- run: git rebase --exec 'cargo doc --all-features --no-deps && linkchecker target/doc/*/*.html' --root
419+
- run: |
420+
git rebase --exec \
421+
'cargo doc --all-features --no-deps && linkchecker target/doc/*/*.html' \
422+
--root
260423
env:
261424
RUSTFLAGS: "-Dwarnings"
262425
update:

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ prettyplease = { version = "0.2", features = ["verbatim"] }
3636
[lints.rust]
3737
non_ascii_idents = "deny"
3838
unexpected_cfgs = { level = "warn", check-cfg = [
39-
'cfg(NO_UI_TESTS)',
39+
'cfg(UI_TESTS)',
4040
'cfg(NO_ALLOC_FAIL_TESTS)',
4141
'cfg(kernel)',
4242
] }

tests/ui.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#![cfg_attr(not(RUSTC_LINT_REASONS_IS_STABLE), feature(lint_reasons))]
22

33
#[test]
4-
#[cfg_attr(any(miri, NO_UI_TESTS), ignore)]
5-
fn compile_fail() {
4+
#[cfg_attr(not(UI_TESTS), ignore)]
5+
fn ui_compile_fail() {
66
let test_cases = trybuild::TestCases::new();
77
test_cases.compile_fail("tests/ui/compile-fail/pinned_drop/*.rs");
88
test_cases.compile_fail("tests/ui/compile-fail/pin_data/*.rs");
@@ -11,7 +11,7 @@ fn compile_fail() {
1111
}
1212

1313
#[test]
14-
#[cfg_attr(any(miri, NO_UI_TESTS), ignore)]
15-
fn expand() {
14+
#[cfg_attr(not(UI_TESTS), ignore)]
15+
fn ui_expand() {
1616
macrotest::expand("tests/ui/expand/*.rs");
1717
}

0 commit comments

Comments
 (0)