Skip to content

auto-changeset: version large PRs and run once per PR - #2061

Merged
feruzm merged 2 commits into
developfrom
fix/auto-changeset-pipefail
Nov 12, 2026
Merged

feruzm merged 2 commits into
developfrom
fix/auto-changeset-pipefail

Conversation

@feruzm

@feruzm feruzm commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Closes #2060

What was wrong

  • Large PRs skipped versioning. auto-changeset.sh runs under set -eo pipefail and tested the changed-file list with echo "$CHANGED_FILES" | grep -q. On a list larger than a pipe buffer, grep -q exits at the first match, echo dies of SIGPIPE, and pipefail turns the match into "no match". On SDK: vote-free bridge v2 post reads with per-node fallback #2059 (1190 changed files) a generic patch label logged No publishable packages changed and the job still went green.
  • Label runs raced. Two labeled events seconds apart started two runs. The older label's run pushed first, and the newer run's push was rejected (fetch first).

Fix

  • Every grep -q in the script now reads from a here-string, so an early exit cannot fail the test. A failing git diff now stops the script instead of reading as "no match".
  • The workflow gets a per-PR concurrency group with cancel-in-progress, so the newest labeled event wins. It sits at workflow level because a job only enters its group after its gate job finishes, which would let a slow gate on the older event cancel the newer run.
  • A superseded label run now shows as cancelled. That is expected.

Test plan

  • test-auto-changeset.sh gains a large-PR case: about 170 KB of changed paths with the package match near the top, and a generic patch label must write "@ecency/sdk": patch.
  • The new case fails on the previous script, with the same message seen on SDK: vote-free bridge v2 post reads with per-node fallback #2059, and passes on this one.
  • bash .github/scripts/test-auto-changeset.sh: exit 0.
  • The workflow YAML parses.

The label workflow runs the script from the base branch, so this takes effect once merged.

Summary by CodeRabbit

  • Chores
    • Improved automated release-note generation for large pull requests.
    • Prevented overlapping automation runs for the same pull request; newer runs cancel older ones.
    • Kept builds focused on packages selected by the release process.

The script tested changed files with echo | grep -q under pipefail. On a
file list over a pipe buffer grep quits at the first match, echo dies of
SIGPIPE and the match reads as no match, so #2059 skipped versioning. All
grep checks now read here-strings, with a large-PR case in the script test.

The workflow also gets a per-PR concurrency group, so a label swapped
seconds after another cancels the older run instead of racing it to the
branch. It sits at workflow level so the newest event wins even when an
older event's gate job finishes later.

Closes #2060
@qodo-code-review

Copy link
Copy Markdown

ⓘ Qodo reviews are paused because your trial has ended. Ask your workspace admin to add credits to resume reviews. Manage billing

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-12T14:55:37.797914Z cc7065b PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Fix large-PR changeset generation and serialize runs per PR

🐞 Bug fix 🧪 Tests ⚙️ Configuration changes 🕐 10-20 Minutes

Grey Divider

AI Description

• Prevent large changed-file lists from silently skipping package versioning under pipefail.
• Cancel superseded label-triggered runs so they cannot race to push the same PR branch.
• Add a large-PR regression test for generic patch labels.
Diagram

graph TD
  Event["Labeled PR"] --> Concurrency["Per-PR concurrency"] --> Gate{"Gate mode"} --> Same["Same-repo job"] --> Script["Changeset script"] --> Output["Version and rebuild"]
  Gate --> Fork["Fork-build job"] --> Script
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Retry rejected pushes
  • ➕ Could recover from a concurrent branch update without canceling a run.
  • ➖ An older run could still apply stale labels after a newer event.
  • ➖ Requires additional reconciliation and retry logic.

Recommendation: Keep workflow-level per-PR cancellation: it addresses both push races and stale label snapshots before either job runs. Push retries alone would not ensure the latest label event wins.

Files changed (3) +43 / -8

Bug fix (1) +11 / -7
auto-changeset.shMake package detection safe under pipefail +11/-7

Make package detection safe under pipefail

• Replaces grep pipelines with here-string checks for labels, changed packages, and rebuild selection, avoiding false negatives when grep exits early on a large list. Captures the post-version git diff before scanning it, so a failed diff stops the script.

.github/scripts/auto-changeset.sh

Tests (1) +22 / -1
test-auto-changeset.shCover generic patch versioning on a large PR +22/-1

Cover generic patch versioning on a large PR

• Adds a case with 3,000 documentation files and an SDK source change, then checks that a generic patch label creates an SDK patch changeset. This reproduces the large-list failure without changing the existing fork tests.

.github/scripts/test-auto-changeset.sh

Other (1) +10 / -0
auto-changeset.ymlCancel superseded changeset runs per PR +10/-0

Cancel superseded changeset runs per PR

• Adds workflow-level concurrency keyed by workflow and PR number, canceling an earlier labeled-event run when a newer one starts. Placing it before the gate prevents a slow older gate from canceling the newer run.

.github/workflows/auto-changeset.yml

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

Tip of the day
💡 Did you know, you can open the rule or relationship behind a finding in one click

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@greptile-apps

greptile-apps Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; the previous test coverage gap is fixed.

Summary

Fixes automatic versioning for large PRs and cancels older label runs for the same PR.

  • Package version checks still find matches in very large pull requests.
  • New label events replace older automation runs for the same pull request.

No new issues were found in the changes since the previous review.

Reviews (2) · Last reviewed commit: "auto-changeset test: check the large PR ..." · Reviewed by Greptile

@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 37 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4c72b8f9-7106-428f-8863-64c6c7eaff57
Commits

Reviewing files that changed from the base of the PR and between cc7065b and 2e3711a.

Files selected for processing: 1

  • .github/scripts/test-auto-changeset.sh

No actionable comments were generated in the recent review.

Walkthrough

The auto-changeset script now feeds grep checks with here-strings, and its test covers a large file list that includes an SDK change. The workflow also cancels an older auto-changeset run when a newer run starts for the same pull request.

Changes: Auto-changeset workflow

Layer / File(s) Summary
Grep checks and large-list test
.github/scripts/auto-changeset.sh, .github/scripts/test-auto-changeset.sh
Grep checks use here-strings. The test creates 3,000 documentation files and verifies that the generated changeset includes a patch entry for @ecency/sdk.
Per-pull-request run concurrency
.github/workflows/auto-changeset.yml
Runs for the same workflow and pull request number share a concurrency group. A newer run cancels an in-progress run.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: Minimal · previous review cc706

The change makes changeset generation reliable for large PRs and limits versioning to one run per PR. No merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "auto-changeset: version large PRs and run once per PR" names the two main changes in the PR. The script change makes large changed-file lists (over 64 KB) work with generic patch labels, an…
Linked Issues check Passed [#2060] Pipe-based grep checks are replaced. Every echo ... | grep -q or grep -qx in .github/scripts/auto-changeset.sh now reads from a here-string (<<<), including the label checks (lines 47,…
Out of Scope Changes check Passed All changes support #2060. The script edits convert pipe-based checks to here-strings and add a fail-fast capture of git diff --name-only. The workflow change adds the per-PR concurrency group the i…
Full details: Title check

Explanation

The title "auto-changeset: version large PRs and run once per PR" names the two main changes in the PR. The script change makes large changed-file lists (over 64 KB) work with generic patch labels, and the workflow change adds per-PR concurrency so only one run versions each PR. The title is short and specific. It does not mention the here-string grep fix, but that fix is part of the large-PR change, so the title is related to the main change.

Full details: Linked Issues check

Explanation

[#2060] Pipe-based grep checks are replaced. Every echo ... | grep -q or grep -qx in .github/scripts/auto-changeset.sh now reads from a here-string (&lt;&lt;&lt;), including the label checks (lines 47, 57, 59), the default-bump file check (line 64), the rebuild checks (lines 96, 98), and the build loop (line 124). The early-exit SIGPIPE failure path is removed. VERSIONED_FILES=$(git diff --name-only) runs under set -e, so a failing git diff stops the script. The test script adds a large-PR case of about 3,000 files (well over 64 KB), with packages/sdk/src/index.ts changed and a generic patch label. It asserts "@ecency/sdk": patch in pr-103.md. The per-PR concurrency group (${{ github.workflow }}-${{ github.event.pull_request.number }}, cancel-in-progress: true) is set at workflow level in .github/workflows/auto-changeset.yml, which satisfies the second cause in the issue. Bump selection logic is unchanged, so the major:sdk/patch:sdk behavior is preserved. The no-package-files case has no new dedicated test. Its behavior is unchanged in the diff, and existing coverage was not inspected. The workflow on: block was not inspected, so pull_request.number availability for every trigger is not confirmed. These gaps do not change the result.

Full details: Out of Scope Changes check

Explanation

All changes support #2060. The script edits convert pipe-based checks to here-strings and add a fail-fast capture of git diff --name-only. The workflow change adds the per-PR concurrency group the issue requests. The test script adds the large-list regression case. The test message change from 'Fork changeset generation passed' to 'Changeset generation passed' is a minor wording change tied to the new case. No unrelated functional change was found in the reviewed diffs.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

A rabbit checks the labels at dawn,
Then feeds each grep without a pipe.
Three thousand pages fill the test,
An SDK patch appears just right.
A newer run takes the lead,
And I hop home beneath the moon.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: bad7bb82-0392-45af-abfc-672b05ff6240
Commits

Reviewing files that changed from the base of the PR and between 11cb8b1 and cc7065b.

Files selected for processing: 3

  • .github/scripts/auto-changeset.sh
  • .github/scripts/test-auto-changeset.sh
  • .github/workflows/auto-changeset.yml

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Comment thread .github/scripts/test-auto-changeset.sh Resolved
The mock changeset version can now move a package version, so the large-PR
case also asserts the versioned package is rebuilt.
@feruzm
feruzm merged commit 916adb0 into develop Nov 12, 2026
9 checks passed
@feruzm
feruzm deleted the fix/auto-changeset-pipefail branch November 12, 2026 15:24
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.

auto-changeset skips versioning on large PRs (grep -q SIGPIPE under pipefail)

1 participant