Skip to content

ci: carry TS CI / Success only from pull_request and merge_group runs - #12635

Merged
zkochan merged 1 commit into
mainfrom
ci/pr-only-success-check
Jun 24, 2026
Merged

zkochan merged 1 commit into
mainfrom
ci/pr-only-success-check

Conversation

@zkochan

@zkochan zkochan commented Jun 24, 2026 •

Copy link
Copy Markdown
Member

Summary

A branch that lives in this repo fires both a push and a pull_request
TS CI run for the same commit, and both report the TS CI / Success
required check to that commit. Branch protection then sees two results for the
one required context, so a cancellation or flake on the push side — for
example two pushes racing on the test.yml concurrency group — blocks the PR
even when the pull_request run passed.

This makes a PR's TS CI / Success come solely from its pull_request run
(and from merge_group in the merge queue):

  • push now triggers only on main. PR/feature/Dependabot branches no
    longer start a second push run alongside their pull_request run, so there
    is only ever one TS CI / Success context per PR commit. main is still
    validated pre-merge by merge_group and re-checked post-merge by the
    push-on-main run. This also subsumes the old gh-readonly-queue/**
    ignore.
  • The build/test jobs now run on every pull_request (same-repo and
    fork), so the pull_request run does the real testing. Previously same-repo
    PRs were tested on the push event and the pull_request run skipped the
    heavy jobs; pointing the required check at pull_request without this would
    have produced a false green.

No double-running (each PR is one run; each main push is one run), no
branch-protection config change (the required context name TS CI / Success
is unchanged), and the chore/update-lockfile special case is handled
naturally now that pull_request always runs the heavy jobs.

Squash Commit Body

A branch that lives in this repo fires both a push and a pull_request TS CI
run for the same commit, and both report the TS CI / Success required check.
Branch protection then sees two results for that context, so a cancellation or
flake on the push side (e.g. two pushes racing on the test.yml concurrency
group) blocks the PR even when the pull_request run passed.

Restrict push CI to main so PR branches carry TS CI / Success only via their
pull_request run (and the merge queue via merge_group). Since pull_request now
covers every PR, run the build/test jobs on every pull_request (same-repo and
fork) instead of relying on the push run, and drop the same-repo/fork/
chore-lockfile gating that existed only to avoid duplicate push+pull_request
builds. main stays covered pre-merge by merge_group and post-merge by the push
run.

Checklist

  • Added or updated tests.

Written by an agent (Claude Code, claude-opus-4-8).

Summary by CodeRabbit

  • Chores
    • Simplified CI job conditions for TypeScript-related checks, making automated runs more consistent.
    • Updated workflow triggering so checks now run on the main branch and only when relevant TypeScript files change.
    • Removed several special-case branch and event rules to reduce unnecessary CI complexity.

A branch that lives in this repo fires both a push and a pull_request
TS CI run for the same commit, and both report the TS CI / Success
required check. Branch protection then sees two results for that
context, so a cancellation or flake on the push side (e.g. two pushes
racing on the test.yml concurrency group) blocks the PR even when the
pull_request run passed.

Restrict push CI to main so PR branches carry TS CI / Success only via
their pull_request run (and the merge queue via merge_group). Since
pull_request now covers every PR, run the build/test jobs on every
pull_request (same-repo and fork) instead of relying on the push run,
and drop the same-repo/fork/chore-lockfile gating that existed only to
avoid duplicate push+pull_request builds. main stays covered pre-merge
by merge_group and post-merge by the push run.
@coderabbitai

coderabbitai Bot commented Jun 24, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: b4e1ad8f-cab6-4400-a10e-4e709355793f

📥 Commits

Reviewing files that changed from the base of the PR and between e2dab00 and 793afd0.

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

📝 Walkthrough

Walkthrough

The CI workflow narrows the push trigger to only the main branch (removing the branches-ignore: gh-readonly-queue/** workaround) and replaces the event/PR-origin-aware if conditions on compile-and-lint and both build-pnpr-* jobs with a uniform !cancelled() && needs.changes.outputs.ts == 'true' check.

Changes

CI TypeScript Job Gating Simplification

Layer / File(s) Summary
Push trigger and job if-condition simplification
.github/workflows/ci.yml
push trigger is restricted to branches: [main], removing the branches-ignore: gh-readonly-queue/** entry. compile-and-lint and both build-pnpr-* (Linux and Windows) if conditions drop the prior github.event_name, github.event.pull_request.head.repo.full_name, github.head_ref, and chore/update-lockfile guards, retaining only !cancelled() and needs.changes.outputs.ts == 'true'.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • pnpm/pnpm#12633: Directly related — that PR added branches-ignore: gh-readonly-queue/** to avoid merge-queue push duplicates, which this PR supersedes by restricting push to main only.
  • pnpm/pnpm#12627: Directly related — extends the workflow for merge_group and adjusts changes.ts/job conditions so TS jobs run for merge queue entries, complementing this PR's push-trigger narrowing.
  • pnpm/pnpm#12453: Directly related — also simplifies compile-and-lint/build-pnpr-* conditions to use a single changes.outputs.ts gate at the workflow conditional level.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ci/pr-only-success-check

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.

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

Copy link
Copy Markdown

PR Summary by Qodo

ci: ensure TS CI / Success is reported only by pull_request and merge_group
🐞 Bug fix ⚙️ Configuration changes 🕐 10-20 Minutes

Grey Divider

Description

• Restrict TS CI push runs to main to avoid duplicate required-check contexts on PR commits.
• Run build/lint/test jobs on every pull_request so PR-required success reflects real testing.
• Simplify job gating by removing same-repo/fork/lockfile exceptions now that duplicates are gone.
Diagram

graph TD
  push_main(("push: main")) --> ci["TS CI workflow (ci.yml)"] --> jobs["Build/Lint/Test jobs"] --> success["TS CI / Success"]
  pr(("pull_request")) --> ci
  mg(("merge_group")) --> ci
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Split into two workflows (PR/merge_group vs push-main)
  • ➕ Clear separation of concerns and per-event concurrency configuration
  • ➕ Reduces risk of future edits reintroducing cross-event coupling
  • ➖ More files and duplicated job definitions unless heavily refactored into reusable workflows
  • ➖ Harder to keep the required-check naming and behavior consistent
2. Keep push on all branches but isolate concurrency keys per event
  • ➕ Retains push validation on feature branches without relying on pull_request
  • ➕ Avoids merge queue cancellations due to shared concurrency groups
  • ➖ Does not solve the core branch-protection problem of two results for one required context
  • ➖ Still burns CI capacity by double-running on same-repo PRs
3. Change required check strategy (different context per event)
  • ➕ Avoids ambiguity in branch protection by using distinct required contexts
  • ➖ Requires branch-protection changes and coordination
  • ➖ Does not meet the goal of keeping the existing required context name stable

Recommendation: The PR’s approach (push only on main; rely on pull_request + merge_group for PR commits) is the most robust way to guarantee a single authoritative TS CI / Success result per PR commit without branch-protection changes. Alternatives either increase maintenance (splitting workflows) or fail to address duplicate required-check contexts (concurrency-only tweaks).

Files changed (1) +17 / -16

Other (1) +17 / -16
ci.ymlScope push trigger to main and run heavy jobs on all PR events +17/-16

Scope push trigger to main and run heavy jobs on all PR events

• Limits the workflow's push trigger to the main branch to prevent duplicate 'TS CI / Success' contexts on PR commits. Simplifies the build/test job conditionals so they run for any pull_request (and merge_group), relying only on the TypeScript-relevant change detector.

.github/workflows/ci.yml

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

qodo-free-for-open-source-projects Bot commented Jun 24, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (2) 📘 Rule violations (0) 📜 Skill insights (0)

Grey Divider


Remediation recommended

1. PR branch detection broken 🐞 Bug ☼ Reliability
Description
TS CI now runs compile/build/test jobs on same-repo pull_request runs, but the reusable test
workflow’s “full suite” branch detection keys off github.ref_name, which does not equal the PR
head/base branch name on pull_request events. This can silently route special-case branches (e.g.
chore/update-lockfile, and potentially PRs targeting release/*) into the affected-only test path
instead of the intended full test suite.
Code

.github/workflows/ci.yml[R68-73]

  compile-and-lint:
    needs: changes
-    # Run only when TypeScript-relevant files changed. Also skip
-    # pull_request events from PRs in the same repo to prevent duplicate
-    # build jobs (the push event already covers them).
-    # Exception: chore/update-lockfile PRs (created by automation with GITHUB_TOKEN, which doesn't trigger push events)
-    if: ${{ !cancelled() && needs.changes.outputs.ts == 'true' && (github.event_name == 'push' || github.event_name == 'merge_group' || github.event.pull_request.head.repo.full_name != github.repository || github.head_ref == 'chore/update-lockfile') }}
+    # Run only when TypeScript-relevant files changed. Every PR (same-repo or
+    # fork) is covered by its pull_request run, and push only fires on main, so
+    # there are no duplicate build jobs to guard against here.
+    if: ${{ !cancelled() && needs.changes.outputs.ts == 'true' }}
Evidence
ci.yml now runs build/test jobs for TS changes without the previous event/repo gating, so
same-repo PRs execute test.yml under the pull_request event. In test.yml, the branch-based
full-suite logic uses github.ref_name, which is not the PR head/base branch name on
pull_request, so the chore/update-lockfile / release/* checks won’t match during PR runs.

.github/workflows/ci.yml[68-73]
.github/workflows/test.yml[118-148]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
After this PR, TS CI’s heavy jobs run on `pull_request` for same-repo PRs. However, `.github/workflows/test.yml` decides whether to run full-suite tests based on `github.ref_name`, which on `pull_request` runs is the PR ref (e.g. `123/merge`) rather than the head branch (`github.head_ref`) or base branch (`github.base_ref`). This makes branch-based full-suite routing ineffective on the workflow event that is now the primary CI signal.

### Issue Context
- TS CI heavy jobs now run whenever `needs.changes.outputs.ts == 'true'`, regardless of event/repo source guards.
- `test.yml` uses `REF_NAME: ${{ github.ref_name }}` and checks it against `main`, `chore/update-lockfile`, and `release/*`.

### Fix Focus Areas
- .github/workflows/test.yml[118-148]

### Suggested fix
Update `Determine test scope` to use PR-aware branch names, for example:
- Export `HEAD_REF=${{ github.head_ref }}` and `BASE_REF=${{ github.base_ref }}` alongside `REF_NAME`.
- Compute a branch selector like:
 - `branch=${HEAD_REF:-$REF_NAME}`
- Then apply full-suite rules using `branch` and/or `BASE_REF` (e.g., treat `BASE_REF` matching `release/*` as full-suite when running on PRs targeting release branches).

This preserves existing push/merge_group behavior while making the branch routing work on `pull_request` runs (which now carry the required check).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Release pushes skip TS CI 🐞 Bug ☼ Reliability
Description
Restricting push to only main means TS CI will not run on pushes to other long-lived branches
(notably release/**). If the repo relies on post-merge/push validation on release branches (e.g.
backports merged into release/*), those commits will no longer produce TS CI / Success from a
push run.
Code

.github/workflows/ci.yml[R13-15]

  push:
-    # The merge queue runs each entry on a temporary `gh-readonly-queue/**`
-    # branch, whose creation also fires a `push` event. That duplicate run
-    # shares `github.ref` (hence the test.yml concurrency group) with the
-    # `merge_group` run for the same commit, so with `cancel-in-progress`
-    # the two cancel each other's test jobs — failing `TS CI / Success` and
-    # ejecting the PR. Only the `merge_group` run reports to the queue, so
-    # skip `push` for those branches.
-    branches-ignore:
-      - 'gh-readonly-queue/**'
+    branches:
+      - main
Evidence
ci.yml now triggers on push only for main. Separately, the repo acknowledges release branches as
first-class (e.g. workflows are configured to run on release/**, and tooling references release
targets like release/11.1), so disabling TS CI on those pushes is a real coverage change that
should be explicitly accepted or corrected.

.github/workflows/ci.yml[3-17]
.github/workflows/zizmor.yml[3-12]
.github/workflows/create-release-pr.yml[4-10]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
TS CI’s `push` trigger is now limited to `main`, which removes push-time TS CI coverage for `release/**` branches.

### Issue Context
This may be intended, but the repo appears to have an active release-branch workflow (`release/…` targets are explicitly supported elsewhere). If release branches receive merges/pushes and you want them validated post-merge (like `main`), TS CI should also run on those branches.

### Fix Focus Areas
- .github/workflows/ci.yml[13-15]

### Suggested fix options
Pick one:
1) **Keep coverage on release branches:** expand the push trigger to include `release/**`:
  - `push.branches: [main, 'release/**']`
2) **Intentionally drop push coverage:** keep `push` on `main` only, but document that release branches rely solely on PR/merge queue validation (and consider removing/adjusting any now-dead branch-specific behavior in test scope logic if applicable).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Previous review results

Review updated until commit 793afd0

Results up to commit 793afd0


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

Great, no issues found!

Qodo reviewed your code and found no material issues that require review
Auto-approved notes - no code review findings
- 'auto_approve_for_no_suggestions' flag enabled

Qodo Logo

@github-actions github-actions Bot added reviewed: coderabbit CodeRabbit submitted an approving review reviewed: qodo labels Jun 24, 2026
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 793afd0

@zkochan
zkochan merged commit 689c42b into main Jun 24, 2026
29 checks passed
@zkochan
zkochan deleted the ci/pr-only-success-check branch June 24, 2026 17:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

reviewed: coderabbit CodeRabbit submitted an approving review reviewed: qodo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant