ci: cancel superseded runs + skip redundant post-close re-runs - #237
Merged
Conversation
ci.yml: 1. Concurrency block keyed by workflow + PR number (or ref for branch-direct pushes) with cancel-in-progress: true. Standard pattern: a new commit to the same PR cancels the prior run in flight. Multiple concurrent PRs don't trip over each other. 2. Explicit pull_request types: [opened, synchronize, reopened]. Default types include 'closed', which made every merge trigger a redundant CI run re-verifying already-green code. Excluding it stops that waste. release.yml: - Same concurrency block + 'workflow_dispatch' trigger so a tag re-push or manual re-run cancels the prior release in flight. Why this lands: - Earlier today (#236 investigation) we found 5 queued CI runs, 3 of them orphaned by already-merged PRs. `gh run cancel` is fine for cleanup; the underlying fix is preventing fresh waste from this pattern. Why the explicit types matter: - Pre-existing bug, not just theoretical. Merges were triggering extra CI runs we were paying for. `types: [closed]` was silently enabled. This PR disables it. Pattern sourced from Next.js, TypeScript, Cargo, and the official GH concurrency docs as of 2026-07. Files: - .github/workflows/ci.yml (+15 lines) - .github/workflows/release.yml (+8 lines, including workflow_dispatch trigger)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Two small workflow changes for cleaner CI:
concurrencyblock on bothci.ymlandrelease.yml. Cancels in-flight/queued runs when a new commit lands on the same PR (or same branch/tag ref). Standard industry pattern.pull_request: types: [opened, synchronize, reopened]onci.yml. Excludes the previously-defaultedclosedevent that was making every merge trigger a redundant CI run.workflow_dispatchadded torelease.ymlso a manualgh workflow runre-run cancels the prior in-flight release.Diff
Why
Concurrency
Earlier today we found 5 queued CI runs, 3 of them orphaned by already-merged PRs and not actually doing anything useful.
gh run cancelcleans up the symptom. This prevents the cause from recurring.A new commit to an open PR (push, force-push, merge from a contributor fork) will now cancel the prior queued/in-flight run for that PR. Multiple concurrent PRs are still safe — each gets its own concurrency key (
PR_numbervs another).Direct
pushtomainnow triggers CI (was previously only running on PRs). That's correct hygiene — direct pushes to a protected branch should still be gated. Branch-direct pushes for routine repo work benefit from the same gating matrix.The
closedevent exclusionThis is a latent bug we didn't know we had.
on: pull_request:without an explicittypes:defaults to[opened, synchronize, reopened, closed]. Theclosedvariant fires every time a PR is merged or closed, and each fire re-runs CI on already-merged code. We were paying for a redundant CI run on every merge.Excluding
closedstops this. Merges no longer trigger post-merge CI runs. Any orphaned queued run from before merge just ages out harmlessly (GH has an upper bound on queue lifetime).What I deliberately skip
gh run cancel <id>is sufficient when noticed.ubuntu-latest(first-party hosted) is faster for our size than maintaining a runner.Pattern sources
https://github.com/vercel/next.js/blob/canary/.github/workflows/build.ymlhttps://github.com/microsoft/TypeScript/blob/main/.github/workflows/ci.ymlhttps://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#concurrencyVerification
python3 yaml.safe_loadon both workflowsOnce Actions recovers from the current outage, this PR's run will demonstrate the new behavior naturally — a force-push after this point cancels the queued run.