Add a 30-second timeout guard to script/test and script/lint #16
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
REPO_POLICIES.md: "make testmust complete in under 20 seconds. Add a30-second timeout in the Makefile."
EXISTING_REPO_CHECKLIST.mdrestates it as"
make testhas a 30-second timeout".Neither
script/testnorscript/linthas any timeout. Both are barehugo --minifyinvocations. The build currently takes about 16 ms, so the 20-secondbudget is met with five orders of magnitude to spare — but there is no guard,
so a hang (a pathological template loop, a wedged filesystem, a future remote
Hugo module fetch) blocks the gate and CI indefinitely instead of failing.
Fix
Wrap the build in
timeout 30in both scripts. Thetimeoutbinary is incoreutils and is present in the alpine build image; confirm it is available in
script/bootstrap's install set on all four supported package managers, orguard its use if it is not universally present.
Keep the guard in the scripts rather than the
Makefile. The policy text says"in the Makefile", but in this repo the Makefile targets are thin shims by
design and every implementation lives in
script/— putting logic in theMakefile would break the scripts-to-rule-them-all pattern the policy mandates
elsewhere. The scripts are also what the
Dockerfileand pre-commit hookactually invoke, so a Makefile-level guard would not cover those paths. Note
this reasoning in the PR body.
Definition of done
script/testandscript/lintboth bound their Hugo invocation to 30seconds.
bare
124exit code is not good enough.timeoutavailability is verified in the Docker build environment; ifscript/bootstrapneeds to install coreutils on any of the four supportedpackage managers, it does so.
make test,make lint, andmake checkall still pass and still completein well under 20 seconds.
script/cibuildsucceeds.TODO.mdupdated in the same commit.No sensible Hugo equivalent — explicitly not applicable
go test -timeout 30s -race -cover ./...— the canonical Makefilesnippet for this rule is Go-specific.
-timeoutis ago testflag,-raceneeds a compiled binary with race instrumentation, and-coverneedsGo source. Only the wall-clock bound transfers, via
timeout(1).<cmd> || { echo "--- Rerunning with -v ---"; <cmd> -v; exit 1; }) — do not implement this here. Itpresupposes a test runner with a quiet/verbose pair.
hugo --minifyhas nosuch pair; the nearest analogue is re-running with
--logLevel debug, whichwould double the build on every failure for marginal extra signal, and Hugo
already prints the failing template and line on error. Adding it would be
cargo-culting the Go pattern into a place it does not fit.
Ref:
REPO_POLICIES.md— "Docker builds must complete in under 5 minutes","
make testmust complete in under 20 seconds. Add a 30-second timeout".