Split Dockerfile: pre-built golangci-lint stage for faster CI #45

Merged
sneak merged 1 commits from split-dockerfile-lint-stage into main 2026-03-15 18:56:25 +01:00
Collaborator

Closes #39

Splits the Dockerfile into a dedicated lint stage using the golangci/golangci-lint image directly, rather than copying the binary into the builder stage.

Changes

Dockerfile

  • Lint stage (AS lint): Uses the pre-built golangci/golangci-lint image (pinned by sha256) to run make fmt-check and make lint. This is a self-contained stage with its own go mod download and source copy.
  • Builder stage (AS builder): Runs only make test and the final binary build. No longer needs golangci-lint installed.
  • Stage dependency: COPY --from=lint /src/go.sum /dev/null forces BuildKit to always execute the lint stage (without this, unused stages are silently skipped).
  • Both stages touch mfer/mf.pb.go to prevent make from trying to regenerate via protoc.

With BuildKit, the lint and builder stages run in parallel after their shared go mod download layers complete, so lint/formatting failures surface much faster without blocking on test execution.

Makefile

  • Added lint to the check target prereqs: check: test lint fmt-check (was check: test fmt-check), matching the REPO_POLICIES requirement.
Closes #39 Splits the Dockerfile into a dedicated lint stage using the `golangci/golangci-lint` image directly, rather than copying the binary into the builder stage. ## Changes ### Dockerfile - **Lint stage** (`AS lint`): Uses the pre-built `golangci/golangci-lint` image (pinned by sha256) to run `make fmt-check` and `make lint`. This is a self-contained stage with its own `go mod download` and source copy. - **Builder stage** (`AS builder`): Runs only `make test` and the final binary build. No longer needs golangci-lint installed. - **Stage dependency**: `COPY --from=lint /src/go.sum /dev/null` forces BuildKit to always execute the lint stage (without this, unused stages are silently skipped). - Both stages touch `mfer/mf.pb.go` to prevent make from trying to regenerate via protoc. With BuildKit, the lint and builder stages run in parallel after their shared `go mod download` layers complete, so lint/formatting failures surface much faster without blocking on test execution. ### Makefile - Added `lint` to the `check` target prereqs: `check: test lint fmt-check` (was `check: test fmt-check`), matching the [REPO_POLICIES](https://git.eeqj.de/sneak/prompts/raw/branch/main/prompts/REPO_POLICIES.md) requirement.
clawbot added 1 commit 2026-03-15 18:54:34 +01:00
Use the golangci/golangci-lint image directly as a lint stage that runs
fmt-check and lint, rather than copying the binary into the builder stage.
BuildKit runs lint and test stages in parallel, so formatting and lint
failures surface much faster.

The COPY --from=lint dependency ensures BuildKit always executes the lint
stage (without it, unused stages are silently skipped).

Also add lint to the Makefile check target prereqs to match REPO_POLICIES
(check: test lint fmt-check).
clawbot added the needs-reviewbot labels 2026-03-15 18:55:59 +01:00
sneak merged commit 89903fa1cd into main 2026-03-15 18:56:25 +01:00
sneak deleted branch split-dockerfile-lint-stage 2026-03-15 18:56:25 +01:00
Sign in to join this conversation.