Skip to content

Commit 6f4c3ca

Browse files
marcoieniAmanieu
authored andcommitted
add conclusion job
1 parent 808a54f commit 6f4c3ca

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

.github/workflows/main.yml

+14-8
Original file line numberDiff line numberDiff line change
@@ -233,19 +233,25 @@ jobs:
233233
run: rustup update nightly && rustup default nightly
234234
- run: ./ci/build-std-detect.sh
235235

236-
success:
236+
conclusion:
237237
needs:
238238
- docs
239239
- verify
240240
- env_override
241241
- test
242242
- build-std-detect
243243
runs-on: ubuntu-latest
244-
# GitHub branch protection is exceedingly silly and treats "jobs skipped because a dependency
245-
# failed" as success. So we have to do some contortions to ensure the job fails if any of its
246-
# dependencies fails.
247-
if: always() # make sure this is never "skipped"
244+
# We need to ensure this job does *not* get skipped if its dependencies fail,
245+
# because a skipped job is considered a success by GitHub. So we have to
246+
# overwrite `if:`. We use `!cancelled()` to ensure the job does still not get run
247+
# when the workflow is canceled manually.
248+
#
249+
# ALL THE PREVIOUS JOBS NEED TO BE ADDED TO THE `needs` SECTION OF THIS JOB!
250+
if: ${{ !cancelled() }} # make sure this is never "skipped"
248251
steps:
249-
# Manually check the status of all dependencies. `if: failure()` does not work.
250-
- name: check if any dependency failed
251-
run: jq --exit-status 'all(.result == "success")' <<< '${{ toJson(needs) }}'
252+
- name: Conclusion
253+
run: |
254+
# Print the dependent jobs to see them in the CI log
255+
jq -C <<< '${{ toJson(needs) }}'
256+
# Check if all jobs that we depend on (in the needs array) were successful.
257+
jq --exit-status 'all(.result == "success")' <<< '${{ toJson(needs) }}'

0 commit comments

Comments
 (0)