Skip to content

Build packages before testing them, and report PR build on every PR - #1500

Merged
feruzm merged 1 commit into
developfrom
chore/require-pr-build-check
Aug 15, 2026
Merged

Build packages before testing them, and report PR build on every PR#1500
feruzm merged 1 commit into
developfrom
chore/require-pr-build-check

Conversation

@feruzm

@feruzm feruzm commented Aug 15, 2026

Copy link
Copy Markdown
Member

Groundwork for making build (24.x) a required check on develop. It is not required today, which is how #1493 merged with six consecutive red builds and 36 failing tests behind it: lint (24.x) and typecheck (24.x) are the only required contexts, neither runs tests, and both were green.

Two things have to change before that setting can be flipped safely.

Build packages before running them

apps/web resolves @ecency/sdk to the committed packages/sdk/dist, so running tests first tests a stale build whenever a PR changes SDK source.

That is precisely what reddened #1493. isAuthorMuted was added to src at 07:18 but only reached the committed dist at 08:34, when the label-triggered changeset commit rebuilt it. Every run in between failed with No "isAuthorMuted" export is defined on the "@ecency/sdk" mock, while the source and the mocks were both correct throughout. Re-running that suite on current develop gives 2742 passing.

A required check that fails for a reason its author cannot act on is what teaches everyone to merge past CI, so consumers now test what the PR actually builds. staging.yml and master.yml carried the same ordering and get the same move.

Report on every pull request

PR build opted in by branch prefix. Two holes: a branch named anything outside the list got no build at all, and once this check is required, such a PR could never satisfy it. Dependabot, Renovate, forks and hotfix/* would be blocked with no way to produce the check.

Keying on the pull request closes both. This is what lint.yml and typecheck.yml already do, and their comments cite this same trap.

Remaining manual step

Adding build (24.x) to the required contexts on develop is a repo setting and cannot ride along in a PR. Worth doing once this merges, so the check reports on every PR first.

This PR exercises its own change: the PR build run below is the new trigger and the new ordering.

Two changes, both prerequisites for making `build (24.x)` a required
check on develop. It is not required today, which is how #1493 merged
with six consecutive red builds behind it.

Build order. apps/web resolves `@ecency/sdk` to the COMMITTED
packages/sdk/dist, so running the tests first tests a stale build
whenever a PR changes SDK source. #1493 spent six runs red on 36 tests
whose source and mocks were both correct: `isAuthorMuted` existed in
src, but not yet in the committed dist, and only landed there when the
changeset commit rebuilt it. A required check that fails for a reason
its author cannot act on is exactly what teaches people to merge past
CI, so consumers now test what the PR actually builds. staging.yml and
master.yml had the same ordering, and get the same move.

Trigger. PR build opted in by branch prefix, which leaves a branch named
anything else with no build at all, and would leave such a PR unable
ever to satisfy the check once it is required: Dependabot, Renovate,
forks and hotfix/* would be blocked with no way to produce it. Keying on
the pull request closes both holes, and matches what lint.yml and
typecheck.yml already do for the same reason.

Making the check required is a repo setting and cannot ride along in a
PR. It should be flipped once this merges.
@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Aug 15, 2026

Copy link
Copy Markdown

Code Review by Qodo

Grey Divider

New Review Started

This review has been superseded by a new analysis

Grey Divider

Qodo Logo

@coderabbitai

coderabbitai Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@feruzm, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 17 minutes

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

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: af3d2840-ec56-40f5-a1d8-6724c58cca5e

📥 Commits

Reviewing files that changed from the base of the PR and between ade78a5 and 18ca40c.

📒 Files selected for processing (3)
  • .github/workflows/PR-branch.yml
  • .github/workflows/master.yml
  • .github/workflows/staging.yml

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

qodo-free-for-open-source-projects Bot commented Aug 15, 2026

Copy link
Copy Markdown

PR Summary by Qodo

Make PR build run on all PRs and build packages before tests

⚙️ Configuration changes 🐞 Bug fix 🕐 20-40 Minutes

Grey Divider

AI Description

• Trigger PR build on pull_request so every PR reports the check.
• Build packages before running tests to avoid stale SDK dist usage.
• Apply the same build-before-test ordering to staging and master workflows.
Diagram

graph TD
  A["GitHub event"] --> B["PR build workflow"] --> C["Build packages"] --> D["Run tests"] --> E["Build"]
  A --> F["Staging workflow"] --> C
  A --> G["Master workflow"] --> C
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Consume SDK from source/workspace instead of committed dist
  • ➕ Eliminates stale dist failures by making tests use the built workspace package
  • ➕ Reduces reliance on committed build artifacts
  • ➖ Potentially larger repo/package-policy change (build/publish pipeline implications)
  • ➖ May affect consumers expecting committed dist layout
2. Enforce pretest build via package.json scripts (pretest)
  • ➕ Keeps correct ordering for both local and CI runs
  • ➕ Centralizes the contract: tests always build prerequisites
  • ➖ May increase local test iteration time even when SDK unchanged
  • ➖ Still requires CI trigger fix to ensure required check is emitted
3. Keep push trigger but broaden branch filters (or remove filters)
  • ➕ Simpler mental model for some teams used to push-based workflows
  • ➖ Still fails to cover forks/bots reliably for required checks
  • ➖ More workflow noise on non-PR pushes

Recommendation: Proceed with this PR’s approach: switching PR build to pull_request is the most reliable way to guarantee the required check exists for every PR (including bots/forks), and moving build:packages before tests fixes a concrete monorepo artifact-staleness failure mode with minimal blast radius. The deeper alternative (changing SDK consumption away from committed dist) could be revisited later, but is disproportionately invasive for the immediate goal of making the build check safely required.

Files changed (3) +24 / -19

Other (3) +24 / -19
PR-branch.ymlTrigger PR build on pull_request and build packages before tests +16/-15

Trigger PR build on pull_request and build packages before tests

• Replaces branch-filtered push triggers with pull_request so the PR build check always runs for all PRs. Reorders steps to run pnpm build:packages before pnpm -r test to ensure tests execute against the current built artifacts (not a stale committed dist). Adds explanatory comments documenting the rationale and prior failure mode.

.github/workflows/PR-branch.yml

master.ymlReorder master workflow to build packages before tests +4/-2

Reorder master workflow to build packages before tests

• Moves the package build step ahead of the test step so consumers (e.g., apps/web) test against the freshly built package outputs. Adds a short comment explaining the monorepo dist-resolution issue being avoided.

.github/workflows/master.yml

staging.ymlReorder staging workflow to build packages before tests +4/-2

Reorder staging workflow to build packages before tests

• Matches master’s corrected ordering by building packages before executing the test suite. This prevents CI from running tests against stale committed dist outputs when package source changes in the same PR.

.github/workflows/staging.yml

@feruzm
feruzm merged commit 9d1d9cf into develop Aug 15, 2026
8 checks passed
@feruzm
feruzm deleted the chore/require-pr-build-check branch August 15, 2026 12:35

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}

P2 Badge Include the pull request identity in the concurrency key

On pull_request runs, github.head_ref contains only the source branch name, so PRs from different forks with a common name such as main or patch-1 share this concurrency group. If those builds overlap, cancel-in-progress: true cancels one PR's required build even though the commits are unrelated, leaving that PR blocked until it is rerun. Key the group by github.event.pull_request.number or include the head repository's full name.

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@qodo-code-review

Copy link
Copy Markdown

Code Review by Qodo

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

Grey Divider


Remediation recommended

1. Cross-PR build cancellations 🐞 Bug ☼ Reliability
Description
After switching PR build to run on pull_request, the workflow-level concurrency group now keys
primarily on github.head_ref (source branch name), so different PRs with the same branch name
(common with forks/bots) can cancel each other’s runs. This can intermittently prevent a PR’s latest
commit from ever getting a completed PR build status, making a required check unreliable.
Code

.github/workflows/PR-branch.yml[R8-9]

on:
-  push:
-    branches:
-      # Every prefix in real use, not just the two most common. This list is an
-      # opt-IN, so a branch named anything else silently gets no build at all --
-      # which is how a change to next.config.js (a build-time file that neither
-      # tsc nor eslint evaluates) reached review with nothing having compiled it.
-      # Add new prefixes here, or they inherit that same silent gap.
-      - 'bugfix/*'
-      - 'feature/*'
-      - 'fix/*'
-      - 'chore/*'
-      - 'refactor/*'
-      - 'docs/*'
-      # Bot-authored PRs were previously merged without ever being built.
-      - 'seer/*'
+  pull_request:
Relevance

●●● Strong

Team has accepted workflow concurrency hardening before; preventing CI cancellations is aligned with
reliability goals.

PR-#1192

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The workflow is now triggered by pull_request, and its concurrency group is computed from
github.head_ref || github.ref. GitHub documents github.head_ref as the PR’s source branch name;
since branch names are not globally unique across repositories/PRs, separate PRs can share the same
concurrency group and cancel each other’s runs.

.github/workflows/PR-branch.yml[8-14]
🌐 Defines github.head_ref as the head/source branch name of the pull request (available for pull_request/pull_request_target events).

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

## Issue description
`PR build` now triggers on `pull_request`, but its concurrency group uses `${{ github.head_ref || github.ref }}`. On PR events, `github.head_ref` is just the source branch name, which can collide across unrelated PRs (especially forks), causing runs to cancel each other.

## Issue Context
When `cancel-in-progress: true`, any workflow run in the same concurrency group cancels the in-flight run. If two PRs share the same `head_ref`, their runs can interfere.

## Fix Focus Areas
- .github/workflows/PR-branch.yml[12-14]

## Proposed change
Update the concurrency group to be PR-unique, e.g.:

```yaml
concurrency:
 group: ${{ github.workflow }}-pr-${{ github.event.pull_request.number }}
 cancel-in-progress: true
```

(If this workflow might later run on non-PR events, add a fallback using `github.ref`.)

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


Grey Divider

Context
✅ Compliance rules (platform): 82 rules
✅ Skills: 6 invoked
  add-feature
  add-query
  add-sdk-mutation
  add-test
  code-review
  debug
✅ Web pages:
  +2 more
Review mode: ⚖️ Balanced: This changes CI triggers and the ordering of build/test steps across three workflows; it has real behavioral and required-check implications, but not enough independent logic to justify extended review.

Grey Divider

Tip of the day
💡 Did you know, you can turn on the rule miner and Qodo learns your standards from review history

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Comment on lines 8 to +9
on:
push:
branches:
# Every prefix in real use, not just the two most common. This list is an
# opt-IN, so a branch named anything else silently gets no build at all --
# which is how a change to next.config.js (a build-time file that neither
# tsc nor eslint evaluates) reached review with nothing having compiled it.
# Add new prefixes here, or they inherit that same silent gap.
- 'bugfix/*'
- 'feature/*'
- 'fix/*'
- 'chore/*'
- 'refactor/*'
- 'docs/*'
# Bot-authored PRs were previously merged without ever being built.
- 'seer/*'
pull_request:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remediation recommended

1. Cross-pr build cancellations 🐞 Bug ☼ Reliability

After switching PR build to run on pull_request, the workflow-level concurrency group now keys
primarily on github.head_ref (source branch name), so different PRs with the same branch name
(common with forks/bots) can cancel each other’s runs. This can intermittently prevent a PR’s latest
commit from ever getting a completed PR build status, making a required check unreliable.
Agent Prompt
## Issue description
`PR build` now triggers on `pull_request`, but its concurrency group uses `${{ github.head_ref || github.ref }}`. On PR events, `github.head_ref` is just the source branch name, which can collide across unrelated PRs (especially forks), causing runs to cancel each other.

## Issue Context
When `cancel-in-progress: true`, any workflow run in the same concurrency group cancels the in-flight run. If two PRs share the same `head_ref`, their runs can interfere.

## Fix Focus Areas
- .github/workflows/PR-branch.yml[12-14]

## Proposed change
Update the concurrency group to be PR-unique, e.g.:

```yaml
concurrency:
  group: ${{ github.workflow }}-pr-${{ github.event.pull_request.number }}
  cancel-in-progress: true
```

(If this workflow might later run on non-PR events, add a fallback using `github.ref`.)

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

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