Skip to content

Commit b71089b

Browse files
committed
Cache pre-pulled container images in CI workflows
Use skopeo to query remote digests and key the GHA cache on actual image content. On cache hit, podman load replaces network pulls. Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 01722d3 commit b71089b

2 files changed

Lines changed: 86 additions & 6 deletions

File tree

.github/workflows/integration-tests.yml

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@ concurrency:
1010
group: integration-${{ github.head_ref || github.ref }}
1111
cancel-in-progress: true
1212

13+
env:
14+
BINK_IMAGES: >-
15+
ghcr.io/alicefr/bink/cluster:latest
16+
ghcr.io/alicefr/bink/node:v1.35-fedora-44-disk
17+
ghcr.io/alicefr/bink/dns:latest
18+
EXTERNAL_IMAGES: >-
19+
docker.io/library/registry:2
20+
docker.io/library/haproxy:lts-alpine
21+
quay.io/libpod/busybox:latest
22+
1323
jobs:
1424
integration-tests:
1525
runs-on: ubuntu-latest
@@ -80,14 +90,42 @@ jobs:
8090
df -h /
8191
free -h
8292
93+
- name: Get image digests
94+
id: digests
95+
run: |
96+
ALL_DIGESTS=""
97+
for img in $BINK_IMAGES $EXTERNAL_IMAGES; do
98+
digest=$(skopeo inspect --no-creds "docker://${img}" --format '{{.Digest}}')
99+
echo "${img}: ${digest}"
100+
ALL_DIGESTS="${ALL_DIGESTS}${digest}"
101+
done
102+
echo "hash=$(echo -n "${ALL_DIGESTS}" | sha256sum | cut -d' ' -f1)" >> "$GITHUB_OUTPUT"
103+
104+
- name: Cache container images
105+
id: image-cache
106+
uses: actions/cache@v4
107+
with:
108+
path: /tmp/podman-image-cache
109+
key: podman-images-integration-${{ steps.digests.outputs.hash }}
110+
111+
- name: Load cached images
112+
if: steps.image-cache.outputs.cache-hit == 'true'
113+
run: |
114+
for f in /tmp/podman-image-cache/*.tar; do
115+
sudo podman load -i "$f"
116+
done
117+
sudo podman images --format "table {{.Repository}}:{{.Tag}}\t{{.Size}}"
118+
83119
- name: Pre-pull container images
120+
if: steps.image-cache.outputs.cache-hit != 'true'
84121
run: |
85-
sudo podman pull ghcr.io/alicefr/bink/cluster:latest
86-
sudo podman pull ghcr.io/alicefr/bink/node:v1.35-fedora-44-disk
87-
sudo podman pull ghcr.io/alicefr/bink/dns:latest
88-
sudo podman pull docker.io/library/registry:2
89-
sudo podman pull docker.io/library/haproxy:lts-alpine
90-
sudo podman pull quay.io/libpod/busybox:latest
122+
for img in $BINK_IMAGES $EXTERNAL_IMAGES; do
123+
sudo podman pull "$img"
124+
done
125+
mkdir -p /tmp/podman-image-cache
126+
sudo podman save -o /tmp/podman-image-cache/bink-images.tar $BINK_IMAGES
127+
sudo podman save -o /tmp/podman-image-cache/external-images.tar $EXTERNAL_IMAGES
128+
sudo chown -R $(id -u):$(id -g) /tmp/podman-image-cache
91129
92130
- name: Run integration tests
93131
run: sudo make test-integration TEST_PROCS=3

.github/workflows/test-container-image.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ concurrency:
1515
group: container-image-test-${{ github.head_ref || github.ref }}
1616
cancel-in-progress: true
1717

18+
env:
19+
BINK_RUNTIME_IMAGES: >-
20+
ghcr.io/alicefr/bink/cluster:latest
21+
ghcr.io/alicefr/bink/node:v1.35-fedora-44-disk
22+
ghcr.io/alicefr/bink/dns:latest
23+
1824
jobs:
1925
test-container-image:
2026
runs-on: ubuntu-latest
@@ -52,6 +58,42 @@ jobs:
5258
sudo systemctl start podman.socket
5359
sudo podman info --format '{{.Store.GraphRoot}}'
5460
61+
- name: Get runtime image digests
62+
id: digests
63+
run: |
64+
ALL_DIGESTS=""
65+
for img in $BINK_RUNTIME_IMAGES; do
66+
digest=$(skopeo inspect --no-creds "docker://${img}" --format '{{.Digest}}')
67+
echo "${img}: ${digest}"
68+
ALL_DIGESTS="${ALL_DIGESTS}${digest}"
69+
done
70+
echo "hash=$(echo -n "${ALL_DIGESTS}" | sha256sum | cut -d' ' -f1)" >> "$GITHUB_OUTPUT"
71+
72+
- name: Cache runtime images
73+
id: image-cache
74+
uses: actions/cache@v4
75+
with:
76+
path: /tmp/podman-image-cache
77+
key: podman-images-container-test-${{ steps.digests.outputs.hash }}
78+
79+
- name: Load cached images
80+
if: steps.image-cache.outputs.cache-hit == 'true'
81+
run: |
82+
for f in /tmp/podman-image-cache/*.tar; do
83+
sudo podman load -i "$f"
84+
done
85+
sudo podman images --format "table {{.Repository}}:{{.Tag}}\t{{.Size}}"
86+
87+
- name: Pre-pull runtime images
88+
if: steps.image-cache.outputs.cache-hit != 'true'
89+
run: |
90+
for img in $BINK_RUNTIME_IMAGES; do
91+
sudo podman pull "$img"
92+
done
93+
mkdir -p /tmp/podman-image-cache
94+
sudo podman save -o /tmp/podman-image-cache/runtime-images.tar $BINK_RUNTIME_IMAGES
95+
sudo chown -R $(id -u):$(id -g) /tmp/podman-image-cache
96+
5597
- name: Build bink image
5698
run: sudo make build-bink-image
5799

0 commit comments

Comments
 (0)