From e2797ef697758a5882abb7121f4d27c72bc116e3 Mon Sep 17 00:00:00 2001 From: Rue <343175018+thatsrue@users.noreply.github.com> Date: Fri, 6 Nov 2026 19:16:58 -0500 Subject: [PATCH] fix(ci): refuse the push when git status fails; reword the gate rules --- .githooks/pre-push | 4 +++- docs/repo-standards.md | 4 ++-- scripts/test-pre-push | 3 +++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.githooks/pre-push b/.githooks/pre-push index 2a067d8..001da10 100755 --- a/.githooks/pre-push +++ b/.githooks/pre-push @@ -17,7 +17,9 @@ while read -r _ sha _ _; do echo "pre-push: pushing $sha but HEAD is $head; check out the branch you push" >&2 exit 1 done -if [[ -n $(git status --porcelain) ]]; then +# Its own line, so set -e refuses the push when status itself fails. +status=$(git status --porcelain) +if [[ -n $status ]]; then echo "pre-push: uncommitted changes; commit or stash them so the check tests what is pushed" >&2 exit 1 fi diff --git a/docs/repo-standards.md b/docs/repo-standards.md index 2f661cc..10018ef 100644 --- a/docs/repo-standards.md +++ b/docs/repo-standards.md @@ -59,8 +59,8 @@ Use only GitHub's default labels and labels added by Dependabot. - Install with `npm ci`, never `npm install`. OpenClaw plugin repos use `npm ci --ignore-scripts`. - Keep scripts in lowercase `scripts/`. Don't add a second task runner. An existing Makefile or justfile calls `scripts/check`. - Every repo with `scripts/check` has a committed `.githooks/pre-push` that runs it, copied byte for byte from [splitleafhq/.github](https://github.com/splitleafhq/.github/blob/main/.githooks/pre-push). It refuses a push whose commit isn't `HEAD` (an annotated tag counts by the commit it names) and a push from a tree with uncommitted changes, so the check tests what is pushed. Turn it on once per clone with `git config core.hooksPath .githooks`, and never skip it. Change the hook here first, where `scripts/test-pre-push` tests it, then copy it out; never edit a copy. No hook frameworks: lefthook skips its pre-push jobs when `HEAD` has no diff from `@{push}` ([evilmartians/lefthook#1612](https://github.com/evilmartians/lefthook/issues/1612)). -- `scripts/check` has two routes at most: a push whose changed files are all Markdown may skip slow steps, and every other push runs everything. No other path routes; each one is a claim that some files can't break some tests, and nothing checks it. The portable part CI runs in an Xcode app (below) is CI's subset, not a route. -- A step whose tool or dependency is missing fails. It never warns and passes, and tests never skip for a missing dependency: install it, or the check fails. +- `scripts/check` has two routes at most: a push whose changed files are all Markdown may skip slow steps, and every other push runs everything. No other path routes; each one is a claim that some files can't break some tests, and nothing checks it. An empty, unknown or failed diff runs everything, and Markdown that a check reads (generated from, linted, or loaded at run time) is not doc-only. The portable part CI runs in an Xcode app (below) is CI's subset, not a route. +- Every test the full check needs runs: a missing tool or test prerequisite fails the check, never warns and passes, and a test never skips itself because a dependency is absent. Provision test dependencies (venvs, binaries, local fixtures), not live services. A suite that truly can't run on every push is named in `scripts/check` as a separate opt-in, not skipped silently. - `scripts/check` runs every test suite the repo has: every package's tests, and in an Xcode app every test target `xcodebuild -list` shows. The pull request that adds a suite adds it to `scripts/check`. - A pull request that changes `scripts/check` or the hook proves each changed step can fail: commit a change that breaks it, run `git push --dry-run origin HEAD:refs/heads/probe` (it runs the pre-push hook and pushes nothing), expect a nonzero exit naming that step, then drop the commit. An uncommitted change proves nothing: the hook refuses a dirty tree before the check runs. - Xcode apps: `scripts/check` is the full local check, macOS build and tests included. CI runs a named portable part of it on Linux, like `scripts/check --portable`. diff --git a/scripts/test-pre-push b/scripts/test-pre-push index 4a4ed01..9a1bdf8 100755 --- a/scripts/test-pre-push +++ b/scripts/test-pre-push @@ -57,6 +57,9 @@ case_ "annotated tag on HEAD~1" nonzero skipped "pre-push: pushing .* but HEAD i touch untracked case_ "untracked file" nonzero skipped "pre-push: uncommitted changes" push origin main:refs/heads/dirty rm untracked +cp .git/index "$tmp/index" && echo corrupt > .git/index +case_ "unreadable index" nonzero skipped "" push origin main:refs/heads/corrupt +cp "$tmp/index" .git/index case_ "failing check refuses the push" nonzero ran "" env STUB_RC=1 "${git[@]}" push origin main:refs/heads/red case_ "push --dry-run runs the hook" nonzero ran "" env STUB_RC=1 "${git[@]}" push --dry-run origin main:refs/heads/probe "${git[@]}" worktree add -q "$tmp/linked" -b linked