Compare commits

..
1 Commits
Author SHA1 Message Date
sneak 41ad87b3b9 Keep Go's build cache between builds (closes #124)
check / check (push) Successful in 1m10s
The Dockerfile runs make test and make build with Go's build cache in a
BuildKit cache mount, so a build compiles only what changed since the
last one instead of the standard library and every dependency from
nothing. The mount has an id of its own, so builds of other repositories,
compiled against other C headers, do not share it. script/test passes
-count=1, so no test result is taken from the cache.

Model: opus-5-5
2026-10-06 15:23:41 +00:00
2 changed files with 11 additions and 16 deletions
+5 -10
View File
@@ -50,14 +50,10 @@ ARG CHECK_EPOCH
COPY . . COPY . .
# Go's build cache is kept between builds in this cache mount, which make test # This cache mount keeps Go's build cache between builds for make test and
# and make build both use, so each compiles only what changed since the last # make build; -count=1 in script/test keeps test results out of it. Go's cache
# build, not the standard library and every dependency from nothing. # does not notice C header changes, so the mount has its own id: change the id
# script/test passes -count=1, so test results are never taken from it. # when the C packages installed above change.
# The mount has its own id because the default id, its path, is shared with
# other repositories' builds, and Go's cache does not notice changes to C
# libraries: an entry compiled there against other C headers could be reused
# here. It does not notice a change of this image's own C headers either.
RUN --mount=type=cache,id=sneak/secret/go-build,target=/root/.cache/go-build \ RUN --mount=type=cache,id=sneak/secret/go-build,target=/root/.cache/go-build \
make test make test
@@ -65,8 +61,7 @@ RUN --mount=type=cache,id=sneak/secret/go-build,target=/root/.cache/go-build \
# is given, otherwise `git describe --tags --always` of the .git the build # is given, otherwise `git describe --tags --always` of the .git the build
# context carries: the tag on a tagged commit, tag-N-gHASH on a commit after # context carries: the tag on a tagged commit, tag-N-gHASH on a commit after
# one, the short commit when no tag is reachable. A context that carries .git # one, the short commit when no tag is reachable. A context that carries .git
# and still yields no version fails the build. make build uses the same Go # and still yields no version fails the build.
# build cache mount as make test.
ARG VERSION ARG VERSION
RUN --mount=type=cache,id=sneak/secret/go-build,target=/root/.cache/go-build \ RUN --mount=type=cache,id=sneak/secret/go-build,target=/root/.cache/go-build \
version="${VERSION:-$(git describe --tags --always)}"; \ version="${VERSION:-$(git describe --tags --always)}"; \
+6 -6
View File
@@ -22,12 +22,12 @@ https://git.eeqj.de/sneak/secret/milestone/12
library and every dependency from nothing on every build library and every dependency from nothing on every build
(https://git.eeqj.de/sneak/secret/issues/124). The `Dockerfile` runs it and (https://git.eeqj.de/sneak/secret/issues/124). The `Dockerfile` runs it and
`make build` with Go's build cache in a BuildKit cache mount, which docker `make build` with Go's build cache in a BuildKit cache mount, which docker
keeps between builds, locally and on the Gitea runner alike, so each compiles keeps between builds, so each compiles only what changed since the last build.
only what changed since the last build. The mount has an id of its own, so The mount has an id of its own, so other repositories' builds do not share it.
other repositories' builds do not share it. `script/test` passes `-count=1`, `script/test` passes `-count=1`, so every test runs on every build and no
so every test runs on every build and no result comes from Go's test cache. A result comes from Go's test cache. A build with an empty cache, such as the
build with an empty cache, such as the first after docker's build cache is first after docker's build cache is cleared, compiles everything in
cleared, compiles everything in `make test` as before. `make test` as before.
- 2026-10-06: The tests run quickly with the race detector on - 2026-10-06: The tests run quickly with the race detector on
(https://git.eeqj.de/sneak/secret/issues/120). Most of their time went to (https://git.eeqj.de/sneak/secret/issues/120). Most of their time went to
deriving keys from passphrases with scrypt, which is slow on purpose. The new deriving keys from passphrases with scrypt, which is slow on purpose. The new