#!/bin/sh # script/lint: run the linter. golangci-lint is never installed locally: it # runs via docker only, one way, everywhere — script/lint builds # Dockerfile.lint, which COPYs the repo into the pinned golangci-lint image # and lints as a build step. This works even when the docker daemon is remote # and bind mounts are impossible, and it removes the host linter's shared # cache, which has attributed other checkouts' findings to this one. # # --no-cache-filter=lint forces the lint stage to re-execute on every run; a # cached lint stage exits 0 in under a second having linted nothing. The deps # stage keeps its cache, so module downloads are not repeated. # --progress=plain keeps the linter's own output visible on success, so a # passing run shows the issue count rather than nothing. # --output=type=cacheonly leaves no image behind to clean up. set -eu ROOT="$(cd "$(dirname "$0")/.." && pwd -P)" main() { cd "$ROOT" docker build \ -f Dockerfile.lint \ --no-cache-filter=lint \ --progress=plain \ --output=type=cacheonly \ . } main "$@"