Skip to content

Commit 0f834c2

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

File tree

1 file changed

+31
-7
lines changed

1 file changed

+31
-7
lines changed

.github/workflows/ci.yml

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
CUDA_PREV_BUILD_VER: ${{ steps.get-vars.outputs.cuda_prev_build_ver }}
2525
steps:
2626
- name: Checkout repository
27-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
27+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
2828
with:
2929
fetch-depth: 0
3030
- name: Get CUDA build versions
@@ -42,7 +42,7 @@ jobs:
4242
skip: ${{ steps.get-should-skip.outputs.skip }}
4343
steps:
4444
- name: Checkout repository
45-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
45+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
4646
- name: Compute whether to skip builds and tests
4747
id: get-should-skip
4848
env:
@@ -123,7 +123,7 @@ jobs:
123123
name: Test ${{ matrix.host-platform }}
124124
if: ${{ github.repository_owner == 'nvidia' }}
125125
permissions:
126-
contents: read # This is required for actions/checkout
126+
contents: read # This is required for actions/checkout
127127
needs:
128128
- ci-vars
129129
- build-linux-64
@@ -144,7 +144,7 @@ jobs:
144144
name: Test ${{ matrix.host-platform }}
145145
if: ${{ github.repository_owner == 'nvidia' }}
146146
permissions:
147-
contents: read # This is required for actions/checkout
147+
contents: read # This is required for actions/checkout
148148
needs:
149149
- ci-vars
150150
- build-linux-aarch64
@@ -164,7 +164,7 @@ jobs:
164164
name: Test ${{ matrix.host-platform }}
165165
if: ${{ github.repository_owner == 'nvidia' }}
166166
permissions:
167-
contents: read # This is required for actions/checkout
167+
contents: read # This is required for actions/checkout
168168
needs:
169169
- ci-vars
170170
- build-windows
@@ -192,7 +192,7 @@ jobs:
192192
build-ctk-ver: ${{ needs.ci-vars.outputs.CUDA_BUILD_VER }}
193193

194194
checks:
195-
name: Check job status
195+
name: Check job status (not cancelled)
196196
if: always()
197197
runs-on: ubuntu-latest
198198
needs:
@@ -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)