Skip to content

feat(pr-gate): never a draft, only the top of a stack, only what it changes - #32

Merged
igorlamos merged 1 commit into
mainfrom
claude/pr-gate
Nov 16, 2026
Merged

igorlamos merged 1 commit into
mainfrom
claude/pr-gate

Conversation

@beplus-agent-claude

Copy link
Copy Markdown
Contributor

What

The PR gate (pr-gate/, design in pr-gate/PR-GATE.md, PG-D1–D7) decides inside each run whether a pull request's checks run. A skipped check reports "skipped", with the reason in the run summary.

  • A draft runs nothing. Marking it ready (ready_for_review) starts the checks.
  • In a stack, only the top PR runs. Its tree holds every PR below it, and a stack merges in one go.
  • Only what the stack changes. Either Rush's rush list --impacted-by git:<fork point> (lockfile included, project by project) or gate-paths globs, read over the whole stack's diff from its root branch.
  • Files every build reads run everything: workflows, rush.json, Rush config, common/scripts.
  • It fails open. With no pull-requests: read, or when Rush can't answer, the checks run, with a warning.

Reusables: app-ci, library-ci, docs-pages, db-migrations-pr and infra-diff take pr-gate: true (and gate-paths where that makes sense).

  • Off by default, so moving v2 changes no caller.
  • Workflow-wide permissions moved onto the jobs: a called workflow cannot ask for more than its caller grants.

Also:

  • Cache: app-ci, library-ci and db-migrations-pr restore the Rush/pnpm cache on a PR and save it only off one. The new reusable rush-cache.yml saves the one cache they all read, from the default branch.
  • cli: BE_NPM_CHECK probes one @beplus package instead of every one, so the job only proves the token arrived; install fails loudly if a package is missing.

Why

Measured on bepluscloud/ai, Nov 5–16: about 47% of console-CI minutes ran on PRs lower in a stack, or on PRs that don't touch the console. The libraries had the opposite problem: branches: [dev] let a stack's bottom PR run and never its top. Across the Enterprise, Nov 1–16 came to $186 at list price.

Tests

test/pr-gate/run.sh: 20 cases against a fake gh and a temporary git repo, all passing; it runs in test-pr-gate.yml. scripts/verify-callers.mjs was updated so the gate job is not reported as a regression.

After merge

Tag v2.17.0 and move v2. Merge the callers only after that (bepluscloud/ai, 50 beplus/* libraries, MRKIT, Mountaineer); until then pr-gate is an unknown input to them.

… top, Rush impact

A composite action, pr-gate/, decides whether a pull request's checks run: never on
a draft; in a stack, only on the top PR (its tree holds every PR below it); and,
given Rush projects or paths, only when the stack changes them, by Rush's own
--impacted-by from where the stack left its root branch. It fails open. Every
reusable workflow takes it as `pr-gate: true`, off by default, so moving v2
changes no caller (pr-gate/PR-GATE.md, PG-D1 to PG-D7).

- app-ci: gate in `plan` (the project's impact, or gate-paths); `checks` skips.
- library-ci: a `gate` job; the environment and the package diff come from the
  stack's root, so a stack's top PR runs with dev's secrets.
- docs-pages: a `gate` job for pull requests; deploy and package spell out their
  status, since the skipped gate would otherwise stop every publish.
- db-migrations-pr: the database project's impact plus gate-paths.
- infra-diff: top-only with gate-paths, else every ready PR.
- No reusable workflow names pull-requests: read (asking for more than a caller
  grants fails it); workflow-wide permissions moved to the jobs.
- Caches are restored on a PR and saved only off one; rush-cache.yml saves the
  one every PR reads, from the default branch, under the checks' keys.
- cli: BE_NPM_CHECK probes ONE @beplus package (one request) instead of each
  dependency (71 in bepluscloud's console, about a minute of every run).
- test/pr-gate/run.sh + test-pr-gate.yml: 20 decisions against a fake gh.

Co-Authored-By: Igor Lamos <igor@be.plus>
@igorlamos
igorlamos merged commit 31981da into main Nov 16, 2026
9 checks passed
@igorlamos
igorlamos deleted the claude/pr-gate branch November 16, 2026 20:32
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