Skip to content

ci: aggregate required checks into a single required_checks_done gate - #757

Merged
helly25 merged 2 commits into
bazel-contrib:masterfrom
helly25:ci/required-checks-gate
Jun 4, 2026
Merged

helly25 merged 2 commits into
bazel-contrib:masterfrom
helly25:ci/required-checks-gate

Conversation

@helly25

@helly25 helly25 commented Jun 4, 2026

Copy link
Copy Markdown
Collaborator

What

Adds a single required_checks_done job to the Tests workflow that needs: every test job and runs with if: always(). It fails (and names the offending jobs in its log and the run summary) whenever any dependency does not succeed.

Why

Today branch protection has to list every individual job (lint, test, toolchain_test, external_test, container_test, xcompile_test, abs_paths_test, sys_paths_test) as a required status check. Adding, renaming, or removing a job means editing the branch protection settings too, and it's easy to forget.

With this aggregating gate, branch protection only needs to require one check — required_checks_done. Adding/renaming/removing a job now only means editing this job's needs: list.

Behaviour

  • if: always() so the gate still runs when a dependency fails or the run is cancelled (GitHub otherwise skips a needs job whose dependency failed).
  • Reads toJSON(needs) via an env var (not interpolated into the script — avoids injection), writes a Job → Result table to the run summary, and:
    • treats success/skipped as passing (so a future conditionally-skipped job won't deadlock the gate),
    • fails on failure/cancelled, emitting a ::error:: annotation per offending job.

Follow-up (repo settings)

After merge, update branch protection on master to require only required_checks_done and drop the individual job checks.

Add a 'required_checks_done' job that depends on every test job and runs
with 'if: always()'. It fails (and names the offending jobs in its log and
the run summary) when any dependency does not succeed.

This lets branch protection require a single status check instead of every
individual job: adding, renaming, or removing a job now only means editing
this job's 'needs' list, not the branch protection settings.
Add a step to required_checks_done that parses the workflow with yq and
fails if any declared job (other than the gate itself) is missing from its
'needs' list. This prevents a newly added job from silently escaping the
required gate. yq is preinstalled on ubuntu-latest runners.
helly25 added a commit to mboworks/bzl that referenced this pull request Jun 4, 2026
The `done` job was a no-op `echo "Done"`. Without `if: always()`, GitHub
skips it whenever a dependency fails -- so branch protection requiring
only `done` would pass on a job that never actually ran.

Apply the principle from bazel-contrib/toolchains_llvm#757: keep one
required status check, but make it actually gate things.

- `if: always()` so the gate runs on every outcome.
- Reads `toJSON(needs)` via an env var (not script interpolation),
  writes a Job -> Result table to the run summary, treats
  `success`/`skipped` as passing, and fails with `::error::` annotations
  naming each non-passing dep.
- A first step uses `yq` to verify every job declared in main.yml (other
  than `done` itself) is wired into `needs:`, so a newly added job cannot
  silently escape the gate.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@helly25
helly25 merged commit acf8fb4 into bazel-contrib:master Jun 4, 2026
70 checks passed
@helly25
helly25 deleted the ci/required-checks-gate branch June 4, 2026 18:48
helly25 added a commit to mboworks/mbo that referenced this pull request Jun 4, 2026
The `done` job was a no-op `echo "Done"`. Without `if: always()`,
GitHub skips it whenever a dependency fails -- so branch protection
on the single `done` check would pass on a skipped, never-ran job.

Apply the principle from bazel-contrib/toolchains_llvm#757: keep one
required status check, but make it actually gate things. The job now
runs on every outcome, parses `toJSON(needs)` (via env, not script
interpolation), writes a Job -> Result table to the run summary, and
fails with `::error::` annotations naming any dep that didn't
succeed. A second step uses `yq` to verify every job declared in the
workflow is wired into `needs`, so a future job can't silently
escape the gate.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants