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