Skip to content

Commit 0b1b1e0

Browse files
committed
ci: run status check always but considered cancellations failures
1 parent bcd40ff commit 0b1b1e0

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

.github/workflows/ci.yml

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,4 +202,28 @@ jobs:
202202
- doc
203203
steps:
204204
- name: Exit
205-
run: exit 0
205+
run: |
206+
# if any dependencies were cancelled, that's a failure
207+
#
208+
# see https://docs.github.com/en/actions/reference/workflows-and-actions/expressions#always
209+
# and https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/collaborating-on-repositories-with-code-quality-features/troubleshooting-required-status-checks#handling-skipped-but-required-checks
210+
# for why this cannot be encoded in the job-level `if:` field
211+
#
212+
# TL; DR: `$REASONS`
213+
#
214+
# The intersection of skipped-as-success and required status checks
215+
# creates a scenario where if you DON'T `always()` run this job, the
216+
# status check UI will block merging and if you DO `always()` run and
217+
# a dependency is _cancelled_ (due to a critical failure, which is
218+
# somehow not considered a failure ¯\_(ツ)_/¯) then the critically
219+
# failing job(s) will timeout causing a cancellation here and the
220+
# build to succeed which we don't want (originally this was just
221+
# 'exit 0')
222+
if ${{ needs.test-linux-64.result == 'cancelled' ||
223+
needs.test-linux-aarch64.result == 'cancelled' ||
224+
needs.test-windows.result == 'cancelled' ||
225+
needs.doc.result == 'cancelled' }}; then
226+
exit 1
227+
else
228+
exit 0
229+
fi

0 commit comments

Comments
 (0)