~bigbes/ci-cacher

8851cb58dd2ccc5d3dd2cea8856d114fd69e1fff — Eugene Blikh 11 days ago f26ddc0
test.yml: install via install.sh, collapse cache_gomod to one dir download

The module cache task was the last if/fi block in this manifest: download
a tarball, untar it, or else go mod download, tar it up, upload. With
v0.2.0's `dir download --exec` it is a single invocation that restores
the tree or builds it and seeds the cache — and the manifest that ships
with the tool now demonstrates the shape it is selling.

Key moves from gomod/<sha>.tar.gz (a tar.gz of ~/go containing pkg/mod)
to gomod/<sha>.tar.zst (cacher's own dir archive of ~/go/pkg/mod), so
the old objects are simply left behind rather than misread.

The bootstrap task loses its mkdir/curl/chmod trio to install.sh, which
additionally verifies the download against checksums.txt.
1 files changed, 19 insertions(+), 23 deletions(-)

M .builds/test.yml
M .builds/test.yml => .builds/test.yml +19 -23
@@ 6,13 6,16 @@
# Order: install_cacher → cacher_init → install_go → cache_gomod →
#        test → docker_start → cache_garage_image → test_e2e.
#
# Dogfoods the published cacher binary (from pages.sr.ht) to cache:
# Dogfoods the published cacher binary (from pages.sr.ht), installed by
# the published install.sh, to cache:
#   * The Go tarball, via `cacher download --url` fallback.
#   * ~/go/pkg/mod, keyed on sha256(go.sum) — biggest win, the docker
#     SDK transitives pulled in by testcontainers are heavy.
#   * The Garage docker image, via `cacher docker download --pull` —
#     single call that does cache HIT → docker load, or cache MISS →
#     docker pull + seed.
#   * ~/go/pkg/mod, keyed on sha256(go.sum), via `cacher dir download
#     --exec` — biggest win, the docker SDK transitives pulled in by
#     testcontainers are heavy.
#   * The Garage docker image, via `cacher docker download --pull`.
# Each of those is one invocation that does cache HIT → restore, or
# cache MISS → fetch/build + seed. No if/fi in this file on purpose:
# the manifest is the demo.
image: ubuntu/noble
packages:
  - curl


@@ 41,11 44,11 @@ submitter:
      - "refs/tags/*"
tasks:
  - install_cacher: |
      mkdir -p ~/.local/bin
      curl -sSL "https://${PAGES_DOMAIN}${PAGES_SUBPATH}/cacher-linux-amd64" \
        -o ~/.local/bin/cacher
      chmod +x ~/.local/bin/cacher
      cacher version
      # install.sh picks the asset for this platform, verifies it against
      # checksums.txt and prints `cacher version` on the way out. ~/.local/bin
      # is already on PATH via `environment:` above, so this task can go
      # straight on to using the binary.
      curl -sSL "https://${PAGES_DOMAIN}${PAGES_SUBPATH}/install.sh" | sh
  - cacher_init: |
      cacher init \
        --endpoint    https://s3.bigb.es \


@@ 66,18 69,11 @@ tasks:
      # Cache ~/go/pkg/mod keyed by sha256(go.sum). A go.sum change
      # invalidates automatically; otherwise both `go test` and the e2e
      # variant (testcontainers + docker SDK transitives) hit the cache
      # and skip proxy.golang.org entirely.
      GOSUM_HASH=$(sha256sum ci-cacher/go.sum | cut -c1-16)
      KEY="gomod/${GOSUM_HASH}.tar.gz"
      if cacher download "$KEY" /tmp/gomod.tar.gz; then
        mkdir -p ~/go
        tar -xzf /tmp/gomod.tar.gz -C ~/go
      else
        cd ci-cacher && go mod download && cd ..
        tar -czf /tmp/gomod.tar.gz -C ~/go pkg/mod
        cacher upload "$KEY" /tmp/gomod.tar.gz
      fi
      rm -f /tmp/gomod.tar.gz
      # and skip proxy.golang.org entirely. --exec runs only on a miss,
      # and the tree it leaves behind is what gets uploaded.
      cacher dir download "gomod/{hash}.tar.zst" ~/go/pkg/mod \
        --hash-from ci-cacher/go.sum \
        --exec 'cd ci-cacher && go mod download'
  - test: |
      cd ci-cacher
      go test ./...