Repository navigation
ci: cancel a pull request's superseded runs - #629
Merged
Merged
Conversation
Nothing in this repo's workflows declares a concurrency group, so every push to a PR queued another full CI matrix and the run it replaced kept its place in line. Observed while iterating on #627 and #628: six runs queued at once, the oldest for three hours, four of them for commits that were no longer any branch's HEAD. Nothing started for about three hours; cancelling the four obsolete runs by hand was what got the queue moving again. Group CI by the pull request's branch and cancel in progress, so a new commit supersedes its predecessor's run instead of competing with it. `github.head_ref` is set only for pull_request events. A push to main falls back to `github.run_id`, which is unique per run, so those get a group of their own: they are never cancelled, and never made to queue behind each other either. Only ci.yml is changed. The other five workflows should not cancel: release.yml and docs.yml both run on pushes to `release` and publish artifacts, where aborting halfway is worse than running twice; check_docs.yml runs only on main; close-slate-issues.yml is a weekly cron; issue-notify.yml fires on issue creation. longbridge-mcp has no concurrency group in any of its four workflows, and longbridge-terminal has one in three of seven but not in `test.yml`. Both are worth the same change, but neither has shown the backlog this repo has -- their CI is small where this one fans out across nine jobs and a wide platform matrix -- so they are left for separate PRs rather than bundled in.
This was referenced Nov 19, 2026
hogan-yuan
added a commit
to longbridge/longbridge-mcp
that referenced
this pull request
Nov 19, 2026
No workflow in this repo declares a `concurrency` group, so every push
to a pull request queues another CI run and **the run it replaced keeps
its place in line**.
## The change
```yaml
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
```
`github.head_ref` is set **only** for `pull_request` events, so:
- **a pull request** groups by its branch — a new commit cancels the run
for the commit it replaced
- **a push to main** falls back to `github.run_id`, which is unique per
run, so those get a group of their own: never cancelled, and never made
to queue behind each other
The naive `group: ${{ github.workflow }}-${{ github.ref }}` would do one
or the other to main.
## Prevention here, not a fix
Being straight about this: **I did not observe a backlog in this repo.**
Its CI is a single `check` job, so superseded runs cost little.
The same change landed in longbridge/openapi as longbridge/openapi#629,
where it *was* a real problem — nine jobs across a wide platform matrix,
six runs queued at once, nothing starting for about three hours, four of
them for commits that were no longer any branch's HEAD. This repo has
the same configuration gap and none of the symptoms; the fix is cheap
enough to be worth having before it does.
## Why only `ci.yml`
| workflow | trigger | why untouched |
|---|---|---|
| `release.yml` | `v*` tags | publishes container images; aborting
halfway is worse than running twice |
| `preview.yml` | `workflow_dispatch` | a run is something a person
asked for by hand |
| `registry-health-check.yml` | weekly cron | nothing to supersede |
🤖 Generated with [Claude Code](https://claude.com/claude-code)
hogan-yuan
added a commit
to longbridge/longbridge-terminal
that referenced
this pull request
Nov 19, 2026
`test.yml` is the workflow pull requests actually run, and it is the one
without a `concurrency` group — so every push to a PR queues another run
while **the one it replaced keeps its place in line**.
## The change
```yaml
concurrency:
group: test-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
```
Three workflows here already declare groups (`test-update.yml`,
`update-homebrew.yml`, `update-scoop.yml`), so this follows their naming
style — a literal prefix — rather than importing `${{ github.workflow
}}` from elsewhere.
`github.head_ref` is set **only** for `pull_request` events:
- **a pull request** groups by its branch — a new commit cancels the run
for the commit it replaced
- **a push to main, or a tag**, falls back to `github.run_id`, which is
unique per run, so those get a group of their own: never cancelled,
never queued behind each other
That second half matters more here than it would in a PR-only workflow,
because `test.yml` also runs on `tags: ["*"]`, and a tag build is not
something to cancel. `test-update.yml`'s existing `group:
test-update-${{ github.ref }}` would have that problem; this one does
not.
## Why only `test.yml`
| workflow | trigger | why untouched |
|---|---|---|
| `release.yml` | `v*` tags, `build-test` branch | publishes; aborting
halfway is worse than running twice |
| `release-to-oss.yml` | `workflow_dispatch` | a run is something a
person asked for by hand |
| `test-install.yml` | push to main / tags, path-filtered | **no
`pull_request` trigger at all**, so nothing to supersede |
## Prevention here, not a fix
Being straight about it: **no backlog was observed in this repo** — its
CI is a single `build` job.
The same change landed in longbridge/openapi as longbridge/openapi#629,
where it was a real problem: nine jobs across a wide platform matrix,
six runs queued at once, nothing starting for about three hours, four of
them for commits that were no longer any branch's HEAD. This repo has
the same gap in the workflow that matters and none of the symptoms.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
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.
No workflow in this repo declares a
concurrencygroup, so every push to a pull request queues another full CI matrix and the run it replaced keeps its place in line.What that looked like
Observed while iterating on #627 and #628:
Six runs queued at once; four were for commits that were no longer any branch's HEAD. Nothing started for roughly three hours. Cancelling the four obsolete runs by hand is what got the queue moving again:
With nine jobs fanning out across a wide platform matrix, each obsolete run is a lot of runner time spent on a commit nobody is waiting for.
The change
github.head_refis set only forpull_requestevents, so:github.run_id, which is unique per run, so those get a group of their own: never cancelled, and never made to queue behind each other eitherThat second half matters. The naive
group: ${{ github.workflow }}-${{ github.ref }}would put every main push in one group — either cancelling a main run that a later commit supersedes, or serialising them.Why only
ci.ymlThe other five workflows should not cancel, so they are untouched:
release.ymlreleasedocs.ymlreleasecheck_docs.ymlmainclose-slate-issues.ymlissue-notify.ymlRelated, deliberately not bundled
test.yml.Both are worth the same change, but neither has shown this backlog — their CI is small where this one fans out — so they belong in their own PRs rather than here.
Honest note on how this came up
A good part of the backlog was self-inflicted: I pushed small follow-up commits to #627 and #628 seven times while reviewing them, and in a repo with no concurrency group each of those reset a full matrix. The fix is worth having regardless, but the measurement above is as much a description of my own push cadence as of the CI configuration.
🤖 Generated with Claude Code