check / check (push) Successful in 1m47s
script/lint now only builds the new Dockerfile.lint, which copies the repo into the pinned golangci-lint image and runs the linter as a build step, so a successful build is a clean lint. It builds with --no-cache, because a cached build runs no linter, and removes the image it tagged when it exits. The main Dockerfile lint stage calls golangci-lint directly, since make lint now needs Docker. Nothing installs or runs golangci-lint on the host any more: bootstrap and the Makefile drop the install, and script/fmt drops golangci-lint run --fix. The gofmt check script/lint repeated stays in script/fmt-check. Model: opus-5-5
21 lines
729 B
Bash
Executable File
21 lines
729 B
Bash
Executable File
#!/bin/sh
|
|
# script/lint: run golangci-lint, in Docker only. Builds Dockerfile.lint,
|
|
# whose build runs the linter, so a successful build is a clean lint.
|
|
# --no-cache because a cached build runs no linter. The image is removed
|
|
# afterwards, whatever the outcome.
|
|
set -eu
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd -P)"
|
|
ROOT="$(cd "$SCRIPT_DIR/.." && pwd -P)"
|
|
|
|
main() {
|
|
cd "$ROOT"
|
|
# Tagged per run, so concurrent runs never remove each other's image.
|
|
image="$("$SCRIPT_DIR/projectname")-lint:$$"
|
|
# A failed build leaves no image, so there is nothing to remove then.
|
|
trap 'docker image rm "$image" >/dev/null 2>&1 || true' EXIT INT TERM
|
|
docker build --no-cache -f Dockerfile.lint -t "$image" .
|
|
}
|
|
|
|
main "$@"
|