Skip to content

Commit 39c1bc6

Browse files
committed
Rework CI workflows
- Split `check` into `fmt`, `clippy` and `doc` so that it's clear which one fails in PR. - Remove deprecated `actions-rs/toolchain` - Use `Swatinem/rust-cache@v2` instead of `actions/cache` - Add job `tests-pass` as a srable name for "all tests pass" requirement Signed-off-by: Jiahao XU <[email protected]>
1 parent d13708d commit 39c1bc6

File tree

1 file changed

+52
-39
lines changed

1 file changed

+52
-39
lines changed

.github/workflows/rust.yml

Lines changed: 52 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -16,52 +16,65 @@ on:
1616
- '.gitignore'
1717

1818
jobs:
19-
check:
19+
fmt:
2020
runs-on: ubuntu-latest
2121

2222
steps:
2323
- uses: actions/checkout@v4
24-
- uses: actions/cache@v3
25-
with:
26-
path: |
27-
~/.cargo/bin/
28-
~/.cargo/registry/index/
29-
~/.cargo/registry/cache/
30-
~/.cargo/git/db/
31-
target/
32-
key: ${{ github.event.repository.name }}-${{ runner.os }}-cargo-check-v3
33-
- name: Install latest stable cargo
34-
uses: actions-rs/toolchain@v1
35-
with:
36-
toolchain: stable
37-
override: true
38-
components: rustfmt, clippy
39-
- name: Install cargo nightly
40-
run: rustup install nightly
24+
25+
- run: rustup component add rustfmt
26+
- uses: Swatinem/rust-cache@v2
27+
28+
- run: cargo fmt --all -- --check
29+
30+
clippy:
31+
runs-on: ubuntu-latest
32+
33+
steps:
34+
- uses: actions/checkout@v4
35+
36+
- run: rustup component add clippy
37+
- uses: Swatinem/rust-cache@v2
38+
39+
- run: cargo clippy --all
40+
41+
doc:
42+
runs-on: ubuntu-latest
43+
44+
steps:
45+
- uses: actions/checkout@v4
46+
47+
- run: rustup install nightly --profile minimal
48+
- uses: Swatinem/rust-cache@v2
49+
4150
- name: Run check
42-
run: |
43-
cargo fmt --all -- --check
44-
cargo clippy --all
45-
./build_doc.sh
51+
run: ./build_doc.sh
52+
4653
build:
4754
runs-on: ubuntu-latest
4855

4956
steps:
5057
- uses: actions/checkout@v4
51-
- uses: actions/cache@v3
52-
with:
53-
path: |
54-
~/.cargo/bin/
55-
~/.cargo/registry/index/
56-
~/.cargo/registry/cache/
57-
~/.cargo/git/db/
58-
target/
59-
key: ${{ github.event.repository.name }}-${{ runner.os }}-cargo-test-v6
60-
- name: Install latest nightly
61-
uses: actions-rs/toolchain@v1
62-
with:
63-
toolchain: nightly
64-
override: true
65-
components: rust-src, miri
66-
- name: Run tests
67-
run: ./run_test.sh
58+
59+
- run: |
60+
rustup toolchain install nightly --profile minimal --component rust-src --component miri
61+
rustup override set nightly
62+
- uses: Swatinem/rust-cache@v2
63+
64+
- run: ./run_test.sh
65+
66+
# Dummy job to have a stable name for the "all tests pass" requirement
67+
tests-pass:
68+
name: Tests pass
69+
needs:
70+
- fmt
71+
- clippy
72+
- doc
73+
- build
74+
if: always() # always run even if dependencies fail
75+
runs-on: ubuntu-latest
76+
steps:
77+
# fail if ANY dependency has failed or cancelled
78+
- if: "contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')"
79+
run: exit 1
80+
- run: exit 0

0 commit comments

Comments
 (0)