feat: apply-branch-protection — codify protoLabs ruleset defaults#11
Merged
Conversation
Adds a new CLI/bin entry for any protoLabs repo to adopt the recommended branch protection ruleset with one command. Pairs two opinions that are both off-by-default in GitHub's UI: 1. required_status_checks is for correctness, not advisory signals. Drop LLM review bots (CodeRabbit, protoquinn[bot], etc.) from the required-checks list. Bots already have a legitimate veto path via reviewDecision — their silence shouldn't block merges. Closes #10. 2. strict_required_status_checks_policy: false for fast-moving repos. Strict mode forces an N×CI-cycle drag on stacked work. The actual safety net is the test suite. Closes #6. What lands: bin/apply-branch-protection.mjs CLI entry point (Node ESM, gh-cli backed) lib/branch-protection.mjs pure functions: filter, merge, apply, strip test/branch-protection.test.mjs 13 unit tests docs/branch-protection-defaults.md full rationale + flag reference README.md section + dev help update package.json bin entry + smoke command Pure-functions split: the lib does all decisions on JSON-in/JSON-out shapes, the bin does I/O (fetch ruleset via `gh api`, print diff, optionally PUT). Tests cover the lib in isolation; the bin is covered by --help smoke + a dry-run against protoLabsAI/protoMaker that returns "no change" (verified post-#3745 dismissal landed). Defaults are intentionally minimal — build/test/checks. Repo-specific rollups like ci-complete must be opted in via --required-checks, because silently requiring a context that a repo doesn't emit would BLOCK every PR there. 18/18 tests pass. Lint clean. Smoke clean. Closes #6 Closes #10
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #6 and #10. Adds a new CLI for adopting the protoLabs recommended branch protection ruleset across any repo in the org.
Two opinions, both off-by-default in GitHub's UI
1.
required_status_checksis for correctness, not advisory signals (#10)Drop LLM review bots (CodeRabbit, protoquinn[bot], etc.) from the required-checks list. Required checks should reflect build/test/lint — things that prove the code works. Bots already have a legitimate veto path via
reviewDecision— their silence shouldn't block merges.Live evidence from protoLabsAI/protoMaker#3745: PR shipped in <2 min, all CI passed, CodeRabbit hadn't posted a status yet, PR sat BLOCKED until a manual nudge. After dropping CodeRabbit from the required list, the same shape now merges cleanly.
2.
strict_required_status_checks_policy: falsefor fast-moving repos (#6)Strict mode forces a PR's branch to be up-to-date with
mainbefore merge. For solo-dev or small-team repos with linear PR stacks, that's an N×CI-cycle drag. The actual safety net is the test suite — stale branches that break main usually fail their own CI first.What lands
bin/apply-branch-protection.mjsgh api.lib/branch-protection.mjstest/branch-protection.test.mjsdocs/branch-protection-defaults.mdREADME.mdpackage.jsonapply-branch-protectionbin entry + smoke command.Architecture note
Pure-functions split: lib does all decisions on JSON-in/JSON-out shapes, bin does I/O (fetch via
gh api, print diff, optionally PUT). Tests cover the lib in isolation; bin is exercised via--helpsmoke and a dry-run against protoLabsAI/protoMaker that returns "no change" (verified post-#3745).Defaults are intentionally minimal
DEFAULT_REQUIRED_CHECKS = ['build', 'test', 'checks']. Repo-specific rollups likeci-completemust be opted in via--required-checks, because silently requiring a context that a repo doesn't emit would block every PR in that repo.Test plan
npm test— 18/18 pass (13 new + 5 existing code-review tests)npm run lint— cleannpm run smoke— all 4 bin entries respond to--helpprotoLabsAI/protoMakerreturns "no change" (correct, since #3745 already landed manually)Usage examples
Closes #6
Closes #10