~bigbes/ci-cacher

ref: d041811523ea4e4dc5aeb636ab3c252c19a3b5b8 ci-cacher/.builds/test.yml -rw-r--r-- 3.2 KiB
d0418115 — Eugene Blikh cacher: add 'docker download --pull' and silence cobra usage on errors a day ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# Unit tests + smoke build first, then end-to-end tests against a real
# Garage container via testcontainers-go. Merged into one job so the Go
# install is shared and a unit-test failure short-circuits before paying
# the ~150 MB Garage image pull.
#
# Order: install_cacher → cacher_init → install_go → test → build →
#        docker_start → cache_garage_image → test_e2e.
#
# Dogfoods cacher to cache both the Go tarball (via --url fallback) and
# the Garage docker image tarball (via explicit upload on miss). First
# run seeds the cache from upstream; subsequent runs pull from
# s3.bigb.es and skip the upstream round-trip.
image: ubuntu/noble
packages:
  - curl
  - ca-certificates
  - docker.io
secrets:
  - 7dde4219-0783-4581-a67d-c94749de3600   # ~/.s3-cache-key-id
  - 0e5b3530-6f19-4f30-9b73-9339dd382e46   # ~/.s3-cache-key-secret
sources:
  - https://git.srht.bigb.es/~bigbes/ci-cacher
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
  # container only adds startup logs we don't need.
  TESTCONTAINERS_RYUK_DISABLED: "true"
submitter:
  git.sr.ht:
    enabled: true
    allow-refs:
      - refs/heads/master
      - "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
  - cacher_init: |
      cacher init \
        --endpoint    https://s3.bigb.es \
        --region      garage \
        --bucket      docker-cache \
        --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
  - test: |
      cd ci-cacher
      go test ./...
  - build: |
      cd ci-cacher
      go build -ldflags "-X go.bigb.es/cacher/internal/version.version=$(cat VERSION)" -o cacher .
      ./cacher version
  - docker_start: |
      sudo systemctl start docker
      sudo usermod -aG docker build
      sudo chmod 666 /var/run/docker.sock
      docker version
  - 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
      KEY="garage/$(echo "$GARAGE_IMAGE" | tr '/:' '-').tar"
      if cacher download "$KEY" /tmp/garage.tar; then
        docker load -i /tmp/garage.tar
      else
        docker pull "$GARAGE_IMAGE"
        docker save "$GARAGE_IMAGE" -o /tmp/garage.tar
        cacher upload "$KEY" /tmp/garage.tar
      fi
      rm -f /tmp/garage.tar
      docker images "$GARAGE_IMAGE"
  - test_e2e: |
      cd ci-cacher
      go test -tags=e2e -timeout=10m ./...