Run lint and tests as phases of the Dockerfile (closes #5)
check / check (push) Successful in 2m45s
check / check (push) Successful in 2m45s
The Dockerfile gets a lint phase on the pinned golangci-lint v2.12.2 image and a test phase on the Debian Go image. The tests run as an unprivileged user, because root reads a file with mode 0000 and the permission test then fails. The build stage copies a file from each phase, so no build finishes unless both pass, and it no longer runs make check. script/lint and script/test each build their phase, uncached and tagged; script/cibuild bootstraps, runs script/check, then builds the image. script/bootstrap no longer installs golangci-lint. README.md and TODO.md describe the new setup. Model: opus-5-5
This commit was merged in pull request #18.
This commit is contained in:
+14
-3
@@ -1,12 +1,23 @@
|
||||
#!/bin/sh
|
||||
# script/lint: run the linter.
|
||||
# script/lint: run the linter. Linting is a phase of the Dockerfile and
|
||||
# this builds that phase alone; the linter is never installed or run on
|
||||
# a developer host, where a shared result cache and a host-global lock
|
||||
# make its answer untrustworthy.
|
||||
#
|
||||
# The phase is not the last stage in the file, so it is built only when
|
||||
# --target names it. --no-cache because a cached lint layer is a lint
|
||||
# that did not run. The tag makes each build replace the previous image
|
||||
# instead of leaving a dangling one behind.
|
||||
set -eu
|
||||
|
||||
ROOT="$(cd "$(dirname "$0")/.." && pwd -P)"
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd -P)"
|
||||
ROOT="$(cd "$SCRIPT_DIR/.." && pwd -P)"
|
||||
|
||||
main() {
|
||||
cd "$ROOT"
|
||||
golangci-lint run --config .golangci.yml ./...
|
||||
docker build --no-cache \
|
||||
--target lint \
|
||||
-t "$("$SCRIPT_DIR/projectname")-lint" .
|
||||
}
|
||||
|
||||
main "$@"
|
||||
|
||||
Reference in New Issue
Block a user