Skip to content

ci: require PRs to main to come through no-mistakes - #95

Merged
kunchenguid merged 2 commits into
mainfrom
fm/treehouse-nomistakes-enforcement-r1
Aug 19, 2026
Merged

kunchenguid merged 2 commits into
mainfrom
fm/treehouse-nomistakes-enforcement-r1

Conversation

@kunchenguid

Copy link
Copy Markdown
Owner

Summary

Adds the PR must be raised via no-mistakes required check to treehouse, matching firstmate and SSHHIP, with a release-please exemption so release PRs are never blocked.

This is a bootstrapping change: the check cannot gate the PR that adds it, so this PR is raised directly rather than through the no-mistakes pipeline.

What changed

  • .github/workflows/no-mistakes-required.yml - job named exactly PR must be raised via no-mistakes, on pull_request to main. The gate script is checked out from the base SHA, so a PR cannot weaken the check that judges it.
  • .github/scripts/no-mistakes-gate.sh - the single executable decision surface. A PR passes when it carries the marker Updates from [git push no-mistakes](https://github.com/kunchenguid/no-mistakes) (confirmed against this repo's own pipeline PRs, e.g. feat(pool): add stable lease identities #68), or is opened by github-actions[bot]/dependabot[bot], or is structurally release-please's own PR: reserved head branch prefix (release-please--, plus the legacy release-please/) and same-repo (non-fork) head and the This PR was generated with [Release Please] body footer. Never author identity, so a future PAT switch stays covered and a human PR or fork spoofing the release body still fails.
  • no_mistakes_gate_test.go - behavioral test that parses the real workflow, resolves its env: ${{ github.event.pull_request.* }} expressions against synthesized GitHub payloads, and executes the actual step shell. Covers: release-please PR exempt (bot- and human-authored), legacy branch prefix exempt, both bots exempt, human PR with signature passes, human PR without signature fails, empty body fails, borrowed release branch name alone fails, fork copying the release body fails, release body on an ordinary branch fails.

Release PRs would otherwise be blocked

release-please opens treehouse's release PRs with GITHUB_TOKEN, and GitHub creates no workflow runs for those PRs. Verified empirically: the head commits of release PRs #78, #69, #56 and #38 carry zero check runs, both before and after the #77 path exclusions. A required check therefore could never report on a release PR, and every release would sit blocked on a status that can never arrive - owner-override only.

So release.yml gains a release-pr-gate-status job that publishes the required context on the open release PR's head SHA. It runs the same gate script with PR_AUTHOR deliberately overridden, which defeats the bot exemption, so a status is stamped only when the structural release-please conditions hold. Verified locally against the real payloads of #78 (stamped) and #94 (skipped, fork).

Also: the gate workflow deliberately has no path filter, because a path-filtered required check never reports and blocks the PR forever. TestPullRequestWorkflowsExcludeReleasePleaseOutputs now encodes both rules - required-check workflows must not filter by path, every other pull_request workflow must still exclude the release-please output set - and fails if a second workflow ever claims the required-check name.

Sequencing

The workflow lands on main first; the required-status-check ruleset (PR must be raised via no-mistakes, Admin bypass) is added right after, so no PR is ever left waiting on a check that cannot run.

Testing

Adds the "PR must be raised via no-mistakes" check that firstmate and
SSHHIP already enforce, so hand-raised PRs to main cannot skip the
review/test/lint pipeline.

All exemption logic lives in .github/scripts/no-mistakes-gate.sh, a
single executable surface the workflow runs and the tests drive:

- github-actions[bot] and dependabot[bot] pass.
- release-please release PRs pass structurally - reserved head branch
  prefix (release-please-- or the legacy release-please/), same-repo
  (non-fork) head, and the Release Please body footer - never on author
  identity, so the exemption survives a future switch to a PAT and a
  fork copying the release body still fails.

release-please opens treehouse's release PRs with GITHUB_TOKEN, and
GitHub creates no workflow runs for those PRs (verified: release PR head
commits carry zero check runs). The required check could therefore never
report on a release PR. release.yml now publishes that status itself,
running the same gate script with the bot exemption deliberately
defeated, so only a structurally genuine release PR is stamped.

The gate workflow intentionally carries no path filter, since a filtered
required check never reports and blocks the PR forever; the release-CI
drift test now encodes that rule for required-check workflows and keeps
the exclusion rule for every other pull_request workflow.
The gate script is read from the base branch by design, so a PR based on
a main that predates it hits a bare 'No such file or directory'. Fail
closed with a message that names the fix instead.
@greptile-apps

greptile-apps Bot commented Aug 19, 2026

Copy link
Copy Markdown

Confidence Score: 3/5

This PR should not merge until the required gate uses evidence that a PR author cannot reproduce merely by editing the PR body.

The central enforcement path accepts a fixed public marker from contributor-controlled input, so a manually raised PR can satisfy the check without traversing the pipeline the check claims to require; mutable action references add a separate non-blocking trust-boundary weakness.

Files Needing Attention: .github/scripts/no-mistakes-gate.sh, .github/workflows/no-mistakes-required.yml, .github/workflows/release.yml

Security Review

The gate can be bypassed because it accepts a public substring in an author-editable PR body as pipeline-origin proof. The new security-sensitive workflows also use a mutable checkout action reference.

Reviews (1): Last reviewed commit: "ci: explain a missing gate script instea..." | Re-trigger Greptile

Comment thread .github/scripts/no-mistakes-gate.sh Resolved
Comment thread .github/workflows/release.yml Resolved
@kunchenguid

Copy link
Copy Markdown
Owner Author

Note for the merger: the PR must be raised via no-mistakes check on this PR fails by design. The gate script is read from the base branch (so a PR can never weaken the check judging it), and main does not carry .github/scripts/no-mistakes-gate.sh until this PR lands. The run reports exactly that:

The no-mistakes gate script is missing from the base branch. Rebase onto a main that contains ./.github/scripts/no-mistakes-gate.sh.

This is the bootstrapping case the delivery mode accounts for; the check is not required on main yet, so it does not block the merge. Every other check is green. The required-status-check ruleset is added immediately after this merges.

@kunchenguid
kunchenguid merged commit f2fe972 into main Aug 19, 2026
5 of 6 checks passed
@kunchenguid
kunchenguid deleted the fm/treehouse-nomistakes-enforcement-r1 branch August 19, 2026 17:18
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