Files
Lucas RayanandClaude Opus 5.5 dc8e390dba
Release / Publish tags (hub) (push) Successful in 19s
Release / Plan (reuse the published image?) (push) Successful in 5s
Release / ci (push) Successful in 2m17s
Release / Build hub image (amd64) (push) Successful in 21s
Release / Build probe image (amd64) (push) Successful in 21s
Release / Build hub image (arm64) (push) Successful in 23s
Release / Build probe image (arm64) (push) Successful in 25s
CI / Format and vet (push) Successful in 1m8s
CI / Tests (Linux, race detector) (push) Successful in 1m42s
CI / Dependency audit (push) Successful in 35s
CI / Docker images (build and smoke test) (push) Skipped
Release / Publish tags (probe) (push) Successful in 13s
Release / Gitea release (push) Successful in 5s
fix(ci): pull the probe image before the smoke test in the release
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 22:39:15 -03:00

37 lines
2.0 KiB
Bash
Executable File

#!/usr/bin/env bash
# Smoke-tests an Urutau probe image: it is small (under 15 MB), runs as a
# non-root user, ships CA certificates and zoneinfo, has a HEALTHCHECK, answers
# --help, and refuses to start without a hub (a clear error, no panic).
# The image is FROM scratch: there is no shell, so nothing runs through `sh`.
#
# scripts/smoke-probe.sh <image-ref>
set -euo pipefail
image=${1:?usage: smoke-probe.sh <image-ref>}
max_bytes=$((15 * 1000 * 1000))
fail() { echo "smoke-probe: $*" >&2; exit 1; }
# In the release the image was pushed by buildx, not loaded: pull it first.
docker image inspect "$image" >/dev/null 2>&1 || docker pull -q "$image" >/dev/null
size=$(docker image inspect -f '{{.Size}}' "$image")
[ "$size" -lt "$max_bytes" ] || fail "image is $size bytes (limit $max_bytes)"
out=$(docker run --rm "$image" --help 2>&1) || fail "'--help' failed: $out"
[ -n "$out" ] || fail "'--help' printed nothing"
grep -qi 'probe' <<<"$out" || fail "'--help' does not mention the probe: $out"
[ "$(docker inspect -f '{{.Config.User}}' "$image")" = 10001:10001 ] || fail "the probe must run as 10001:10001"
[ "$(docker inspect -f '{{if .Config.Healthcheck}}yes{{end}}' "$image")" = yes ] || fail "image has no HEALTHCHECK"
[ -z "$(docker inspect -f '{{range $p, $_ := .Config.ExposedPorts}}{{$p}}{{end}}' "$image")" ] || fail "the probe must not expose a port"
# CA certificates and zoneinfo are in the image (copy them out: no shell inside).
cid=$(docker create "$image")
trap 'docker rm -f "$cid" >/dev/null 2>&1 || true' EXIT
docker cp "$cid:/etc/ssl/certs/ca-certificates.crt" - >/dev/null || fail "CA certificates missing"
docker cp "$cid:/usr/share/zoneinfo/America/Sao_Paulo" - >/dev/null || fail "zoneinfo missing"
# Without configuration the probe stops with a message that names the missing setting.
if out=$(docker run --rm "$image" 2>&1); then fail "the probe must not start without URUTAU_HUB"; fi
grep -qi 'hub' <<<"$out" || fail "the missing-hub error does not mention the hub: $out"
echo "smoke-probe: $image ok ($((size / 1000)) kB)"