Skip to content

ci: one live run per workflow per ref (cancel superseded, never cancel main) - #249

Merged
zackees merged 1 commit into
mainfrom
ci/one-live-run-per-ref
Sep 14, 2026
Merged

zackees merged 1 commit into
mainfrom
ci/one-live-run-per-ref

Conversation

@zackees

@zackees zackees commented Sep 14, 2026

Copy link
Copy Markdown
Member

Why

The GitHub-hosted runner pool is shared across every zackees repo (~40 concurrent jobs, 5 macOS). On 2026-09-14 the global queue held 120 jobs behind 36 running; the largest contributors were runs already superseded by a newer push, or belonging to PRs merged a day earlier. Every such run is dead weight that delays every other repo.

The rule

At most one live run per workflow per non-main ref. A new push to a branch or PR cancels the run it supersedes instead of queuing behind it. Runs on main are never cancelled and never coalesced — each merge keeps its own full result — which is why the main group is keyed on run_id rather than the ref (a shared ref group would let GitHub replace a pending main run with the next one).

concurrency:
  group: ${{ github.workflow }}-${{ github.ref == 'refs/heads/main' && github.run_id || github.ref }}
  cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}

Release/publish/tag workflows get group: <workflow>-<run_id>, cancel-in-progress: false: never cancelled, never coalesced.

What changed here (24 files)

  • Workflows with no concurrency block got the block above, inserted after on:.
  • Existing per-ref blocks (group: …${{ github.ref }}… with cancel-in-progress: true or ${{ github.event_name == 'pull_request' }}) were normalized to the same shape — the old forms either cancelled main runs, or did not cancel superseded pushes to feature branches that have no PR yet.
  • Untouched: workflow_call-only workflows (the caller's group governs them) and constant, non-ref groups (deliberate cross-ref serialization).

Mechanical change generated by one script and applied fleet-wide; YAML validated. The same PR is open in every affected repo.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Vf5U1eUfawCVRTVnJSF2He

Every workflow now carries a top-level concurrency group so a new push to a
branch or PR cancels the superseded run instead of queuing behind it in the
shared account-wide runner pool. Runs on main get a unique group (run_id) so
they are never cancelled and never coalesced; release/publish workflows are
likewise never cancelled. Reusable (workflow_call) workflows are untouched
because the caller's group governs them; constant cross-ref groups are left
as deliberate serialization.

24 workflow files changed.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vf5U1eUfawCVRTVnJSF2He
@zackees
zackees merged commit f667da4 into main Sep 14, 2026
0 of 22 checks passed
@zackees
zackees deleted the ci/one-live-run-per-ref branch September 14, 2026 17:04
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.

1 participant