ci: run heavy CI jobs on PRs only when opted in via label
Every push to every open PR currently runs the full CI workflow. One full run is ~16.6 runner-hours (unit matrix, itest tranches, windows itest, cross-compilation). Most of those runs happen while a PR is still iterating and nobody is reading the results yet.
Proposal: new PRs get only a fast subset of CI by default. The heavy jobs run once a maintainer or the author opts in with a label.
Why a label
GitHub's built-in skip ([skip ci] and friends) is per commit and driven by the commit message. It can't be toggled per PR or by a reviewer, so the switch has to live in main.yml.
Proposed behavior
| PR state | Jobs |
|---|---|
Draft, or ready without run-ci |
Fast subset. This is what drafts already run today: static checks, lint, commit checks, release notes, dependency pins, non-race unit tests and basic itests. Skipped: cross-compilation, unit-race, full/windows/macOS itests, backwards-compat. |
Ready for review and labeled run-ci |
Full workflow |
merge_group |
Full workflow, always (labels aren't visible here) |
Nightly schedule on master |
Full workflow |
The label name is TBD. An alternative is the inverse, a skip-heavy-ci label on top of a full-by-default policy. That saves less, but it's less surprising for contributors.
Implementation sketch
Most of the plumbing exists:
ci-gatealready computes adocs-onlyoutput that heavy jobs consume. Extend it, or add a sibling output (heavy), to cover "PR event, not draft, and hasrun-ci". Use the live label lookup that.github/actions/check-labelalready does, so a re-run picks up a label added after the run started.- Heavy matrix jobs must keep the matrix instantiated and skip at the step level, as they do for
docs-onlytoday. Otherwise the per-leg required check names are never reported. - Add
labeled(and probablyunlabeled) topull_request.types, so applying the label starts a run. The existing concurrency group cancels the stale run. - Non-PR events (
merge_group,schedule,workflow_dispatch) always setheavy=true.
Hard prerequisite: required merge queue
Skipped required checks count as passing. Without a required merge queue, this label would effectively let a PR merge without the heavy CI ever running. This must only land after the merge queue is required on master; see the discussion on #11421. With the queue required, merge_group runs ignore PR labels and stay the real gate. The label then only controls how much pre-queue feedback a PR gets.
Open questions
- Who may apply the label? Labels need triage permission, so external contributors depend on a maintainer, which is probably what we want for cost. Should the author be able to request it via a comment command?
- Should the label persist across pushes (simplest), or be removed on
synchronizeso each heavy run is a deliberate request? - Are any fast-subset jobs worth promoting to heavy, or the reverse (e.g.
unit-race)?