Skip to content

Commit d53f3f2

Browse files
committed
ci: Use a single action to collect final status
This is copied from how rust-lang/miri-test-libstd does it.
1 parent 46392d7 commit d53f3f2

File tree

2 files changed

+22
-20
lines changed

2 files changed

+22
-20
lines changed

.github/workflows/ci.yaml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,17 @@ jobs:
6868
components: rustfmt
6969
- run: cargo fmt --all --check
7070

71-
ci-success:
72-
name: Complete
71+
# One job that "summarizes" the success state of this pipeline. This can then be added to branch
72+
# protection, rather than having to add each job separately.
73+
success:
74+
name: Success
7375
runs-on: ubuntu-latest
7476
needs: [test, i586, no_std, fmt]
77+
# Github branch protection is exceedingly silly and treats "jobs skipped because a dependency
78+
# failed" as success. So we have to do some contortions to ensure the job fails if any of its
79+
# dependencies fails.
80+
if: always() # make sure this is never "skipped"
7581
steps:
76-
- run: exit 0
77-
ci-failed:
78-
name: Complete
79-
runs-on: ubuntu-latest
80-
needs: [test, i586, no_std, fmt]
81-
if: failure()
82-
steps:
83-
- run: exit 1
82+
# Manually check the status of all dependencies. `if: failure()` does not work.
83+
- name: check if any dependency failed
84+
run: jq --exit-status 'all(.result == "success")' <<< '${{ toJson(needs) }}'

.github/workflows/pr.yaml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,17 @@ jobs:
2828
- uses: actions/checkout@v4
2929
- run: cargo fmt --all --check
3030

31-
ci-success:
32-
name: Complete
31+
# One job that "summarizes" the success state of this pipeline. This can then be added to branch
32+
# protection, rather than having to add each job separately.
33+
success:
34+
name: Success
3335
runs-on: ubuntu-latest
3436
needs: [test, fmt]
37+
# Github branch protection is exceedingly silly and treats "jobs skipped because a dependency
38+
# failed" as success. So we have to do some contortions to ensure the job fails if any of its
39+
# dependencies fails.
40+
if: always() # make sure this is never "skipped"
3541
steps:
36-
- run: exit 0
37-
ci-failed:
38-
name: Complete
39-
runs-on: ubuntu-latest
40-
needs: [test, fmt]
41-
if: failure()
42-
steps:
43-
- run: exit 1
42+
# Manually check the status of all dependencies. `if: failure()` does not work.
43+
- name: check if any dependency failed
44+
run: jq --exit-status 'all(.result == "success")' <<< '${{ toJson(needs) }}'

0 commit comments

Comments
 (0)