From 4c3e470117ab195e7523ae3918a4da1a5f957f59 Mon Sep 17 00:00:00 2001 From: Eugene Blikh Date: Tue, 26 May 2026 08:29:51 +0300 Subject: [PATCH] test.yml: use published cacher binary instead of building from source Walking back e1b71b2. Building cacher from source dropped the go-tarball caching (chicken-and-egg). Bootstrapping from the published v0.1.0 binary instead lets all three caches (go tarball, gomod, garage image) use cacher. Cost: cache_garage_image stays on the if/else cacher docker {exists,download,upload} pattern instead of the single `cacher docker download --pull` introduced on master, because v0.1.0 doesn't have --pull yet. Comment notes the switch as a follow-up after the next release. --- .builds/test.yml | 53 ++++++++++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/.builds/test.yml b/.builds/test.yml index 19ff2ce81c1d30ce1d94c8da5c9e7c27b35c040c..72971a819fa035e59548bd2be230b6cde32b9254 100644 --- a/.builds/test.yml +++ b/.builds/test.yml @@ -3,18 +3,17 @@ # install + module cache are shared and a unit-test failure # short-circuits before paying the ~150 MB Garage image pull. # -# Order: install_go → install_cacher (built from source) → cacher_init -# → cache_gomod → test → docker_start → cache_garage_image → -# test_e2e. +# Order: install_cacher → cacher_init → install_go → cache_gomod → +# test → docker_start → cache_garage_image → test_e2e. # -# Dogfoods cacher (built fresh from source — this manifest is the -# regression test for the binary it produces) to cache: +# Dogfoods the published cacher binary (from pages.sr.ht) to cache: +# * The Go tarball, via `cacher download --url` fallback. # * ~/go/pkg/mod, keyed on sha256(go.sum) — biggest win, the docker -# SDK transitives are heavy. -# * The Garage docker image, via `cacher docker download --pull` -# which on miss falls back to `docker pull` and seeds S3. -# Go tarball itself isn't cached: cacher has to be built first, which -# needs Go, so chicken-and-egg. ~50MB curl is acceptable. +# SDK transitives pulled in by testcontainers are heavy. +# * The Garage docker image, via `cacher docker {exists,download, +# upload}`. Switch to `cacher docker download --pull` after the +# next release; the single-command form lives on master but +# isn't in v0.1.0. image: ubuntu/noble packages: - curl @@ -28,6 +27,8 @@ sources: environment: GO_VERSION: "1.26.3" PATH: /home/build/.local/go/bin:/home/build/.local/bin:/usr/local/bin:/usr/bin:/bin + PAGES_DOMAIN: bigbes.pages.srht.bigb.es + PAGES_SUBPATH: /ci-cacher # Keep in sync with internal/testutil/garage/container.go const Image. GARAGE_IMAGE: "dxflrs/garage:v2.3.0" # No Ryuk reaper — the VM is torn down at job end, so the reaper @@ -40,19 +41,11 @@ submitter: - refs/heads/master - "refs/tags/*" tasks: - - install_go: | - GO_TARBALL="go${GO_VERSION}.linux-amd64.tar.gz" - mkdir -p ~/.local - curl -sSL "https://go.dev/dl/$GO_TARBALL" -o "/tmp/$GO_TARBALL" - tar -xz -C ~/.local -f "/tmp/$GO_TARBALL" - rm "/tmp/$GO_TARBALL" - go version - install_cacher: | - # Build from source so we exercise the binary this PR/branch - # actually produces — not the previously-published release. mkdir -p ~/.local/bin - cd ci-cacher - go build -o ~/.local/bin/cacher . + curl -sSL "https://${PAGES_DOMAIN}${PAGES_SUBPATH}/cacher-linux-amd64" \ + -o ~/.local/bin/cacher + chmod +x ~/.local/bin/cacher cacher version - cacher_init: | cacher init \ @@ -62,6 +55,14 @@ tasks: --prefix ci-cacher/deps \ --key-file ~/.s3-cache-key-id \ --secret-file ~/.s3-cache-key-secret + - install_go: | + GO_TARBALL="go${GO_VERSION}.linux-amd64.tar.gz" + mkdir -p ~/.local + cacher download "golang/${GO_TARBALL}" "/tmp/${GO_TARBALL}" \ + --url "https://go.dev/dl/${GO_TARBALL}" + tar -xz -C ~/.local -f "/tmp/${GO_TARBALL}" + rm "/tmp/${GO_TARBALL}" + go version - cache_gomod: | # Cache ~/go/pkg/mod keyed by sha256(go.sum). A go.sum change # invalidates automatically; otherwise both `go test` and the e2e @@ -89,8 +90,16 @@ tasks: - cache_garage_image: | # Key derived from the image ref so a version bump invalidates # the cache automatically: dxflrs/garage:v2.3.0 → dxflrs-garage-v2.3.0 + # stderr swallowed on `exists` because v0.1.0 still dumps the + # cobra Usage block on a miss (SilenceUsage lands in the next + # release). KEY="docker/$(echo "$GARAGE_IMAGE" | tr '/:' '-').tar.zst" - cacher docker download "$KEY" "$GARAGE_IMAGE" --pull + if cacher docker exists "$KEY" >/dev/null 2>&1; then + cacher docker download "$KEY" "$GARAGE_IMAGE" + else + docker pull "$GARAGE_IMAGE" + cacher docker upload "$KEY" "$GARAGE_IMAGE" + fi docker images "$GARAGE_IMAGE" - test_e2e: | cd ci-cacher