#!/bin/sh # script/lint: run the linter. golangci-lint is never installed or run # on the host: it runs via docker only, one way, everywhere. This # builds Dockerfile.lint, which COPYs the repo into the digest-pinned # golangci-lint image and lints as a build step, so a successful build # means a clean lint. # # --no-cache-filter=lint forces the lint stage (source copy + linter # run) to execute on every invocation. Without it an unchanged tree # returns success in well under a second having linted nothing. The # deps stage (base image + go mod download) stays cached, and no global # cache invalidation is performed. --progress=plain keeps the linter's # own output visible. set -eu ROOT="$(cd "$(dirname "$0")/.." && pwd -P)" main() { cd "$ROOT" docker build \ --progress=plain \ --no-cache-filter=lint \ --target lint \ -f Dockerfile.lint \ . } main "$@"