The script/ builds pass a new CACHEBUST build argument on every run in place of --no-cache, which also emptied Go's build cache mount. Every Dockerfile stage declares ARG CACHEBUST first, so every RUN step still reruns on an unchanged tree. The canonical Go Dockerfile mounts only Go's build cache, on the steps that compile, so compiled packages survive between check builds; both go test runs carry -count=1, so no test result is reused. golangci-lint's own cache and the module cache are not kept. A repository re-vendors the scripts and adds the ARG lines in one commit: a stage without the line is served from cache with no warning. Unverified: not yet tried on the shared CI runner. Model: opus-5-5
This commit was merged in pull request #129.
This commit is contained in:
1 parent
f9e23ccae3
commit
e3f79c49da
11 files changed
+184
-97
No files matched your search
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: New Repo Checklist
|
||||
last_modified: 2026-10-08
|
||||
last_modified: 2026-10-15
|
||||
---
|
||||
|
||||
Use this checklist when creating a new repository from scratch. Follow the steps
|
||||
@@ -108,6 +108,16 @@ 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
|
||||
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
|
||||
- Image pinned by sha256 hash with version/date comment
|
||||
@@ -145,13 +155,13 @@ are thin shims calling them. Model scripts:
|
||||
- [ ] `script/setup` / `make setup` — readies a fresh clone: runs `bootstrap`,
|
||||
then `install-precommit`, plus repo-specific init
|
||||
- [ ] `script/test` / `make test` —
|
||||
`docker build --no-cache --target test --output type=cacheonly .`, which
|
||||
writes no image; the phase runs real tests, not a no-op (90-second
|
||||
`docker build --build-arg CACHEBUST="$(date +%s)-$$" --target test --output type=cacheonly .`,
|
||||
which writes no image; the phase runs real tests, not a no-op (90-second
|
||||
timeout, 60-second hard cap on wall time)
|
||||
- [ ] `script/lint` / `make lint` —
|
||||
`docker build --no-cache --target lint --output type=cacheonly .`, which
|
||||
writes no image. No lint verdict may come from a host invocation of the
|
||||
linter.
|
||||
`docker build --build-arg CACHEBUST="$(date +%s)-$$" --target lint --output type=cacheonly .`,
|
||||
which writes no image. No lint verdict may come from a host invocation of
|
||||
the linter.
|
||||
- [ ] `script/fmt` / `make fmt` — formats code (writes; native, never in a
|
||||
container)
|
||||
- [ ] `script/fmt-check` / `make fmt-check` — checks formatting (read-only;
|
||||
@@ -161,16 +171,16 @@ are thin shims calling them. Model scripts:
|
||||
- [ ] `script/projectname` — outputs the project name (used by `script/docker`
|
||||
for the image tag)
|
||||
- [ ] `script/docker` / `make docker` — builds Docker image, tagged via
|
||||
`script/projectname` (byte-identical across repos); `--no-cache`, plus the
|
||||
version as a build arg
|
||||
`script/projectname` (byte-identical across repos); a new `CACHEBUST`
|
||||
value on every build, plus the version as a build arg
|
||||
- [ ] `script/cibuild` — cd to repo root, run `script/bootstrap`, run
|
||||
`script/check`, then
|
||||
`docker build --no-cache --build-arg VERSION="$version" -t "$tag" .` (what
|
||||
CI runs), with `$version` from `git describe --tags --always --dirty`
|
||||
(`unknown` if empty) and `$tag` from `script/projectname`, each assigned
|
||||
on its own line before the build. The bootstrap is required: CI checks out
|
||||
and runs this alone, and `script/fmt-check` runs the formatter on the
|
||||
host.
|
||||
`docker build --build-arg CACHEBUST="$(date +%s)-$$" --build-arg VERSION="$version" -t "$tag" .`
|
||||
(what CI runs), with `$version` from
|
||||
`git describe --tags --always --dirty` (`unknown` if empty) and `$tag`
|
||||
from `script/projectname`, each assigned on its own line before the build.
|
||||
The bootstrap is required: CI checks out and runs this alone, and
|
||||
`script/fmt-check` runs the formatter on the host.
|
||||
- [ ] `script/fmt` and `script/fmt-check` pick their `yarn` with the same test
|
||||
as `script/bootstrap`: the `yarn` on `PATH` when the node on `PATH` has
|
||||
the pinned major version, and otherwise yarn under the pinned node, with
|
||||
@@ -195,8 +205,8 @@ 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 layer, means nothing
|
||||
ran
|
||||
checks — a sub-second build, or `CACHED` on a gate's `RUN` step, means
|
||||
nothing ran
|
||||
- [ ] 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