@@ -48,42 +48,19 @@ jobs:
4848 run : rustup update stable && rustup default stable && rustup component add rustfmt
4949 - run : cargo fmt --check
5050
51- # These success/failure jobs are here to consolidate the total
52- # success/failure state of all other jobs. These jobs are then included in
53- # the GitHub branch protection rule which prevents merges unless all other
54- # jobs are passing. This makes it easier to manage the list of jobs via this
55- # yml file and to prevent accidentally adding new jobs without also updating
56- # the branch protections.
57- #
58- # Unfortunately this requires two jobs because the branch protection
59- # considers skipped jobs as successful. The status check functions like
60- # success() can only be in an `if` condition.
61- #
62- # Beware that success() is false if any dependent job is skipped. See
63- # https://github.com/orgs/community/discussions/45058. This means there
64- # cannot be optional jobs. One workaround is to check for all other
65- # statuses:
66- # (contains(needs.*.result, 'cancelled') || contains(needs.*.result, 'skipped') || contains(needs.*.result, 'failure'))
67- # but that is a mess.
51+ # The success job is here to consolidate the total success/failure state of
52+ # all other jobs. This job is then included in the GitHub branch protection
53+ # rule which prevents merges unless all other jobs are passing. This makes
54+ # it easier to manage the list of jobs via this yml file and to prevent
55+ # accidentally adding new jobs without also updating the branch protections.
6856 success :
6957 name : Success gate
70- runs-on : ubuntu-latest
58+ if : always()
7159 needs :
7260 - test
7361 - rustfmt
74- if : " success()"
75- steps :
76- - name : mark the job as a success
77- run : echo success
78- failure :
79- name : Failure gate
8062 runs-on : ubuntu-latest
81- needs :
82- - test
83- - rustfmt
84- if : " !success()"
8563 steps :
86- - name : mark the job as a failure
87- run : |
88- echo One or more jobs failed
89- exit 1
64+ - run : jq --exit-status 'all(.result == "success")' <<< '${{ toJson(needs) }}'
65+ - name : Done
66+ run : exit 0
0 commit comments