Skip to content

Commit 3fa7a48

Browse files
committed
tests: Add worker image to cache-from
Signed-off-by: Brian Goff <[email protected]>
1 parent 2142386 commit 3fa7a48

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

.github/workflows/worker-images.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,15 @@ jobs:
118118
name: Setup (merged)
119119
run: |
120120
set -ex -o pipefail
121-
EXTRA_FLAGS="--set worker.cache-to=type=gha,scope=main.${{matrix.target}},mode=max --set worker.cache-from=type=gha,scope=${MAIN_CACHE_SCOPE}"
121+
ref="${{github.ref}}"
122+
branch="${ref#refs/heads/}"
123+
branch_scope="${branch//\//-}" # Replace slashes with dashes
124+
gha_scope="${branch_scope}.${{matrix.target}}"
125+
126+
EXTRA_FLAGS="--set worker.cache-to=type=gha,scope=${gha_scope},mode=max --set worker.cache-from=type=gha,scope=${MAIN_CACHE_SCOPE} --set worker.cache-from=type=gha,scope=${gha_scope}"
127+
EXTRA_FALGS+=" --set worker.tags=ghcr.io/${IMAGE_REPO}:${branch_scope} --set cache-to=type=inline --cache-from=type=registry,ref=${IMAGE_REPO}:${branch_scope} --push"
122128
echo "EXTRA_FLAGS=${EXTRA_FLAGS}" >> $GITHUB_ENV
129+
123130
- name: Setup QEMU
124131
run: docker run --rm --privileged tonistiigi/binfmt:latest --install all
125132
- name: Expose GitHub tokens for caching

test/testenv/build.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,18 @@ var ciLoadCacheOptions = sync.OnceValues(func() (out []client.CacheOptionsEntry,
286286
"url": url,
287287
},
288288
})
289+
out = append(out, client.CacheOptionsEntry{
290+
Type: "registry",
291+
Attrs: map[string]string{
292+
"ref": "ghcr.io/azure/dalec/" + target + "/worker:latest",
293+
},
294+
})
295+
out = append(out, client.CacheOptionsEntry{
296+
Type: "registry",
297+
Attrs: map[string]string{
298+
"ref": "ghcr.io/azure/dalec/" + target + "/worker:main",
299+
},
300+
})
289301
}
290302

291303
if len(out) == 0 {

0 commit comments

Comments
 (0)