Skip to content

CI: Prevent concurrent merges from cancelling CircleCI trigger - #35320

Merged
Sidnioulz merged 2 commits into
nextfrom
sidnioulz/fix-trigger-circleci-merge-cancellation
Jun 30, 2026
Merged

Sidnioulz merged 2 commits into
nextfrom
sidnioulz/fix-trigger-circleci-merge-cancellation

Conversation

@Sidnioulz

@Sidnioulz Sidnioulz commented Jun 29, 2026 •

Copy link
Copy Markdown
Contributor

What I did

The Trigger CircleCI workflow sets its concurrency group to ${{ github.workflow }}-${{ github.ref }} with cancel-in-progress: true.

  • For pull_request_target events, github.ref is per-PR (refs/pull/<n>/merge), so this correctly cancels only redundant re-triggers on the same PR. Two different open PRs never collide.
  • For push events (merges to next/main), github.ref is the shared refs/heads/<branch>. So two merges landing close together share one concurrency group, and the earlier merge's trigger job is cancelled before it POSTs to CircleCI — silently skipping that commit's merged workflow.

This PR keys the group on github.sha for push events, while preserving per-PR grouping (and redundant-retrigger cancellation) for PR events:

group: ${{ github.workflow }}-${{ github.event_name == 'push' && github.sha || github.ref }}

Evidence

I queried GitHub Actions history for cancelled runs of this workflow (sampled the 500 most recent; 5,228 cancelled all-time):

Impact

Each cancelled push-trigger meant a merged commit on next never fired its CircleCI merged (post-merge validation) workflow. Low frequency (~1.2% of cancellations) but a silent gap in CI coverage. PR-event behavior is unchanged.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved workflow run grouping to reduce unintended cancellations during closely timed merges on shared branches.
    • Separate grouping is now used for pull requests and branch pushes, helping keep CI runs more reliable.

Manual testing

  • Merge two PRs at the same time on next
  • Notice ci:merged trigger can get cancelled
  • Merge this PR, and re-merge two PRs
  • Notice we now get a ci:merged per commit

…cleCI trigger

The Trigger CircleCI workflow's concurrency group was keyed on github.ref.
For PR events that ref is per-PR (refs/pull/<n>/merge), but for push events
it is the shared refs/heads/<branch>. With cancel-in-progress, two merges to
next landing close together share one group, so the earlier merge's trigger
job is cancelled before it POSTs to CircleCI and its `merged` workflow is
silently skipped. GH Actions history shows this happening on pushes to next.

Key the group on github.sha for push events while keeping per-PR grouping
(and redundant-retrigger cancellation) for pull_request_target events.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Sidnioulz Sidnioulz changed the title Fix(ci): prevent concurrent merges from cancelling each other's CircleCI trigger CI: Prevent concurrent merges from cancelling CircleCI trigger Jun 29, 2026
@Sidnioulz Sidnioulz added build Internal-facing build tooling & test updates ci:normal Run our default set of CI jobs (choose this for most PRs). qa:skip Pull Requests that do not need any QA. (e.g. documentation) labels Jun 29, 2026
@Sidnioulz Sidnioulz self-assigned this Jun 29, 2026
@Sidnioulz Sidnioulz moved this to In Progress in Core Team Projects Jun 29, 2026
@Sidnioulz
Sidnioulz requested a review from a team June 29, 2026 11:52
@coderabbitai

coderabbitai Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The concurrency.group in the CircleCI trigger workflow is changed from a single workflow-ref key for all events to a conditional: push events use workflow-sha (per-commit), while pull_request_target events retain workflow-ref (per-PR).

Changes

CircleCI Trigger Workflow Concurrency Fix

Layer / File(s) Summary
Conditional concurrency group key
.github/workflows/trigger-circle-ci-workflow.yml
concurrency.group now uses github.sha for push events and github.ref for pull_request_target events, preventing unintended run cancellations between simultaneous merges on shared branches.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes


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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/trigger-circle-ci-workflow.yml:
- Around line 47-53: The concurrency key in the GitHub Actions workflow
currently uses github.ref for all PR-style events, which causes
pull_request_target runs to collapse onto the base branch and cancel unrelated
PRs. Update the concurrency.group expression in trigger-circle-ci-workflow.yml
so the PR path uses github.event.pull_request.number (with github.workflow and
the existing push/sha branch logic preserved), keeping pull_request_target jobs
isolated per PR.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 943a1034-f8b7-4ea8-bfc7-96f95417ec2e

📥 Commits

Reviewing files that changed from the base of the PR and between d0ef37e and aa14123.

📒 Files selected for processing (1)
  • .github/workflows/trigger-circle-ci-workflow.yml

Comment thread .github/workflows/trigger-circle-ci-workflow.yml Outdated
Comment thread .github/workflows/trigger-circle-ci-workflow.yml Outdated
@storybook-app-bot

Copy link
Copy Markdown
Contributor

Package Benchmarks

Commit: d64659d, ran on 30 June 2026 at 11:43:35 UTC

The following packages have significant changes to their size or dependencies:

@storybook/builder-webpack5

Before After Difference
Dependency count 188 188 0
Self size 79 KB 79 KB 0 B
Dependency size 36.17 MB 35.23 MB 🎉 -942 KB 🎉
Bundle Size Analyzer Link Link

@storybook/angular

Before After Difference
Dependency count 185 185 0
Self size 160 KB 160 KB 🚨 +54 B 🚨
Dependency size 31.44 MB 30.50 MB 🎉 -942 KB 🎉
Bundle Size Analyzer Link Link

@storybook/ember

Before After Difference
Dependency count 187 187 0
Self size 15 KB 15 KB 0 B
Dependency size 31.52 MB 30.57 MB 🎉 -942 KB 🎉
Bundle Size Analyzer Link Link

@storybook/nextjs

Before After Difference
Dependency count 533 533 0
Self size 663 KB 663 KB 🚨 +13 B 🚨
Dependency size 62.88 MB 61.94 MB 🎉 -942 KB 🎉
Bundle Size Analyzer Link Link

@storybook/nextjs-vite

Before After Difference
Dependency count 93 93 0
Self size 1.39 MB 1.39 MB 🎉 -35 B 🎉
Dependency size 24.93 MB 23.98 MB 🎉 -942 KB 🎉
Bundle Size Analyzer Link Link

@storybook/react-native-web-vite

Before After Difference
Dependency count 122 122 0
Self size 30 KB 30 KB 0 B
Dependency size 26.00 MB 25.05 MB 🎉 -942 KB 🎉
Bundle Size Analyzer Link Link

@storybook/react-vite

Before After Difference
Dependency count 83 83 0
Self size 36 KB 36 KB 0 B
Dependency size 22.70 MB 21.76 MB 🎉 -942 KB 🎉
Bundle Size Analyzer Link Link

@storybook/react-webpack5

Before After Difference
Dependency count 274 274 0
Self size 23 KB 23 KB 0 B
Dependency size 48.66 MB 47.72 MB 🎉 -942 KB 🎉
Bundle Size Analyzer Link Link

@storybook/server-webpack5

Before After Difference
Dependency count 200 200 0
Self size 16 KB 16 KB 🎉 -12 B 🎉
Dependency size 37.43 MB 36.49 MB 🎉 -942 KB 🎉
Bundle Size Analyzer Link Link

@storybook/tanstack-react

Before After Difference
Dependency count 84 84 0
Self size 110 KB 110 KB 0 B
Dependency size 22.74 MB 21.79 MB 🎉 -942 KB 🎉
Bundle Size Analyzer Link Link

@storybook/cli

Before After Difference
Dependency count 204 204 0
Self size 821 KB 821 KB 🎉 -84 B 🎉
Dependency size 92.62 MB 91.66 MB 🎉 -952 KB 🎉
Bundle Size Analyzer Link Link

@storybook/codemod

Before After Difference
Dependency count 197 197 0
Self size 32 KB 32 KB 🎉 -72 B 🎉
Dependency size 91.10 MB 90.15 MB 🎉 -951 KB 🎉
Bundle Size Analyzer Link Link

@storybook/preset-react-webpack

Before After Difference
Dependency count 163 163 0
Self size 19 KB 19 KB 0 B
Dependency size 33.15 MB 32.20 MB 🎉 -942 KB 🎉
Bundle Size Analyzer Link Link

@storybook/react

Before After Difference
Dependency count 59 59 0
Self size 1.52 MB 1.52 MB 🚨 +6 B 🚨
Dependency size 13.38 MB 12.43 MB 🎉 -942 KB 🎉
Bundle Size Analyzer Link Link

@Sidnioulz
Sidnioulz requested a review from ndelangen June 30, 2026 11:58
@Sidnioulz
Sidnioulz merged commit 7ba9c11 into next Jun 30, 2026
152 checks passed
@Sidnioulz
Sidnioulz deleted the sidnioulz/fix-trigger-circleci-merge-cancellation branch June 30, 2026 14:43
@github-project-automation github-project-automation Bot moved this from In Progress to Done in Core Team Projects Jun 30, 2026
@github-actions github-actions Bot mentioned this pull request Jun 30, 2026
2 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build Internal-facing build tooling & test updates ci:normal Run our default set of CI jobs (choose this for most PRs). qa:skip Pull Requests that do not need any QA. (e.g. documentation)

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants