mirror of
https://github.com/cozystack/cozystack.git
synced 2026-12-02 21:30:46 +09:00
Release-line image builds read only main's build cache, which matches
release-1.6 less with every Dockerfile main changes: the rc Prepare
Release job went from 28 minutes on v1.6.4-rc.1 to 43 on v1.6.5-rc.1
and 45 on v1.6.6-rc.1.
The line now keeps a cache of its own. build-release.yaml writes
buildcache-release-1.6 on every push to the line, and rc builds import
it together with main's buildcache. CACHE_FROM_TAGS lists every cache a
build imports; unset, it is CACHE_TAG (buildcache), as before. This
line's cache-args took an optional per-call cache tag that no caller
passes, so it takes main's form instead. A cache write that fails no
longer fails the build (ignore-error=true).
The units of hack/build-matrix.sh build four at a time (make
build-parallel, hack/build-units.sh), each output line carrying its
unit. On this line packages/core/platform waits for the rest, because
it writes backupstrategy-controller's values.yaml.
Tested with bats: the cache macro, the unit builder against a fake make
and the workflow settings, plus a dry run of hack/build-units.sh over
this line's units with make -n.
Assisted-by: LLM
(cherry picked from commit 12eaa49521)
Signed-off-by: Myasnikov Daniil <myasnikovdaniil2001@gmail.com>
44 lines
2.5 KiB
Bash
44 lines
2.5 KiB
Bash
#!/usr/bin/env bats
|
|
# The cache settings of the release-line image builds. build-release.yaml runs
|
|
# only on a push to a line and tags.yaml only on a tag, so no PR lane would
|
|
# notice a change to them.
|
|
#
|
|
# Test-level EXIT traps replace Bats' own handler and hide failing TAP results.
|
|
# Cleanup follows aborting assertions; see docs/agents/e2e-testing.md.
|
|
|
|
load test_helper
|
|
|
|
@test "CACHE_FROM_TAGS imports every cache it lists and the build still writes only CACHE_TAG" {
|
|
pkg=packages/system/cozystack-controller
|
|
out=$(make -n -C "$pkg" image IMAGE_TAG=pr-1-abc COZYSTACK_VERSION=0 WRITE_CACHE=1 CACHE_TAG=buildcache-release-1.6 'CACHE_FROM_TAGS=buildcache-release-1.6 buildcache')
|
|
echo "$out" | grep -q -- '--cache-from type=registry,ref=[^ ]*/cozystack-controller:buildcache-release-1.6 '
|
|
echo "$out" | grep -q -- '--cache-from type=registry,ref=[^ ]*/cozystack-controller:buildcache '
|
|
echo "$out" | grep -q -- '--cache-to type=registry,ref=[^ ]*/cozystack-controller:buildcache-release-1.6,[^ ]*ignore-error=true'
|
|
[ "$(echo "$out" | grep -o -- '--cache-to' | wc -l)" -eq 1 ]
|
|
for write in '' WRITE_CACHE=0; do
|
|
out=$(make -n -C "$pkg" image IMAGE_TAG=pr-1-abc COZYSTACK_VERSION=0 $write 'CACHE_FROM_TAGS=buildcache-release-1.6 buildcache')
|
|
[ "$(echo "$out" | grep -o -- '--cache-from' | wc -l)" -eq 2 ]
|
|
[ "$(echo "$out" | grep -o -- '--cache-to' | wc -l)" -eq 0 ]
|
|
done
|
|
out=$(make -n -C "$pkg" image IMAGE_TAG=pr-1-abc COZYSTACK_VERSION=0)
|
|
[ "$(echo "$out" | grep -o -- '--cache-from' | wc -l)" -eq 1 ]
|
|
echo "$out" | grep -q -- '--cache-from type=registry,ref=[^ ]*/cozystack-controller:buildcache '
|
|
}
|
|
|
|
@test "a push to a release line writes the line's cache and imports main's too" {
|
|
step='.jobs["build-line"].steps[] | select(.name == "Build line images and publish the packages artifact")'
|
|
wf=.github/workflows/build-release.yaml
|
|
[ "$(yq "$step | .run" "$wf")" = 'make build-parallel' ]
|
|
[ "$(yq "$step | .env.WRITE_CACHE" "$wf")" = 1 ]
|
|
[ "$(yq "$step | .env.CACHE_TAG" "$wf")" = 'buildcache-${{ github.ref_name }}' ]
|
|
[ "$(yq "$step | .env.CACHE_FROM_TAGS" "$wf")" = 'buildcache-${{ github.ref_name }} buildcache' ]
|
|
}
|
|
|
|
@test "an rc build imports its line's cache and main's, and writes none" {
|
|
wf=.github/workflows/tags.yaml
|
|
build='.jobs["prepare-release"].steps[] | select(.name == "Build")'
|
|
[ "$(yq "$build | .run" "$wf")" = 'make build-parallel' ]
|
|
[ "$(yq "$build | .env.CACHE_FROM_TAGS" "$wf")" = 'buildcache-release-${{ steps.tag.outputs.line }} buildcache' ]
|
|
[ "$(yq "$build | .env.WRITE_CACHE" "$wf")" = null ]
|
|
}
|