Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

fix(release): promote a v-prefixed tag and fail loudly on a broken image list

Jose Ramirezefc9216be976
diff --git a/scripts/release/promote-release-images.sh b/scripts/release/promote-release-images.sh
index d63918f00..a9e61a67d 100755
--- a/scripts/release/promote-release-images.sh
+++ b/scripts/release/promote-release-images.sh
@@ -5,6 +5,11 @@ REGISTRY="ghcr.io/evenfire-ai"
DRY_RUN="${DRY_RUN:-true}"
RELEASE_REF="${RELEASE_REF:?RELEASE_REF is required}"
VERSION="${RELEASE_REF#v}"
+# The tag that lands must carry the same "v" the consuming kustomize
+# component and the operator recovery docs pin (newTag: v0.6.0,
+# MINIKUBE_IMAGE_TAG=v0.6.1) -- promoting to a bare :0.6.0 would produce a tag
+# nothing downstream ever pulls.
+TAG="v${VERSION}"
TAG_SHA="$(git rev-parse "$RELEASE_REF^{commit}")"
# :stable moves only for a strict release. A v0.6.0-rc dry run must not
@@ -12,9 +17,29 @@ TAG_SHA="$(git rev-parse "$RELEASE_REF^{commit}")"
MOVE_STABLE=false
[[ "$RELEASE_REF" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]] && MOVE_STABLE=true
-mapfile -t IMAGES < <(node -e '
+# Captured into a variable, not read via `mapfile -t IMAGES < <(...)`.
+# Process substitution hides the reader's exit status from `set -e`: a
+# broken deploy/images.json (images-manifest.mjs's load() throws at import
+# time) printed a Node stack trace to stderr but still let `mapfile` succeed
+# on whatever partial/empty output had been flushed, so this job used to
+# report success -- and promote nothing -- after failing to even read its
+# own image list. Command substitution assignment IS visible to `set -e`.
+if ! IMAGES_TSV="$(node -e '
import("./scripts/release/images-manifest.mjs").then(m =>
- m.publishedImages().forEach(i => console.log(`${i.name}\t${(i.source_paths||[]).join(",")}`)))')
+ m.publishedImages().forEach(i => console.log(`${i.name}\t${(i.source_paths||[]).join(",")}`)))')"; then
+ echo "::error::could not load the published image list (deploy/images.json via images-manifest.mjs); see the Node error above" >&2
+ exit 1
+fi
+
+# An empty list is also a silent-success trap, even when the node command
+# above exits 0 (e.g. every image's `published` flag flipped false). A
+# release that would ship zero images must fail loudly, not report done.
+if [ -z "$IMAGES_TSV" ]; then
+ echo "::error::the published image list is empty; refusing to report success for a release that would ship nothing" >&2
+ exit 1
+fi
+
+mapfile -t IMAGES <<< "$IMAGES_TSV"
failed=0
for row in "${IMAGES[@]}"; do
@@ -37,13 +62,13 @@ for row in "${IMAGES[@]}"; do
fi
if [ "$DRY_RUN" = "true" ]; then
- echo "would promote $name@$digest -> :$VERSION ($platforms)"
+ echo "would promote $name@$digest -> :$TAG ($platforms)"
continue
fi
- crane copy "$REGISTRY/$name@$digest" "$REGISTRY/$name:$VERSION"
+ crane copy "$REGISTRY/$name@$digest" "$REGISTRY/$name:$TAG"
[ "$MOVE_STABLE" = "true" ] && crane copy "$REGISTRY/$name@$digest" "$REGISTRY/$name:stable"
- echo "promoted $name@$digest -> :$VERSION"
+ echo "promoted $name@$digest -> :$TAG"
done
exit $failed
diff --git a/scripts/release/resolve-release-images.mjs b/scripts/release/resolve-release-images.mjs
index 95583d059..c4cf4d444 100644
--- a/scripts/release/resolve-release-images.mjs
+++ b/scripts/release/resolve-release-images.mjs
@@ -7,7 +7,7 @@
// Prints the digest to promote on success; exits non-zero with a named reason
// otherwise.
//
-// Why the revision label and not git history: builds are change-detected, so
+// Why the revision annotation and not git history: builds are change-detected, so
// each image's newest sha- tag sits at a different commit, and the tagged
// commit on main is a dev->main merge that was never built. Computing "the last
// commit touching this image's source paths" lands on feature-branch merge
@@ -73,8 +73,10 @@ try {
if (!revision) {
die(
- `${image}@${digest} carries no org.opencontainers.image.revision label, so there is no way ` +
- `to tell what it was built from. Re-publish via a build_all run before releasing.`
+ `${image}@${digest} carries no org.opencontainers.image.revision annotation, so there is no way ` +
+ `to tell what it was built from. This usually means it is not a multi-arch index produced by ` +
+ `build-publish.yml's merge step (a lone single-platform push has no index to annotate) or it ` +
+ `predates that step recording one -- re-publish via a build_all run so the merge step writes it.`
)
}
@@ -83,7 +85,9 @@ try {
} catch {
die(
`${image}: the published image was built from ${revision}, which is not an ancestor of the ` +
- `release commit ${tagSha}. That image is not in this release.`
+ `release commit ${tagSha} -- that image predates this release. :latest tracks dev, so re-running ` +
+ `build-publish would only move it further forward, not fix this. Merge dev into main so ` +
+ `${tagSha} descends from ${revision}, then cut the release tag again.`
)
}
diff --git a/scripts/tests/test-promote-release-images.sh b/scripts/tests/test-promote-release-images.sh
new file mode 100755
index 000000000..2ab772a11
--- /dev/null
+++ b/scripts/tests/test-promote-release-images.sh
@@ -0,0 +1,167 @@
+#!/usr/bin/env bash
+set -u
+FAIL=0
+
+# promote-release-images.sh is the driver test-resolve-release-images.sh does
+# NOT cover: it loops deploy/images.json (via images-manifest.mjs), builds
+# the promoted tag string, and decides whether a broken or empty image list
+# is a loud failure or a silent no-op success. crane is stubbed on PATH; git
+# and node are real, against a small throwaway repo -- these cases are about
+# the driver's own plumbing, not the registry.
+
+REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
+
+pass() { echo "PASS: $1"; }
+fail() { echo "FAIL: $1"; FAIL=1; }
+
+# A throwaway repo carrying real copies of the three release scripts (not
+# symlinks: images-manifest.mjs computes its manifest path relative to its
+# OWN file location via import.meta.url, which Node resolves through a
+# symlink back to this repo's real deploy/images.json -- only a real copy
+# reads the throwaway one) plus a one-image deploy/images.json and a
+# v0.1.0 tag two commits deep, so ancestry is real rather than mocked.
+make_repo() {
+ local d=$1
+ mkdir -p "$d/widget" "$d/scripts/release" "$d/deploy"
+ cp "$REPO_ROOT/scripts/release/images-manifest.mjs" "$d/scripts/release/"
+ cp "$REPO_ROOT/scripts/release/resolve-release-images.mjs" "$d/scripts/release/"
+ cp "$REPO_ROOT/scripts/release/promote-release-images.sh" "$d/scripts/release/"
+ cat > "$d/deploy/images.json" <<'JSON'
+{
+ "images": [
+ {
+ "name": "widget",
+ "path": "widget",
+ "source_paths": ["widget/**"],
+ "published": true,
+ "deployed_to_minikube": false
+ }
+ ]
+}
+JSON
+ ( cd "$d" && git init -q .
+ echo one > widget/a.ts && git add -A && git -c user.email=t@t -c user.name=t commit -qm one
+ echo two > widget/a.ts && git add -A && git -c user.email=t@t -c user.name=t commit -qm two
+ git tag v0.1.0 )
+}
+
+# A manifest with the SAME one entry, minus `published`. images-manifest.mjs
+# throws for this at import time -- the case this reproduces is the reviewer's:
+# a broken manifest must fail the run, not vanish into an empty image list.
+write_broken_manifest() {
+ cat > "$1/deploy/images.json" <<'JSON'
+{
+ "images": [
+ {
+ "name": "widget",
+ "path": "widget",
+ "source_paths": ["widget/**"],
+ "deployed_to_minikube": false
+ }
+ ]
+}
+JSON
+}
+
+# make_stub <dir> <revision>
+make_stub() {
+ mkdir -p "$1/bin"
+ cat > "$1/bin/crane" <<STUB
+#!/usr/bin/env bash
+COPY_LOG="$1/copy-log"
+case "\$1" in
+ digest) echo "sha256:widgetdigest00000000000000000000000000000000000000000000000000" ;;
+ manifest) echo '{"annotations":{"org.opencontainers.image.revision":"$2"},"manifests":[{"platform":{"architecture":"amd64"}},{"platform":{"architecture":"arm64"}}]}' ;;
+ copy) echo "\$2 \$3" >> "\$COPY_LOG"; echo "copied \$2 -> \$3" ;;
+ *) exit 1 ;;
+esac
+STUB
+ chmod +x "$1/bin/crane"
+}
+
+assert_a_broken_image_manifest_fails_loudly_not_silently() {
+ local d; d="$(mktemp -d)"; make_repo "$d"
+ local old; old="$( cd "$d" && git rev-parse HEAD~1 )"
+ make_stub "$d" "$old"
+ write_broken_manifest "$d"
+ # This is the reviewer's exact repro: images-manifest.mjs's load() throws
+ # at import time. `mapfile -t IMAGES < <(...)` used to hide that failure
+ # from `set -e` entirely -- the run printed a Node stack trace, exited 0,
+ # and promoted nothing. It must now exit nonzero and print no promotion
+ # line.
+ local out rc
+ out="$( cd "$d" && PATH="$d/bin:$PATH" DRY_RUN=true RELEASE_REF=v0.1.0 \
+ bash scripts/release/promote-release-images.sh 2>&1 )" && rc=0 || rc=1
+ if [ "$rc" -ne 0 ] && ! grep -qE 'would promote|^promoted ' <<< "$out"; then
+ pass "a broken image manifest fails the release loudly instead of silently promoting nothing"
+ else
+ fail "expected a nonzero exit and no promotion line; got rc=$rc out='$out'"
+ fi
+ rm -rf "$d"
+}
+
+assert_a_healthy_manifest_still_dry_run_promotes() {
+ local d; d="$(mktemp -d)"; make_repo "$d"
+ # revision == tag_sha (HEAD, which v0.1.0 also points to): a commit is
+ # trivially its own ancestor and its own diff is always empty, so the
+ # resolver succeeds regardless of what changed between commits -- this
+ # case is about the driver's tag construction, not the resolver's
+ # ancestor/diff guards (already covered by test-resolve-release-images.sh).
+ local head; head="$( cd "$d" && git rev-parse HEAD )"
+ make_stub "$d" "$head"
+ local out rc
+ out="$( cd "$d" && PATH="$d/bin:$PATH" DRY_RUN=true RELEASE_REF=v0.1.0 \
+ bash scripts/release/promote-release-images.sh 2>&1 )" && rc=0 || rc=1
+ # Regression guard for the fix above: a HEALTHY manifest must still reach
+ # the promotion line, not just an unhealthy one failing loudly.
+ if [ "$rc" -eq 0 ] && grep -q ':v0.1.0' <<< "$out"; then
+ pass "a healthy manifest still dry-run promotes, with the v-prefixed tag in the echo"
+ else
+ fail "expected exit 0 and a :v0.1.0 dry-run line; got rc=$rc out='$out'"
+ fi
+ rm -rf "$d"
+}
+
+assert_the_real_promotion_copies_to_the_v_prefixed_tag() {
+ local d; d="$(mktemp -d)"; make_repo "$d"
+ # Same reasoning as the dry-run case above: revision == tag_sha so the
+ # resolver's own guards are a non-issue here.
+ local head; head="$( cd "$d" && git rev-parse HEAD )"
+ make_stub "$d" "$head"
+ ( cd "$d" && PATH="$d/bin:$PATH" DRY_RUN=false RELEASE_REF=v0.1.0 \
+ bash scripts/release/promote-release-images.sh >/dev/null 2>&1 )
+ local log; log="$(cat "$d/copy-log" 2>/dev/null || echo '')"
+ # The consuming kustomize component and the operator recovery docs pin
+ # newTag: v0.6.0 / MINIKUBE_IMAGE_TAG=v0.6.1 -- WITH the v. This checks the
+ # actual `crane copy` destination argument, not just an echo string, since
+ # the echo and the real copy target were two separate lines that could
+ # drift from each other.
+ if grep -q 'ghcr.io/evenfire-ai/widget:v0.1.0$' <<< "$log" && grep -q 'ghcr.io/evenfire-ai/widget:stable$' <<< "$log"; then
+ pass "a real promotion copies to the v-prefixed version tag and moves :stable for a strict release"
+ else
+ fail "expected copy destinations ending :v0.1.0 and :stable; got copy-log '$log'"
+ fi
+ rm -rf "$d"
+}
+
+assert_every_defined_case_is_invoked() {
+ # comm -23 over sorted lists -- same pattern as
+ # test-resolve-release-images.sh and test-release-coordinates.sh.
+ local defined invoked missing self
+ self="$REPO_ROOT/scripts/tests/test-promote-release-images.sh"
+ defined="$(grep -oE '^assert_[a-z_]+\(\) \{' "$self" | sed -E 's/\(\) \{$//' | sort -u)"
+ invoked="$(grep -oE '^assert_[a-z_]+$' "$self" | sort -u)"
+ missing="$(comm -23 <(printf '%s\n' "$defined") <(printf '%s\n' "$invoked"))"
+ if [ -z "$missing" ]; then
+ pass "every defined assert_ case is invoked in the call block"
+ else
+ fail "defined but never invoked: $(printf '%s ' $missing)"
+ fi
+}
+
+assert_a_broken_image_manifest_fails_loudly_not_silently
+assert_a_healthy_manifest_still_dry_run_promotes
+assert_the_real_promotion_copies_to_the_v_prefixed_tag
+assert_every_defined_case_is_invoked
+
+exit $FAIL
diff --git a/scripts/tests/test-resolve-release-images.sh b/scripts/tests/test-resolve-release-images.sh
index d99cd48cf..5ea6d002a 100755
--- a/scripts/tests/test-resolve-release-images.sh
+++ b/scripts/tests/test-resolve-release-images.sh
@@ -92,7 +92,7 @@ assert_a_source_change_after_the_revision_is_rejected() {
rm -rf "$d"
}
-assert_a_missing_revision_label_fails_loudly() {
+assert_a_missing_revision_annotation_fails_loudly() {
local d; d="$(mktemp -d)"; make_repo "$d"
mkdir -p "$d/bin"
cat > "$d/bin/crane" <<'STUB'
@@ -107,10 +107,14 @@ STUB
local out
out="$( cd "$d" && PATH="$d/bin:$PATH" node "$REPO_ROOT/scripts/release/resolve-release-images.mjs" \
--image control-api --source-paths 'unrelated/**' --tag-sha HEAD 2>&1 )" && rc=0 || rc=1
- if [ "$rc" -ne 0 ] && grep -qi "revision label" <<< "$out"; then
- pass "a missing revision label fails loudly rather than promoting blind"
+ # "annotation", not "label": the value lives on the OCI index's own
+ # annotations now, and the resolver's message was corrected to match --
+ # this assertion would have masked that wording bug had it kept checking
+ # for the old "revision label" phrase.
+ if [ "$rc" -ne 0 ] && grep -qi "revision annotation" <<< "$out"; then
+ pass "a missing revision annotation fails loudly rather than promoting blind"
else
- fail "expected a named failure about the revision label; got rc=$rc out='$out'"
+ fail "expected a named failure about the revision annotation; got rc=$rc out='$out'"
fi
rm -rf "$d"
}
@@ -119,14 +123,31 @@ assert_the_digest_is_resolved_once_and_reused() {
local d; d="$(mktemp -d)"; make_repo "$d"
local old; old="$( cd "$d" && git rev-parse HEAD~1 )"
mkdir -p "$d/bin"
- # Emit a DIFFERENT digest on each call. If the script resolves :latest more
- # than once, the digest it verified is not the digest it would promote --
- # a time-of-check-to-time-of-use bug, because :latest moves on every dev push.
+ # Two independent counters. `digest-calls` (as before) proves each `crane
+ # digest` call returns a fresh value, so a repeated call would be caught by
+ # `sha256:call1` no longer being what gets printed. `latest-refs` is the
+ # broader net: it fires on ANY crane subcommand whose arguments reference
+ # `:latest`, not only `digest`. A stub that only counted `digest` calls
+ # cannot see the resolver re-reading the moving tag through a DIFFERENT
+ # subcommand (e.g. `crane manifest .../image:latest` in place of
+ # `.../image@$digest`) -- proven by mutating the resolver's manifest read
+ # to do exactly that: with only the digest-only counter, nothing reddened.
cat > "$d/bin/crane" <<STUB
#!/usr/bin/env bash
-COUNT_FILE="$d/digest-calls"
+DIGEST_COUNT_FILE="$d/digest-calls"
+LATEST_COUNT_FILE="$d/latest-refs"
+if printf '%s ' "\$@" | grep -q ':latest'; then
+ n=\$(( \$(cat "\$LATEST_COUNT_FILE" 2>/dev/null || echo 0) + 1 )); echo "\$n" > "\$LATEST_COUNT_FILE"
+ if [ "\$n" -gt 1 ]; then
+ echo "crane stub: :latest referenced more than once (args: \$*)" >&2
+ exit 1
+ fi
+fi
case "\$1" in
- digest) n=\$(( \$(cat "\$COUNT_FILE" 2>/dev/null || echo 0) + 1 )); echo "\$n" > "\$COUNT_FILE"; echo "sha256:call\$n" ;;
+ digest)
+ n=\$(( \$(cat "\$DIGEST_COUNT_FILE" 2>/dev/null || echo 0) + 1 )); echo "\$n" > "\$DIGEST_COUNT_FILE"
+ echo "sha256:call\$n"
+ ;;
manifest) echo '{"annotations":{"org.opencontainers.image.revision":"$old"}}' ;;
*) exit 1 ;;
esac
@@ -134,11 +155,12 @@ STUB
chmod +x "$d/bin/crane"
local out; out="$( cd "$d" && PATH="$d/bin:$PATH" node "$REPO_ROOT/scripts/release/resolve-release-images.mjs" \
--image control-api --source-paths 'unrelated/**' --tag-sha HEAD 2>&1 )"
- local calls; calls="$(cat "$d/digest-calls" 2>/dev/null || echo 0)"
- if [ "$calls" = "1" ] && grep -q "sha256:call1" <<< "$out"; then
+ local digest_calls; digest_calls="$(cat "$d/digest-calls" 2>/dev/null || echo 0)"
+ local latest_refs; latest_refs="$(cat "$d/latest-refs" 2>/dev/null || echo 0)"
+ if [ "$digest_calls" = "1" ] && [ "$latest_refs" = "1" ] && grep -q "sha256:call1" <<< "$out"; then
pass "the moving :latest tag is resolved to a digest exactly once"
else
- fail "crane digest called $calls time(s), output '$out'"
+ fail "crane digest called $digest_calls time(s), :latest referenced $latest_refs time(s), output '$out'"
fi
rm -rf "$d"
}
@@ -164,7 +186,7 @@ assert_every_defined_case_is_invoked() {
assert_a_revision_that_is_an_ancestor_resolves
assert_a_non_ancestor_revision_is_rejected
assert_a_source_change_after_the_revision_is_rejected
-assert_a_missing_revision_label_fails_loudly
+assert_a_missing_revision_annotation_fails_loudly
assert_the_digest_is_resolved_once_and_reused
assert_every_defined_case_is_invoked