Skip to content

Commit 16b1719

Browse files
lfranckeclaude
andcommitted
fix(template): Make "Finished Build and Publish" gate reflect real build outcome
The `finished` job is the single required status check for the build workflow. It had no `if:` clause, so a failed dependency caused GitHub to *skip* it rather than fail it - and branch protection treats a skipped required check as passing. A broken build (e.g. a failed publish-index-manifest) therefore became mergeable. Two fixes: - Add `if: always()` so the gate always runs and reports a real success/failure conclusion. - List every leaf job directly in `needs` and fail the gate on any `failure`/`cancelled` result. Previously publish-index-manifest was only a transitive dependency (via openshift-preflight-check), so its failure would not surface in `needs.*.result`. `skipped` is tolerated, since jobs skip legitimately on merge_group events, forks, and when detect-changes finds no relevant changes. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 272b393 commit 16b1719

1 file changed

Lines changed: 30 additions & 2 deletions

File tree

template/.github/workflows/build.yaml.j2

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,13 +372,41 @@ jobs:
372372
# WARNING: Do not change the name unless you will also be changing the
373373
# Required Checks (in branch protections) in GitHub settings.
374374
name: Finished Build and Publish
375+
# Run even when a dependency failed, was skipped or cancelled, so that this
376+
# gate reflects the real outcome. Without `always()` a failed dependency
377+
# would *skip* this job, and GitHub treats a skipped required check as
378+
# passing - making a broken build mergeable.
379+
if: always()
380+
# List every leaf job directly. A transitive failure (e.g. a failed
381+
# publish-index-manifest that skips openshift-preflight-check) does not
382+
# surface as `failure` in `needs.*.result` unless the failing job is a
383+
# direct dependency.
375384
needs:
385+
- detect-changes
376386
- cargo-udeps
377-
- openshift-preflight-check
387+
- build-container-image
388+
- publish-index-manifest
389+
- provenance-oci
390+
- provenance-quay
378391
- publish-helm-chart
392+
- openshift-preflight-check
379393
runs-on: ubuntu-latest
380394
steps:
381-
- run: echo "We are done here"
395+
# Skipped dependencies are fine (jobs skip legitimately on merge_group
396+
# events, forks, or when detect-changes finds no relevant changes). Only
397+
# a failure or cancellation must fail this gate.
398+
- name: Fail on any failed or cancelled dependency
399+
env:
400+
RESULTS: ${{ join(needs.*.result, ' ') }}
401+
run: |
402+
echo "Dependency results: $RESULTS"
403+
for result in $RESULTS; do
404+
if [ "$result" = "failure" ] || [ "$result" = "cancelled" ]; then
405+
echo "::error::A required job did not succeed (result: $result)"
406+
exit 1
407+
fi
408+
done
409+
echo "We are done here"
382410

383411
notify:
384412
name: Failure Notification

0 commit comments

Comments
 (0)