Skip to content

ci: move branch naming check from Mergify to GitHub Actions - #1131

Merged
CatherineSue merged 1 commit into
mainfrom
ci/replace-mergify-branch-check
Apr 14, 2026
Merged

CatherineSue merged 1 commit into
mainfrom
ci/replace-mergify-branch-check

Conversation

@CatherineSue

@CatherineSue CatherineSue commented Apr 14, 2026 •

Copy link
Copy Markdown
Member

Description

Problem

Mergify's pull_request_rules creates a post_check status check on fork PRs even when the head-repo-full-name = lightseekorg/smg condition should exclude them. This produces noisy failing checks ("Rule: Enforce branch naming convention (internal) (post_check)") on external contributions.

Verified across 20 fork PRs — 3 had the spurious check (#1115, #1088, #1082), all with branch names that don't contain a /. The details_url on these checks points to the fork PR itself, confirming Mergify is directly evaluating the rule on forks (not SHA collision from another PR).

The head-repo-full-name condition correctly prevents the actions (close/comment) from firing on forks, but does not prevent the post_check from being created. This is Mergify's internal behavior and cannot be configured.

Additionally, the previously working merge_protections block (which used if guards to properly gate check creation) was removed by auto-generated PR #906 — Mergify's bot keeps opening PRs to "upgrade" the config and remove merge_protections, making it unsustainable to maintain.

Solution

  • Remove the branch naming pull_request_rules entry from Mergify (eliminates post_check noise entirely)
  • Add a branch-naming job to the existing pr-naming-check.yml GitHub Actions workflow
  • The GHA job uses if: github.event.pull_request.head.repo.full_name == 'lightseekorg/smg' — completely invisible to fork PRs (no skipped check, no noise)
  • On failure, the job posts a comment explaining the naming convention and auto-closes the PR (matching previous Mergify behavior)

Changes

  • .github/mergify.yml — removed Enforce branch naming convention (internal) rule and stale auto-generated comment
  • .github/workflows/pr-naming-check.yml — added branch-naming job with validation, comment, and auto-close

Test Plan

  1. Internal PR with good branch name (e.g. feat/something): branch-naming job should pass
  2. Internal PR with bad branch name (e.g. something): job should fail, post comment, and auto-close the PR
  3. Fork PR (any branch name): branch-naming job should not appear at all in checks — no "Skipped", no noise
  4. Verify existing pr-validation job (PR title + commit message checks) still works unchanged

To test, push a branch with a bad name from the internal repo:

git checkout -b test-bad-branch-name origin/main
git commit --allow-empty -s -m "test: verify branch naming auto-close"
git push -u origin test-bad-branch-name
# open PR, observe it gets commented on and closed
# then delete the branch
git push origin --delete test-bad-branch-name
Checklist
  • cargo +nightly fmt passes (no Rust changes)
  • cargo clippy --all-targets --all-features -- -D warnings passes (no Rust changes)
  • (Optional) Documentation updated
  • (Optional) Please join us on Slack #sig-smg to discuss, review, and merge PRs

Summary by CodeRabbit

  • Chores
    • Migrated branch naming convention enforcement from Mergify to GitHub Actions for improved validation workflow consistency.

Mergify's pull_request_rules creates a post_check on fork PRs with bad
branch names even when head-repo-full-name guards should exclude them.
This produces noisy failing checks on external contributions.

Replace with a GitHub Actions job that uses a proper `if` gate to skip
fork PRs entirely, and auto-closes internal PRs with bad branch names.

Signed-off-by: Chang Su <chang.s.su@oracle.com>
@github-actions github-actions Bot added the ci CI/CD configuration changes label Apr 14, 2026
@coderabbitai

coderabbitai Bot commented Apr 14, 2026 •

Copy link
Copy Markdown

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

Branch naming convention enforcement is migrated from Mergify to GitHub Actions. The Mergify rule that validated branch names and closed non-conforming PRs is removed, replaced by a new Actions workflow job that validates branch names, comments with remediation guidance, and auto-closes failing PRs.

Changes

Cohort / File(s) Summary
Mergify rule removal
.github/mergify.yml
Removed the "Enforce branch naming convention (internal)" pull request rule, including its branch-name regex validation and auto-close/comment actions.
GitHub Actions job addition
.github/workflows/pr-naming-check.yml
Added new branch-naming job that validates branch names against a lowercase/digits regex for internal PRs, comments with remediation commands, and auto-closes non-conforming PRs via GitHub CLI.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

ci

Suggested reviewers

  • slin1237
  • key4ng
  • XinyueZhang369

Poem

🐰 A branch must be named just so,
No more Mergify's oversight,
Actions now keep the flow,
With comments of gentle might,
Lowercase and digits bright! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and specifically describes the main change: moving the branch naming check from Mergify to GitHub Actions, which is the primary objective of this pull request.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ci/replace-mergify-branch-check

Comment @coderabbitai help to get the list of available commands and usage tips.

@claude claude 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.

Clean migration from Mergify to GitHub Actions. User-controlled inputs are properly env-var gated (no script injection), regex is unchanged, fork PRs are fully invisible, and comment+close behavior matches the previous Mergify rule.

@CatherineSue
CatherineSue merged commit 50cbf82 into main Apr 14, 2026
31 of 37 checks passed
@CatherineSue
CatherineSue deleted the ci/replace-mergify-branch-check branch April 14, 2026 18:13

@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

Here are some automated review suggestions for this pull request.

Reviewed commit: dbc43dcc78

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

name: Branch Naming Convention
runs-on: ubuntu-latest
# Only enforce on internal PRs, not forks
if: github.event.pull_request.head.repo.full_name == 'lightseekorg/smg' && github.head_ref != 'main'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Prevent fork PR check noise at workflow trigger level

Using a job-level if here does not make the check invisible on fork PRs: the workflow still runs on every pull_request, and branch-naming becomes a skipped check run rather than disappearing. GitHub documents that skipped jobs are reported as successful status checks, so this still adds check noise on forks and does not achieve the stated “no skipped check” behavior.

Useful? React with 👍 / 👎.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request removes the Mergify rule that enforced branch naming conventions for internal branches, including the associated auto-close and commenting actions. I have no feedback to provide as there were no review comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci CI/CD configuration changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant