Skip to content

ci: cancel superseded pull request runs - #673

Merged
alexander-akait merged 2 commits into
mainfrom
ci/cancel-outdated-runs
Sep 18, 2026
Merged

alexander-akait merged 2 commits into
mainfrom
ci/cancel-outdated-runs

Conversation

@alexander-akait

@alexander-akait alexander-akait commented Sep 18, 2026 •

Copy link
Copy Markdown
Member

Pushing a new commit to a pull request currently leaves the previous commit's jobs running to completion, even though nobody will read their results.

Test alone is 28 jobs per push — three operating systems × nine Node.js versions, plus lint — and Cross-runtime adds three more. PR #667 went through five pushes this afternoon, so roughly 130 job-runs were obsolete the moment they started.

Change

Test and Cross-runtime get the concurrency group Benchmarks already had:

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: ${{ github.event_name == 'pull_request' }}

github.workflow is in the group key, so the workflows never cancel each other. On a pull_request event github.ref is refs/pull/<n>/merge, which is unique per pull request, so one PR's pushes never cancel another's.

Why main is exempt

The condition is the point of the change, not decoration. Benchmarks cancelled main runs until now, and this stops that too:

  • CodSpeed compares a pull request against the benchmark result of its base commit. Two merges in quick succession would cancel the first one's run and leave later comparisons without a baseline.
  • Codecov's project check compares against main coverage in the same way.
  • A cancelled main run hides a breakage that is already on the default branch.

Left alone deliberately

  • Release — already has concurrency: ${{ github.workflow }}-${{ github.ref }}. The string form defaults cancel-in-progress to false, so releases queue instead of cancelling, which is what you want for something that publishes.
  • Dependabot — one short job that approves and enables auto-merge. Cancelling it halfway could leave a pull request without the auto-merge it was about to turn on, and there is nothing to save.

Verification

actionlint 1.7.7 passes on all five workflows. I checked that this means something by typo'ing the expression to github.event_nam and confirming it is caught:

.github/workflows/test.yml:16:27: property "event_nam" is not defined in object type {…}
   |
16 |   cancel-in-progress: ${{ github.event_nam == 'pull_request' }}
   |                           ^~~~~~~~~~~~~~~~

All five workflows also still parse as YAML and are Prettier-clean. No changeset: CI-only change, matching how previous ci: commits were handled here.

🤖 Generated with Claude Code

https://claude.ai/code/session_016aGHrb1YaEvaGwNELGEHjF


Generated by Claude Code

Summary by CodeRabbit

  • Chores
    • Improved automated workflow run management by grouping pull request runs by workflow and Git reference.
    • In-progress pull request runs are cancelled when a newer run starts, reducing redundant checks.
    • Pushes to the main branch and manually triggered runs now use independent run groups and are not cancelled, preserving benchmark baselines and ongoing validation.

Pushing a new commit to a pull request leaves the previous commit's jobs
running to completion even though nobody will look at their results. For
`Test` that is 28 jobs (three operating systems by nine Node.js versions,
plus lint), and `Cross-runtime` adds three more.

Give `Test` and `Cross-runtime` the concurrency group `Benchmarks` already
had, so a new commit cancels the runs it supersedes.

Runs for `main` are exempt everywhere, including in `Benchmarks`, which
cancelled them until now: they are the baseline Codecov and CodSpeed compare
pull requests against, and cancelling one would also hide a breakage that is
already on the default branch.

`Release` keeps its existing group, which queues rather than cancels, and
`Dependabot` is left alone: cancelling it halfway could leave a pull request
without the auto-merge it was about to enable.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016aGHrb1YaEvaGwNELGEHjF
@changeset-bot

changeset-bot Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 900ca86

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai

coderabbitai Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 151288b6-fd25-4ff8-85e4-086a602a114c

📥 Commits

Reviewing files that changed from the base of the PR and between 7459187 and 900ca86.

📒 Files selected for processing (3)
  • .github/workflows/benchmarks.yml
  • .github/workflows/cross-runtime.yml
  • .github/workflows/test.yml
🚧 Files skipped from review as they are similar to previous changes (2)
  • .github/workflows/benchmarks.yml
  • .github/workflows/test.yml

Included review availability: Your plan provides up to 4 included reviews per hour; 2 remain after this review.


Walkthrough

The benchmark, cross-runtime, and test workflows now use conditional concurrency groups. Pull request runs share groups based on workflow and ref and can cancel in-progress runs. Non-pull-request runs use unique run IDs and are not cancelled. Comments document the behavior, including preservation of main runs for CodSpeed baseline comparisons.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 900ca

Pull-request runs are cancellable and non-pull-request runs remain isolated; no merge-blocking risk is established.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main CI change: cancelling superseded pull request runs. It is concise and directly related to the workflow concurrency updates.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 266b531d-dd9d-4442-a164-7e6db5c8b99a

📥 Commits

Reviewing files that changed from the base of the PR and between e913bc5 and 7459187.

📒 Files selected for processing (3)
  • .github/workflows/benchmarks.yml
  • .github/workflows/cross-runtime.yml
  • .github/workflows/test.yml

Included review availability: Your plan provides up to 4 included reviews per hour; 2 remain after this review.

Comment thread .github/workflows/benchmarks.yml
@codecov

codecov Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.14%. Comparing base (e913bc5) to head (900ca86).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #673   +/-   ##
=======================================
  Coverage   98.14%   98.14%           
=======================================
  Files          49       49           
  Lines       10046    10046           
=======================================
  Hits         9860     9860           
  Misses        186      186           
Flag Coverage Δ
integration 98.14% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@codspeed

codspeed Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

Merging this PR will degrade performance by 85.11%

❌ 2 regressed benchmarks
✅ 140 untouched benchmarks

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ Memory extensions-many: 6-extension list (warm) 2.8 KB 100.4 KB -97.23%
❌ Memory node-compare: node require.resolve x 1000 76 KB 95.1 KB -20.09%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing ci/cancel-outdated-runs (900ca86) with main (e913bc5)

Open in CodSpeed

`cancel-in-progress` only protects the run that is already executing. A
concurrency group holds at most one pending run, and GitHub cancels that
pending run whenever a newer one enters the group, whatever
`cancel-in-progress` says. Keying every run of a workflow on the ref
therefore did not deliver what the comments promised: with one `main` run
executing and a second waiting, a third push would have evicted the second,
which is exactly the "two merges in quick succession" case this is meant to
protect.

Group only pull request runs by ref; give everything else `github.run_id`,
so each is a group of one that can be neither cancelled nor evicted.

Also corrects the matrix in the comment: nine Node.js versions, not ten.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016aGHrb1YaEvaGwNELGEHjF

Copy link
Copy Markdown
Member Author

CodSpeed Performance Analysis is failing here with "Performance Regression: -85.11%":

Mode Benchmark BASE HEAD
❌ Memory extensions-many: 6-extension list (warm) 2.8 KB 100.4 KB -97.23%
❌ Memory node-compare: node require.resolve x 1000 76 KB 95.1 KB -20.09%

This PR changes three YAML files under .github/workflows/ and nothing else — no lib/, no test/, no dependencies. git diff main...HEAD --stat is three workflow files. A change that never reaches the runtime cannot make a benchmark allocate 36× more memory.

So the check is measuring something other than this branch, and it is worth recording that plainly because the same phenomenon is currently red on #667 too, where it is much harder to dismiss confidently. Taken together:

  • On feat: experimental support for Node.js package maps #667 (a real code change), extensions-many: 6-extension list (warm) was reported as -22% in Simulation while array-alias … (warm) was reported as +62.6% in Memory in the same run.
  • Here, on a YAML-only branch, that same extensions-many benchmark is reported as -97% in Memory.

One benchmark swinging 60–97% in both directions across branches that do not touch it — including one that cannot touch it — is the measurement, not the code. CodSpeed says as much itself on #667: "Different runtime environments detected — some benchmarks with significant performance changes were compared across different runtime environments, which may affect the accuracy of the results."

This PR may actually help with that. benchmarks.yml currently cancels main runs, so a main commit can end up with no benchmark result at all and later comparisons fall back to whatever baseline they can find — which is exactly the kind of cross-environment comparison the warning describes. That is the flaw this PR fixes, so the fix and the noisy check share a root cause.

I am not touching the diff for this: there is nothing in three YAML files to make faster. If you want the check green before merging, the regressions can be acknowledged in the CodSpeed dashboard — a maintainer action I would not take unasked.


Generated by Claude Code

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