Skip to content

ci: cancel superseded pull request runs - #5742

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

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

Conversation

@alexander-akait

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

Copy link
Copy Markdown
Member

nodejs.yml already cancelled superseded jobs, but through per-job concurrency groups that also cancel pushes to main, next and v4. This replaces them with one workflow-level group that only cancels pull request runs.

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

Why the branch pushes should not be superseded

That is the actual bug here. main, next and v4 are built on push, and those runs feed the coverage that later comparisons are measured against. A cancelled run also hides a breakage that is already on the branch, which is exactly when you want to know.

Note that cancel-in-progress: false alone is not enough: 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. Hence github.run_id for non-pull-request events: each gets a group of one, so it can be neither cancelled nor evicted. (Thanks to the review on the sibling PR for catching this; the first version of this PR had the flaw.)

Why one workflow-level group rather than fixing the per-job ones

Adding the condition to the existing blocks would have been a smaller diff, but the per-job arrangement has three other costs:

  • It cancels job by job. Each old job dies only as its replacement is queued; a workflow-level group cancels the whole superseded run at once.
  • upload-coverage has no group at all. Today a superseded run can still reach it and publish coverage for a commit nobody is looking at. The workflow-level group covers it.
  • Every matrix dimension has to be repeated in the group key, and a dimension added later and forgotten would make cells cancel each other — a quiet and confusing failure. ci: stop sharding the test matrix and drop Node 25 #5741 is a live example of the maintenance burden: it had to edit the group key purely because the matrix changed. Keying on the workflow and ref cannot drift.

Happy to switch to the minimal version (keep the per-job groups, just add the condition) if you would rather keep the existing shape.

Verification

actionlint 1.7.7 is clean on all three workflows, and I checked that this means something by typo'ing the expression to github.event_nam, which it catches at exactly that line. The file is also Prettier- and cspell-clean using this repo's own configs.

release.yml is untouched: it already uses concurrency: ${{ github.workflow }}-${{ github.ref }}, whose string form leaves cancel-in-progress false, so releases queue instead of cancelling. dependency-review.yml is untouched too — one short job, nothing to save.

Rebased onto #5741 (merge commit), which stopped sharding the test matrix and dropped Node 25. It edited the same per-job group this PR removes; the removal is kept, since the workflow-level group supersedes it. An earlier version of this description quoted a job count, which that PR made wrong within the hour — the count is now gone from both the description and the workflow comment.

The same change is going to enhanced-resolve (webpack/enhanced-resolve#673) and webpack-dev-middleware (webpack/webpack-dev-middleware#2412).

🤖 Generated with Claude Code

https://claude.ai/code/session_016aGHrb1YaEvaGwNELGEHjF

Summary by CodeRabbit

  • Chores
    • Updated automated workflow run coordination.
    • Pull request workflow runs now cancel earlier in-progress runs for the same branch, prioritizing the latest changes.
    • Push-triggered workflows continue running independently without automatic cancellation.
    • Workflow concurrency is managed across the complete workflow rather than separately for each test and lint configuration.
    • This provides more predictable validation results while reducing unnecessary duplicate work.

The two per-job concurrency groups already cancelled a superseded job when
its replacement was queued, but they cancelled pushes to `main`, `next` and
`v4` the same way. Those runs publish the coverage later comparisons are
measured against, and cancelling one also hides a breakage that is already
on the branch.

Replace them with a single workflow-level group that only cancels pull
request runs. Besides fixing that, it cancels the whole superseded run at
once rather than job by job as each replacement is queued — the test matrix
is 48 jobs — it covers `upload-coverage`, which had no group of its own and
could otherwise publish coverage for a commit already superseded, and a
matrix dimension added later cannot be forgotten in a group key.

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

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: 3a0b47a0-5186-491d-ad3e-3cb3259d17b0

📥 Commits

Reviewing files that changed from the base of the PR and between 2a57d72 and f7be6a5.

📒 Files selected for processing (1)
  • .github/workflows/nodejs.yml

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


Walkthrough

The workflow adds one workflow-level concurrency policy. For pull request events, it groups runs by workflow and ref and cancels in-progress runs. For other events, it assigns each run a unique group. The lint and test jobs no longer define separate concurrency policies.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to f7be6

The workflow now scopes cancellation to pull-request runs while preserving independent non-pull-request runs, with no actionable merge-blocking risk identified.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The pull request changes only .github/workflows/nodejs.yml. It adds workflow-level concurrency and removes per-job concurrency. These CI changes do not implement or support the IPv6 host requirement… Remove the workflow concurrency changes from this pull request, or link them to an appropriate CI issue and submit them separately.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Issue #673 requires webpack-dev-server --host "::" --hot --inline to work. The prior review established existing IPv6 host handling and tests in test/cli/host-option.test.js and `test/e2e/host.tes…
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…
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 workflow runs.
Full details: Out of Scope Changes check

Explanation

The pull request changes only .github/workflows/nodejs.yml. It adds workflow-level concurrency and removes per-job concurrency. These CI changes do not implement or support the IPv6 host requirement in issue #673.

  • Fix all pre-merge checks with AI
✨ 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.

`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 the workflow on the ref
therefore did not deliver what the comment promised: with one branch run
executing and a second waiting, a third push would have evicted the second.

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.

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

Copy link
Copy Markdown
Member Author

Pushed a correction in 2a57d72 before anyone spent time reviewing the first version — the review on the sibling PR (webpack/enhanced-resolve#673) caught a real flaw that this PR had too.

cancel-in-progress: false protects only the run that is already executing. The concurrency group still holds at most one pending run, and GitHub evicts that pending run whenever a newer one enters the group, whatever the flag says — "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."

So keying every run on the ref did not actually deliver what this PR claims. With one main run executing and a second waiting, a third push would have evicted the second — exactly the "two merges in quick succession" case the change exists to protect, and it would have looked correct while failing.

The group is now:

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

Pull requests still group by ref and supersede as described above; every other run gets a group of one and can be neither cancelled nor evicted. actionlint 1.7.7, Prettier and cspell are clean on the result using this repo's own configs.


Generated by Claude Code

#5741 stopped sharding the test matrix and dropped Node 25, which edited the
per-job concurrency group this branch removes in favour of a workflow-level
one. Kept the removal: the workflow-level group covers every job, including
`upload-coverage`, which never had one.

Also drops the job count from the comment. It said 48, #5741 made it 9 within
the hour, and a number like that goes stale every time the matrix is touched.
@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 90.29%. Comparing base (2317bf9) to head (f7be6a5).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5742      +/-   ##
==========================================
+ Coverage   89.38%   90.29%   +0.90%     
==========================================
  Files          13       13              
  Lines        6169     6241      +72     
==========================================
+ Hits         5514     5635     +121     
+ Misses        655      606      -49     

☔ 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.

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