@@ -22,25 +22,15 @@ jobs:
2222 - if : github.event_name != 'release' && github.event_name != 'workflow_dispatch'
2323 uses : Swatinem/rust-cache@v2
2424 - uses : taiki-e/install-action@v2
25- with : { tool: ' just,cargo-llvm-cov' }
25+ with : { tool: just }
2626 - if : github.event_name == 'release'
2727 name : Ensure this crate has not yet been published (on release)
2828 run : just check-if-published
29- - run : RUST_BACKTRACE=1 just -v ci-test
29+ - run : just ci-test
3030 - name : Check semver
3131 uses : obi1kenobi/cargo-semver-checks-action@v2
32- - if : github.event_name != 'release' && github.event_name != 'workflow_dispatch'
33- name : Generate code coverage
34- run : just ci-coverage
35- - if : github.event_name != 'release' && github.event_name != 'workflow_dispatch'
36- name : Upload coverage to Codecov
37- uses : codecov/codecov-action@v5
38- with :
39- token : ${{ secrets.CODECOV_TOKEN }}
40- files : target/llvm-cov/codecov.info
41- fail_ci_if_error : true
4232
43- msrv :
33+ test- msrv :
4434 name : Test MSRV
4535 runs-on : ubuntu-latest
4636 steps :
@@ -57,10 +47,32 @@ jobs:
5747 with :
5848 toolchain : ${{ steps.msrv.outputs.value }}
5949 components : rustfmt
60- - run : just -v ci-test-msrv
50+ - run : just ci-test-msrv
51+ env :
52+ # Ignore warnings in MSRV. Sadly, this cannot be done inside `just ci-test-msrv`
53+ CI : ' '
54+
55+ coverage :
56+ name : Code Coverage
57+ if : github.event_name != 'release'
58+ runs-on : ubuntu-latest
59+ steps :
60+ - uses : actions/checkout@v4
61+ - uses : Swatinem/rust-cache@v2
62+ - uses : taiki-e/install-action@v2
63+ with : { tool: 'just,cargo-llvm-cov' }
64+ - name : Generate code coverage
65+ run : just ci-coverage
66+ - name : Upload coverage to Codecov
67+ uses : codecov/codecov-action@v5
68+ with :
69+ token : ${{ secrets.CODECOV_TOKEN }}
70+ files : target/llvm-cov/codecov.info
71+ fail_ci_if_error : true
6172
6273 build :
6374 name : Build ${{ matrix.target }}
75+ needs : [ test ]
6476 runs-on : ${{ matrix.os }}
6577 strategy :
6678 fail-fast : false
@@ -155,6 +167,7 @@ jobs:
155167
156168 cross-build :
157169 name : Cross-build
170+ needs : [ test ]
158171 runs-on : ubuntu-latest
159172 steps :
160173 - uses : actions/checkout@v4
@@ -182,10 +195,20 @@ jobs:
182195 env :
183196 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
184197
185- publish :
198+ # This job checks if any of the previous jobs failed or were canceled.
199+ # This approach also allows some jobs to be skipped if they are not needed.
200+ ci-passed :
201+ if : always()
202+ needs : [ test, test-msrv, coverage, build, cross-build ]
203+ runs-on : ubuntu-latest
204+ steps :
205+ - if : ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}
206+ run : exit 1
207+
208+ release :
186209 if : startsWith(github.ref, 'refs/tags/')
187210 name : Publish to crates.io
188- needs : [ test, msrv, build, cross-build ]
211+ needs : [ ci-passed ]
189212 runs-on : ubuntu-latest
190213 steps :
191214 - uses : actions/checkout@v4
0 commit comments