#!/bin/sh # script/lint: run the linter. golangci-lint is never installed on a # host: this builds Dockerfile.lint, which copies the repo into the # digest-pinned golangci-lint image and lints as a build step, so a # successful build is a clean lint. A cold cache needs the network to # pull the image and for `go mod download`; once warm this runs offline # until go.mod or go.sum changes. # # Without a fresh CHECK_EPOCH docker serves the gate layers from cache # on an unchanged tree and this exits 0 having run no linter. The PID is # in the value because two lint runs land inside the same second easily. # # The image is never used, so --output=type=cacheonly writes none; # without it every run leaves an untagged image behind. set -eu ROOT="$(cd "$(dirname "$0")/.." && pwd -P)" main() { cd "$ROOT" docker build \ --build-arg CHECK_EPOCH="$(date +%s)-$$" \ --output=type=cacheonly \ -f Dockerfile.lint \ . } main "$@"