Keep modules, lint cache and system packages in check builds (closes #130)
check / check (push) Canceled after 0s
check / check (push) Canceled after 0s
On sneak's ruling in #130, check builds keep three more things besides Go's build cache. In each stage of the canonical Go Dockerfile, the system-package install and the module download come before ARG CACHEBUST, so Docker keeps those layers until the base image, the install line, go.mod or go.sum changes. Modules are kept as a layer, not a cache mount, because Go does not check a cache mount's files again. golangci-lint run also mounts golangci-lint's cache. Every step that lints, tests or compiles still comes after ARG CACHEBUST, both go test runs keep -count=1, and a step that also installs node packages stays below the line. The policy, checklists, Go style guide, README and script comments say the same. Model: opus-5-5
This commit was merged in pull request #131.
This commit is contained in:
1 parent
e3f79c49da
commit
065357920a
10 files changed
+168
-83
No files matched your search
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: New Repo Checklist
|
||||
last_modified: 2026-10-15
|
||||
last_modified: 2026-10-18
|
||||
---
|
||||
|
||||
Use this checklist when creating a new repository from scratch. Follow the steps
|
||||
@@ -108,15 +108,24 @@ Template files can be fetched from:
|
||||
stage carries a `COPY --from=` of a harmless file from each so the image
|
||||
cannot be built unless both passed. Keep the final stage last: a stage
|
||||
nothing depends on is built only when `--target` names it.
|
||||
- Every stage declares `ARG CACHEBUST` as its first line after `FROM`. The
|
||||
`script/` builds pass a new `CACHEBUST` value on every build, which reruns
|
||||
every `RUN` step and keeps Go's build cache; `--no-cache` would empty it.
|
||||
A stage without the `ARG` line is served from cache on an unchanged tree,
|
||||
so the scripts and every stage's `ARG CACHEBUST` line are added in the
|
||||
same commit.
|
||||
- Go: the steps that compile (`golangci-lint run`, `go test`, `go build`)
|
||||
mount Go's build cache (`--mount=type=cache,target=/root/.cache/go-build`)
|
||||
and nothing else, and both `go test` runs carry `-count=1`, as in the
|
||||
- In every stage `ARG CACHEBUST` comes right after the steps that install
|
||||
system packages and download Go's modules, or right after `FROM` in a
|
||||
stage with neither, and every step that lints, tests or compiles comes
|
||||
after it. A step that installs anything else as well, such as a
|
||||
`script/bootstrap` that also installs node packages, comes after it too.
|
||||
The `script/` builds pass a new `CACHEBUST` value on every build, which
|
||||
reruns every `RUN` step after that line and leaves the layers above it and
|
||||
the cache mounts in place; `--no-cache` would build those layers again and
|
||||
empty the mounts. A stage without the `ARG` line is served from cache on
|
||||
an unchanged tree, so the scripts and every stage's `ARG CACHEBUST` line
|
||||
are added in the same commit.
|
||||
- Go: each Go stage downloads the modules (`COPY go.mod go.sum ./`,
|
||||
`RUN go mod download`) above `ARG CACHEBUST`; the steps that compile
|
||||
(`golangci-lint run`, `go test`, `go build`) mount Go's build cache
|
||||
(`--mount=type=cache,target=/root/.cache/go-build`), `golangci-lint run`
|
||||
also mounts golangci-lint's
|
||||
(`--mount=type=cache,target=/root/.cache/golangci-lint`), and no step
|
||||
mounts anything else; both `go test` runs carry `-count=1`, as in the
|
||||
canonical Go `Dockerfile` in `REPO_POLICIES.md`
|
||||
- Server: the final stage builds and runs the application
|
||||
- Non-server: the final stage brings up the dev environment
|
||||
@@ -205,8 +214,10 @@ are thin shims calling them. Model scripts:
|
||||
- [ ] `script/cibuild` succeeds in a fresh clone on a host carrying what CI has
|
||||
(the runner image `docker.gitea.com/runner-images:ubuntu-latest`: docker,
|
||||
git and node 24, with no yarn on `PATH`), and demonstrably executed the
|
||||
checks — a sub-second build, or `CACHED` on a gate's `RUN` step, means
|
||||
nothing ran
|
||||
checks — a sub-second build, or `CACHED` on a step that lints or tests,
|
||||
one of the `RUN` steps below `ARG CACHEBUST`, means nothing ran. The steps
|
||||
that install system packages and download Go's modules above that line are
|
||||
expected to show `CACHED`.
|
||||
- [ ] Plant a lint violation and confirm both `make lint` and a plain
|
||||
`docker build .` fail on it; revert. A plain build that passes proves the
|
||||
final stage is missing its `COPY --from=` edge to the gate phases.
|
||||
|
||||
Reference in new issue
Block a user