ci(pr-readiness): only assess PRs targeting the default branch - #16821
ci(pr-readiness): only assess PRs targeting the default branch#16821Joibel wants to merge 1 commit into
Conversation
The PR readiness helper fired on every PR that had CI complete on it, including backports to release-* branches, which follow their own process and should not be drafted or commented on. Resolve the PR as before, then skip it unless it is bound for the default branch. A stacked PR whose base is the head branch of another open PR in the same repository is followed up the chain of open PRs, so a stack that ends on the default branch is still assessed, while one that ends on a release branch, a closed PR, or a cycle is not. The open-PR list is already fetched, so this adds no API calls. The default branch is read from the workflow_run payload rather than hard-coded. Signed-off-by: Alan Clucas <alan@clucas.org>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughThe PR-readiness workflow now reads the repository default branch, resolves stacked PRs that lead to it, and skips PRs targeting release branches or unresolved stacks. Tests cover direct, stacked, forked-head, dead-end, and cyclic cases. ChangesDefault-branch PR eligibility
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to This change limits PR-readiness assessments to PRs targeting the default branch while preserving support for stacked PRs, with tests and type checks reported as passing. No actionable merge-blocking risk remains. Suggested reviewers: Sequence Diagram(s)sequenceDiagram
participant PullRequestEvent
participant ReadinessWorkflow
participant targetsDefaultBranch
PullRequestEvent->>ReadinessWorkflow: provide base branch and default branch
ReadinessWorkflow->>targetsDefaultBranch: resolve PR stack
targetsDefaultBranch-->>ReadinessWorkflow: return eligibility
ReadinessWorkflow-->>PullRequestEvent: continue or stop processing
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Description checkExplanation The description follows the repository template, explains the motivation and modifications, documents verification results, identifies the documentation update, and declares AI use. The feature-specific issue requirement does not apply to this change. Full details: Docstring CoverageExplanation Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 4 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
make pre-commit -B(n/a —.github/pr-readinessonly; rannpm run typecheckandnpm test)Motivation
The PR readiness helper currently assesses every PR that has CI complete on it, including backports to
release-*branches (e.g. #16813 / #16814). Backports follow their own process, and drafting or commenting on them is noise.Modifications
classify.ts: new pure functiontargetsDefaultBranch(pr, openPrs, defaultBranch). A PR is in scope when its base is the default branch, or its base is the head branch of another open PR in the same repository that (transitively) targets the default branch — so stacked PRs heading formainare still assessed. Dead ends (a release branch, or a base whose PR has been closed/merged) and cycles are out of scope.main.ts: after resolving the PR by head SHA, skip it unlesstargetsDefaultBranchholds. The default branch comes fromcontext.payload.repository.default_branchrather than being hard-coded. The open-PR list was already fetched for head-SHA resolution, so this adds no API calls.types.ts:StackablePr— the PR subset the walk needs.workflow_runtriggers can't filter on the PR's base branch (thebranches:filter applies to the run's head branch), which is why this lives in the script rather than the workflow'sif:.Verification
test/classify.test.ts: directmaintarget, release-branch target, three-deep stack, stack ending on a release branch / closed PR, a fork head sharing the base's branch name (must not be treated as part of the stack), and a cycle.npm run typecheckclean;npm test43/43 passing.pr-readiness-test.yamlruns the same in CI.Documentation
.github/pr-readiness/README.mdupdated.AI
Claude Code was used to draft the change, tests and this description; reviewed by me.
Summary by CodeRabbit
Bug Fixes
Tests