Skip to content

ci: cancel superseded pull request runs - #273

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

alexander-akait merged 1 commit into
mainfrom
ci/cancel-outdated-runs

Conversation

@alexander-akait

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

Copy link
Copy Markdown
Member

test.yml has no concurrency control at all, so pushing a new commit to a pull request leaves the previous commit's 28 jobs (three operating systems × nine Node.js versions, plus lint) running to completion even though nobody will read their results.

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

Why non-pull-request runs get their own group

Only pull request runs share a group. Everything else gets github.run_id, a group of one, and the reason is not obvious:

cancel-in-progress: false protects only the run that is already executing. A concurrency group holds at most one pending run, and GitHub evicts that pending run whenever a newer one enters the group regardless of the flag — "any existing pending job or workflow in the same concurrency group will be canceled and the new queued job or workflow will take its place." With one main run executing and a second waiting, a third push would evict the second. A group of one cannot be cancelled or evicted.

That matters because main runs publish the coverage later comparisons are measured against, and losing one also hides a breakage that is already on the default branch.

benchmarks.yml also fixed

It already had a group, but with an unconditional cancel-in-progress: true — so a push to main cancels the in-flight benchmark run for the previous main commit. CodSpeed compares a pull request against the benchmark result of its base commit, so two merges in quick succession leave later comparisons without a baseline to use. It now uses the same expression.

Untouched

  • release.yml — already uses the string form concurrency: ${{ github.workflow }}-${{ github.ref }}, which leaves cancel-in-progress false, so releases queue instead of cancelling.
  • dependabot.yml — 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.

Verification

actionlint 1.7.7 is clean on all four workflows, and I checked that this means something by typo'ing the expression to github.event_nam, which it catches at exactly that line. Both files are Prettier-clean.

The same change is going to webpack-sources, watchpack, schema-utils and webpack-cli, and is already open on enhanced-resolve (webpack/enhanced-resolve#673), webpack-dev-server (webpack/webpack-dev-server#5742) and webpack-dev-middleware (webpack/webpack-dev-middleware#2412).

🤖 Generated with Claude Code

https://claude.ai/code/session_016aGHrb1YaEvaGwNELGEHjF


Generated by Claude Code

Summary by CodeRabbit

  • Chores
    • Improved workflow run management for pull requests by automatically canceling superseded runs.
    • Preserved concurrent push and other workflow runs so queued checks and coverage comparisons are not canceled.

`test.yml` has no concurrency control, so pushing a new commit to a pull
request leaves the previous commit's jobs running to completion even though
nobody will read their results.

Add a workflow-level group. Only pull request runs share it; every other run
gets `github.run_id`, a group of one, because a group holds at most one
pending run and GitHub evicts that pending run whenever a newer one enters
the group — `cancel-in-progress` protects the running run, not the queued
one. Pushes to `main` therefore always complete: they publish the coverage
later comparisons are measured against, and losing one would also hide a
breakage already on the default branch.

`benchmarks.yml` already had a group, but with an unconditional
`cancel-in-progress: true`, so a push to `main` cancelled the in-flight
benchmark run for the previous `main` commit. CodSpeed compares a pull
request against the benchmark result of its base commit, so that leaves
later comparisons without a baseline. It now uses the same expression.

`release.yml` is untouched: its string-form group leaves `cancel-in-progress`
false, so releases queue rather than cancel.

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: e0a7b66

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

@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 99.25%. Comparing base (c554310) to head (e0a7b66).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #273   +/-   ##
=======================================
  Coverage   99.25%   99.25%           
=======================================
  Files          15       15           
  Lines         805      805           
  Branches      140      140           
=======================================
  Hits          799      799           
  Misses          6        6           
Flag Coverage Δ
integration 99.25% <ø> (ø)

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 not alter performance

✅ 92 untouched benchmarks


Comparing ci/cancel-outdated-runs (e0a7b66) with main (c554310)

Open in CodSpeed

@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: f7a000f9-5a79-470b-9d80-f2370b25dd17

📥 Commits

Reviewing files that changed from the base of the PR and between c554310 and e0a7b66.

📒 Files selected for processing (2)
  • .github/workflows/benchmarks.yml
  • .github/workflows/test.yml

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


Walkthrough

Both workflows now define concurrency settings. Pull-request runs share groups based on the workflow and pull-request ref, and newer runs cancel older runs. Other runs use a unique github.run_id group, and cancellation is disabled.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to e0a7b

The workflow changes match the intended pull-request cancellation and non-pull-request isolation behavior and are ready to merge.

🚥 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 and concisely describes the main change: cancelling superseded pull request runs in CI workflows.
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.

@alexander-akait
alexander-akait merged commit 5488a0e into main Sep 18, 2026
36 checks passed
@alexander-akait
alexander-akait deleted the ci/cancel-outdated-runs branch September 18, 2026 16:47
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