#!/bin/sh # script/lint: run the linter. golangci-lint is never installed on a # 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 # is a clean lint. The only prerequisite is a working docker; once the # pinned image is present nothing here reaches the network. # # CHECK_EPOCH is what makes the result mean anything. Without it docker # serves the gate layers from cache on an unchanged tree and this exits # 0 in well under a second having run no linter. The PID is in the value # as well as the epoch because two lint runs land inside the same second # easily, and `date +%s` alone would cache the second one. set -eu ROOT="$(cd "$(dirname "$0")/.." && pwd -P)" main() { cd "$ROOT" docker build \ --build-arg CHECK_EPOCH="$(date +%s)-$$" \ -f Dockerfile.lint \ . } main "$@"