Skip to content

Commit 82c1267

Browse files
authored
Fix test-result job to run even when dependencies are skipped (#4096)
## Why The test-result job would be skipped if any of its dependencies were skipped, which incorrectly blocked the merge queue. Now it uses `if: always()` to ensure it runs regardless of dependency status, and checks `contains(needs.*.result, 'failure')` to fail only if any dependency actually failed. References: - https://github.com/orgs/community/discussions/25970 - https://github.com/orgs/community/discussions/25789 ## Tests On this Pr, the test-result job succeeds even though most of the builds were skipped. The same job was skipped on the PR that added it.
1 parent 5b33202 commit 82c1267

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

.github/workflows/push.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,14 @@ jobs:
271271
make test-pipelines
272272
273273
# This job groups the result of all the above test jobs.
274-
# If any of them failed, this job will be skipped.
275274
# It is a required check, so it blocks auto-merge and the merge queue.
275+
#
276+
# We use `if: always()` to ensure this job runs even when dependencies are skipped.
277+
# Without it, GitHub Actions skips jobs whose dependencies are skipped, which would
278+
# incorrectly block the merge queue when optional test jobs don't run.
279+
#
280+
# The step checks `contains(needs.*.result, 'failure')` to fail if any dependency failed.
281+
# Reference: https://github.com/orgs/community/discussions/25970
276282
test-result:
277283
needs:
278284
- test
@@ -281,11 +287,17 @@ jobs:
281287
- test-exp-ssh
282288
- test-pipelines
283289

290+
if: ${{ always() }}
284291
name: test-result
285292
runs-on: ubuntu-latest
286293

287294
steps:
288-
- run: echo "All tests passed ✅"
295+
- run: |
296+
if [[ "${{ contains(needs.*.result, 'failure') }}" == "true" ]]; then
297+
echo "One or more required jobs failed ❌"
298+
exit 1
299+
fi
300+
echo "All tests passed ✅"
289301
290302
validate-generated-is-up-to-date:
291303
needs: cleanups

0 commit comments

Comments
 (0)