Skip to content

ci(pr-flow): add PR base guard — block stacked PRs#451

Open
0xmariowu wants to merge 1 commit intomainfrom
chore/pr-base-guard
Open

ci(pr-flow): add PR base guard — block stacked PRs#451
0xmariowu wants to merge 1 commit intomainfrom
chore/pr-base-guard

Conversation

@0xmariowu
Copy link
Copy Markdown
Owner

@0xmariowu 0xmariowu commented May 6, 2026

Why

Sister project lazie had stacked PRs (#108/#109/#110) desync under squash + auto-merge today. Adding the same guard repo-wide.

Topology-aware auto-merge wouldn't fix it: squash merge produces new SHAs that downstream PR base refs don't reflect, so the chain breaks even with correct ordering.

What

.github/workflows/assert-base-is-default-branch.yml — any PR whose base.ref != repository.default_branch fails. Branch from main, merge serially.

Test plan

  • This PR's base = main → check passes
  • After merge, intentional stacked PR is rejected

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores
    • Added automated validation to ensure pull requests use the repository's default branch as their base, strengthening development process controls.

Copilot AI review requested due to automatic review settings May 6, 2026 06:37
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 6, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8c6b030c-d04b-4121-9af9-5f27e47bec6e

📥 Commits

Reviewing files that changed from the base of the PR and between 97557ae and e20e73f.

📒 Files selected for processing (1)
  • .github/workflows/assert-base-is-default-branch.yml

📝 Walkthrough

Walkthrough

A new GitHub Actions workflow is introduced to validate that pull requests target the repository's default branch, rejecting PRs with incorrect base branch selection before proceeding.

Changes

PR Base Guard Workflow

Layer / File(s) Summary
Workflow Configuration
.github/workflows/assert-base-is-default-branch.yml
New workflow "PR base guard" triggers on PR events, runs a job that compares the PR's base branch to the repository's default branch, failing the workflow if they do not match.

Estimated Code Review Effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰✨ A new guardian hops into place,
Watching branches with graceful grace,
"Default only!" it firmly cries,
No stray PRs shall catch surprise!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically identifies the main change: adding a PR base guard workflow to block stacked PRs, matching the changeset.
Description check ✅ Passed The description covers key sections (Why, What, Test plan) with clear rationale and implementation details, though it omits some template sections like Scope checkbox and Security Impact.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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 and usage tips.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a GitHub Actions guard to prevent “stacked PR” workflows by enforcing that every pull request targets the repository’s default branch, avoiding downstream base desync under squash + auto-merge.

Changes:

  • Introduces a new pull_request workflow that fails when pull_request.base.ref is not repository.default_branch.
  • Emits a clear error annotation explaining the policy and how to resolve it (rebase/retarget onto the default branch).

Comment on lines +23 to +29
run: |
if [ "$BASE_REF" != "$DEFAULT_BRANCH" ]; then
echo "::error::PR #${PR_NUMBER} base is '${BASE_REF}', must be '${DEFAULT_BRANCH}'."
echo "Stacked PRs are not supported. Branch from '${DEFAULT_BRANCH}' and merge serially."
exit 1
fi
echo "OK: base '${BASE_REF}' matches default branch."
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.

2 participants