fmt: check goimports in fmt-check, run it at its pinned commit (#119)
check / check (push) Failing after 2m28s
check / check (push) Failing after 2m28s
script/fmt-check now runs goimports in list mode and fails naming any file it would change, and checks gofmt with -s, as script/fmt applies it. Both scripts run goimports with `go run` at the commit that script/bootstrap used to install, so a goimports on PATH is never used and bootstrap no longer installs it. The pin is written in both scripts; change them together. The first run on a machine, and every Dockerfile lint stage run, downloads and builds goimports. The Markdown half of the issue (prettier) is not done here: it needs node in the lint image or a separate build, a decision for the owner. Model: opus-5-5
This commit was merged in pull request #192.
This commit is contained in:
+12
-3
@@ -1,18 +1,27 @@
|
||||
#!/bin/sh
|
||||
# script/fmt-check: check formatting (read-only). Same scope as
|
||||
# script/fmt, but fails instead of writing.
|
||||
# script/fmt-check: check formatting (read-only). Same tools and scope
|
||||
# as script/fmt, but fails instead of writing.
|
||||
set -eu
|
||||
|
||||
ROOT="$(cd "$(dirname "$0")/.." && pwd -P)"
|
||||
|
||||
# goimports v0.42.0, 2026-08-07. Must match script/fmt.
|
||||
GOIMPORTS_REF="golang.org/x/tools/cmd/goimports@009367f5c17a8d4c45a961a3a509277190a9a6f0"
|
||||
|
||||
main() {
|
||||
cd "$ROOT"
|
||||
files="$(gofmt -l .)"
|
||||
files="$(gofmt -s -l .)"
|
||||
if [ -n "$files" ]; then
|
||||
echo "gofmt: files not formatted:" >&2
|
||||
echo "$files" >&2
|
||||
exit 1
|
||||
fi
|
||||
files="$(go run "$GOIMPORTS_REF" -l .)"
|
||||
if [ -n "$files" ]; then
|
||||
echo "goimports: files not formatted:" >&2
|
||||
echo "$files" >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
main "$@"
|
||||
|
||||
Reference in New Issue
Block a user