From 316b8ceeffa829d9d8c75552eadf09fda6ed4245 Mon Sep 17 00:00:00 2001 From: Phil Leggetter Date: Thu, 24 Sep 2026 22:38:40 +0100 Subject: [PATCH 1/2] docs(agents): unit tests before every push, judged by exit code A unit test failed first in CI on #455. It had failed locally too, but the output was piped through head and log lines from deliberately failing mock requests pushed the FAIL out of view. AGENTS.md now states the rule before every push: unit tests must pass, read from the exit code rather than filtered output; run the acceptance tags for what changed, not the full suite, which CI runs. It also records the test hazard behind that failure: cobra's LocalFlags() and InheritedFlags() mutate the shared rootCmd, so tests walk Flags() and PersistentFlags(). Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_012XtSQ2kfpcRXXqweskgXkH --- AGENTS.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/AGENTS.md b/AGENTS.md index 59285ac0..e3622a1c 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -256,6 +256,14 @@ go test -race ./... **Whenever you change Go code in this repo, run tests from the repository root** and treat the run as failed if compilation or any test fails. +**Before every push — required:** + +- **Unit tests must pass.** Run `go test ./...` (and `go vet ./...`). A unit test should never fail first in CI; if one does, it was not run, or its result was not read. +- **Judge the result by the exit code, never by filtered output.** `go test ./... > /tmp/t.log 2>&1; echo exit=$?`. Tests that mock failing API calls log `level=error` lines, and piping through `head` can push the `FAIL` line out of view — a failure on your screen that you never see. +- **Run the acceptance tests for what you changed**, by tag, per `test/acceptance/README.md` — not the full suite. The full suite runs in CI; running it locally on every change is not needed. + +Tests in `pkg/cmd` share the package-level `rootCmd`. Do not call cobra's `LocalFlags()` or `InheritedFlags()` from a test: both merge parents' persistent flags into the command as a side effect, and the next test in the package sees flags that are not really there. Walk `Flags()` and `PersistentFlags()` instead. + **Recommended command in Cursor (module cache + full permissions):** ```bash From 8c90351d9cca5cfc6bb9aa15ec3263f9adf5a4a2 Mon Sep 17 00:00:00 2001 From: Phil Leggetter Date: Thu, 24 Sep 2026 22:38:57 +0100 Subject: [PATCH 2/2] docs(agents): the before-push rule is for code changes, not docs-only ones Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_012XtSQ2kfpcRXXqweskgXkH --- AGENTS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AGENTS.md b/AGENTS.md index e3622a1c..c2543c0a 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -256,7 +256,7 @@ go test -race ./... **Whenever you change Go code in this repo, run tests from the repository root** and treat the run as failed if compilation or any test fails. -**Before every push — required:** +**Before pushing a code change — required** (a docs-only change needs none of this): - **Unit tests must pass.** Run `go test ./...` (and `go vet ./...`). A unit test should never fail first in CI; if one does, it was not run, or its result was not read. - **Judge the result by the exit code, never by filtered output.** `go test ./... > /tmp/t.log 2>&1; echo exit=$?`. Tests that mock failing API calls log `level=error` lines, and piping through `head` can push the `FAIL` line out of view — a failure on your screen that you never see.