Skip to content

Commit eee43d9

Browse files
committed
ci(e2e): name the packages that kept release refs instead of current main
A file whose config differs from the artifact beyond its image lines keeps the committed ref. That is the safe answer, and it is not a neutral one: the component then runs its last release image in a lane whose job is to exercise the tree under review, and the only trace is one line among hundreds of overlay lines. Six packages took that path on a recent run, backupstrategy-controller among them, which is why four backup round-trip suites refused Kinds the tree supports and three unrelated pull requests each spent a round establishing the red lane was not theirs (#4257). Summarise the drifted packages in one GitHub annotation. Nothing about which files are overlaid changes; a run with no drift emits nothing. Assisted-by: LLM Signed-off-by: IvanHunters <[email protected]>
1 parent 070dcb1 commit eee43d9

2 files changed

Lines changed: 50 additions & 0 deletions

File tree

‎hack/overlay-main-images.sh‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ overlaid=0
8383
same=0
8484
skipped=0
8585
drift=0
86+
drift_files=""
8687
failed=0
8788
# Walk the artifact's ref-bearing files, pruning vendored charts/ subtrees.
8889
# `for … in $(find)` (not a pipe) keeps the counters in this shell; package
@@ -107,6 +108,7 @@ for new in $(find "$MAINPKGS" -type d -name charts -prune -o \
107108
if diff "$cur" "$new" | sed -n 's/^[<>] //p' | grep -qvE "$img_line"; then
108109
echo "drift (non-ref change) in $cur -> keeping committed ref"
109110
drift=$((drift + 1))
111+
drift_files="$drift_files $(dirname "${cur#packages/}")"
110112
continue
111113
fi
112114

@@ -120,3 +122,15 @@ for new in $(find "$MAINPKGS" -type d -name charts -prune -o \
120122
done
121123

122124
echo "Overlay current-main images: overlaid=$overlaid same=$same skipped(rebuilt/owned/edited)=$skipped drift=$drift failed=$failed"
125+
126+
# Keeping the committed ref is the safe answer to a config that does not match
127+
# the artifact, but it is not a neutral one: that component then runs its last
128+
# RELEASE image in a lane whose job is to exercise the tree under review. Said
129+
# once per file among hundreds of overlay lines, it reads as bookkeeping. Said
130+
# once at the end, with the packages named, it is the first thing to check when
131+
# a suite fails on behaviour the diff plainly contains — which is what #4257
132+
# cost three unrelated PRs, one round each.
133+
if [ "$drift" -gt 0 ]; then
134+
printf '::warning title=Image overlay drift::%s package(s) kept committed release refs, so they run release images in this lane rather than current main:%s\n' \
135+
"$drift" "$(echo "$drift_files" | tr ' ' '\n' | sort -u | tr '\n' ' ' | sed 's/ */ /g; s/ $//')"
136+
fi

‎hack/overlay-main-images_test.bats‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,3 +217,39 @@
217217
echo ":buildcache ref races build-main.yaml on the cache manifest." >&2
218218
exit 1; }
219219
}
220+
221+
# A drifted file keeps its committed release ref, which is the safe choice, but
222+
# it also means that component runs a release image in a lane meant to exercise
223+
# the tree under review. That used to be one line among hundreds, so three
224+
# separate PRs each spent a round establishing that a red backup suite was not
225+
# theirs (#4257).
226+
@test "drift is summarised as a GitHub annotation naming the packages" {
227+
root=$(pwd)
228+
w=$(mktemp -d); trap 'rm -rf "$w"' EXIT
229+
mkdir -p "$w/packages/system/alpha" "$w/main/system/alpha"
230+
mkdir -p "$w/packages/system/beta" "$w/main/system/beta"
231+
printf 'tuning: old\nimage: ghcr.io/cozystack/cozystack/alpha:v1.5.0@sha256:aaaa\n' > "$w/packages/system/alpha/values.yaml"
232+
printf 'tuning: new\nimage: iad.ocir.io/x/cozystack/alpha:main@sha256:bbbb\n' > "$w/main/system/alpha/values.yaml"
233+
printf 'tuning: old\nimage: ghcr.io/cozystack/cozystack/beta:v1.5.0@sha256:cccc\n' > "$w/packages/system/beta/values.yaml"
234+
printf 'tuning: new\nimage: iad.ocir.io/x/cozystack/beta:main@sha256:dddd\n' > "$w/main/system/beta/values.yaml"
235+
cd "$w"
236+
"$root/hack/overlay-main-images.sh" main '[]' > out.txt
237+
# Read the names out of the ANNOTATION line, not the whole log: every drifted
238+
# file already prints its own path above, so grepping the log would pass even
239+
# if the summary named nothing.
240+
grep '::warning title=Image overlay drift' out.txt > ann.txt
241+
grep -q 'system/alpha' ann.txt
242+
grep -q 'system/beta' ann.txt
243+
grep -q '2 package(s)' ann.txt
244+
}
245+
246+
@test "no annotation when nothing drifted" {
247+
root=$(pwd)
248+
w=$(mktemp -d); trap 'rm -rf "$w"' EXIT
249+
mkdir -p "$w/packages/system/clean" "$w/main/system/clean"
250+
printf 'image: ghcr.io/cozystack/cozystack/clean:v1.5.0@sha256:aaaa\n' > "$w/packages/system/clean/values.yaml"
251+
printf 'image: iad.ocir.io/x/cozystack/clean:main@sha256:bbbb\n' > "$w/main/system/clean/values.yaml"
252+
cd "$w"
253+
"$root/hack/overlay-main-images.sh" main '[]' > out.txt
254+
! grep -q '::warning title=Image overlay drift' out.txt
255+
}

0 commit comments

Comments
 (0)