Skip to content

Commit 419db92

Browse files
ci: fail the Branch protection check when a job it waits on does not succeed (#3840)
The job is main's required status check. Without an if: it was skipped whenever test, contribute, browser or firebase-13 failed, and GitHub counts a skipped required check as satisfied, so a pull request with red tests stayed mergeable. Now the job always runs and exits 1 unless every needed job succeeded. skipped is included because a failed build skips three of the four jobs rather than failing them, and always() rather than !cancelled() because a cancelled run must also leave the check red. Found by Tyler Reitz on #3762.
1 parent 916435a commit 419db92

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

‎.github/workflows/test.yml‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,13 @@ jobs:
193193
runs-on: ubuntu-latest
194194
name: Branch protection
195195
needs: ['test', 'contribute', 'browser', 'firebase-13']
196+
# A skipped job satisfies a required status check, so this job must run on every outcome of
197+
# the jobs above and fail itself. Keep always(), not !cancelled(): a cancelled run must stay red.
198+
if: ${{ always() }}
196199
steps:
197-
- run: true
200+
- name: Fail unless every needed job succeeded
201+
if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') || contains(needs.*.result, 'skipped') }}
202+
run: exit 1
198203

199204
publish:
200205
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)