Run all linting in Docker via Dockerfile.lint (closes #109)
All checks were successful
check / check (push) Successful in 3m9s
All checks were successful
check / check (push) Successful in 3m9s
golangci-lint no longer runs on the host. script/lint 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. The host binary shared one cache and one lock with every other checkout on the machine, which produced findings attributed to unrelated worktrees as well as unearned passes. Two properties the wrapper has to get right: - --no-cache-filter=lint forces the lint stage to re-execute. Without it an unchanged tree replays the layer and the build exits 0 in under a second having linted nothing. The deps stage stays cacheable. - Both lint steps use RUN --network=none. golangci-lint config verify is documented as fetching its JSON schema over HTTPS; the pinned image resolves it with no network, and --network=none enforces that rather than trusting it. Verify is kept because golangci-lint run silently ignores config keys it does not recognize. The main Dockerfile's lint stage now invokes golangci-lint directly instead of `make lint`, which would otherwise need a docker daemon inside the build. golangci-lint installation is removed from script/bootstrap.
This commit is contained in:
@@ -19,9 +19,14 @@ RUN go mod download
|
||||
# .dockerignore.
|
||||
COPY . .
|
||||
|
||||
# Run formatting check and linter
|
||||
# Run formatting check and linter. golangci-lint is invoked directly rather
|
||||
# than through `make lint`: this stage is already the pinned linter image, and
|
||||
# script/lint is a wrapper that builds Dockerfile.lint, so calling it here
|
||||
# would need a docker daemon inside the build. Keep these steps in step with
|
||||
# Dockerfile.lint, including --network=none (see its header for why).
|
||||
RUN make fmt-check
|
||||
RUN make lint
|
||||
RUN --network=none golangci-lint config verify --config .golangci.yml
|
||||
RUN --network=none golangci-lint run --config .golangci.yml ./...
|
||||
|
||||
# Build stage
|
||||
# golang:1.26.1-bookworm (Debian-based), 2026-03-17
|
||||
|
||||
Reference in New Issue
Block a user