ci: optional compile-only pull request runs, and fail-fast merge groups

Merged
TE
2mo ago
+230-10

Nothing changes when this merges. It adds a switch, off by default, that lets pull requests run compile admission only and leaves the full macOS suite to the merge queue.

Why

Last 7 days of ci.yml pull-request runs: 1,111 runs for about 230 merges (74 succeeded, 433 failed, 604 cancelled by a newer push). About 80% of Mac time, roughly 53,000 Mac-minutes a week, goes to commits that never merge (shares estimated from 25 sampled runs per bucket).

A merge queue runs CI again on every queued pull request, so with today's workflow each macOS pull request would pay for the full suite twice. With compile-only, a merged pull request costs one full suite on the commit that lands plus about 21 Mac-minutes per push: about today's spend, and main can no longer break from two pull requests that each passed alone.

The cost: test failures show up when a pull request is queued, not on each push, and a flaky shard now costs a queue slot.

Summary

  • Switch: repository variable CI_PULL_REQUEST_SUITE=compile-only makes pull requests skip the app-host shards, package tests, lag build and Release build. Merge groups and dispatches always run everything. Unset (today), pull requests run everything.
  • Opt back in: the full-ci label restores the full suite for one pull request; labels are read live, so label and re-run.
  • Fails safe: unreadable labels, an unknown value or a missing output all mean full suite. The tests gate accepts a skipped suite only when full_suite is explicitly false.
  • Fail-fast merge groups: the shard matrix fails fast, and a new merge-group-fail-fast.yml cancels a merge group's run at the first failed job so the queue drops it without waiting on the remaining Macs. It needs actions: write, so it runs from workflow_run on the default branch's copy (a queued pull request cannot edit it), checks out nothing, and uses a GitHub-hosted runner. ci.yml gets no write permission.

Rollout (maintainers)

  1. Admin-merge #13114, then merge this.
  2. Together: set CI_PULL_REQUEST_SUITE=compile-only, create the full-ci label, and add "Require merge queue" to the ruleset "main: block force-push or delete" (squash, status check timeout 360 min, merge limits min 1 / max 5, build concurrency 3, only merge non-failing pull requests).
  3. Back out by deleting the variable. Do not set the variable without the queue: macOS changes would merge on compile admission alone.

Testing

  • tests/test_ci_change_areas.py (Python 3.9 and 3.12): runs the real tests gate script against compile-only, full, failed and missing-output inputs, covers the policy for every event, and asserts the fail-fast job never checks out code and is not a ci-status dependency. Pass.
  • test_ci_self_hosted_guard.sh, test_ci_merge_queue_required_checks.py, test_ci_reusable_workflow_permissions.py, actionlint: pass.
  • The watcher's step script against a stubbed gh: failure on the second page of jobs (cancels), completed run (exits), API down (errors after ten tries).
  • Not exercised on a real merge group: the queue is off.

Related: #13095

🤖 Generated with Claude Code