Files
harpia/scripts/smoke-image.sh
T
Lucas RayanandClaude Sonnet 5 5ed6cb2c95
Release / Build image (amd64) (push) Successful in 10m49s
Release / Plan (reuse the published image?) (push) Successful in 5s
Release / ci (push) Successful in 20m40s
CI / Format and clippy (push) Successful in 5m43s
CI / Tests (Linux) (push) Successful in 16m5s
CI / Dependency audit (push) Successful in 11s
CI / Docker image (build and smoke test) (push) Skipped
Release / Build image (arm64) (push) Successful in 7m34s
Release / Publish tags (push) Successful in 15s
Release / Gitea release (push) Skipped
Release / CLI (linux-aarch64) (push) Skipped
Release / CLI (linux-x86_64) (push) Skipped
refactor!: rename project from Xexéu to Harpia
Renames the whole project, after the harpy eagle: crates
(xexeu-core/xexeu-cli -> harpia-core/harpia-cli), binary (xexeu ->
harpia), admin token env var (XEXEU_ADMIN_TOKEN -> HARPIA_ADMIN_TOKEN),
compose env vars (XEXEU_* -> HARPIA_*), container image
(ciberfauna/xexeu -> ciberfauna/harpia) and the Gitea repository
(ciberfauna/xexeu -> ciberfauna/harpia). Logo updated to the new brand
artwork. All docs (EN/PT-BR), CI workflows, scripts, GUI strings and
the openspec change history updated to match.

BREAKING CHANGE: binary, crate, env var and image names all changed;
existing .env files, scripts and deployments referencing the old
xexeu/XEXEU names must be updated.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VAyr8cd6jzwpJM9cS1oGjy
2026-11-03 13:43:21 -03:00

42 lines
2.3 KiB
Bash
Executable File

#!/usr/bin/env bash
# Smoke-tests a Harpia image: the API and the dashboard answer,
# harpia doctor reports ok, a HEALTHCHECK is declared and SIGTERM stops the daemon cleanly.
# Everything runs through `docker exec`, so no port has to be reachable from
# the CI job container. The container is always removed.
#
# scripts/smoke-image.sh <image-ref>
set -euo pipefail
image=${1:?usage: smoke-image.sh <image-ref>}
name="harpia-smoke-$$-$RANDOM"
trap 'docker rm -f "$name" >/dev/null 2>&1 || true' EXIT
fail() { echo "smoke: $*" >&2; docker logs "$name" >&2 2>&1 || true; exit 1; }
# The image ships no config (compose mounts ./config), so copy the example in.
# docker cp instead of a bind mount: the daemon may not see this job's paths.
cfg=$(mktemp -d)
trap 'rm -rf "$cfg"; docker rm -f "$name" >/dev/null 2>&1 || true' EXIT
mkdir "$cfg/config"
cp "$(dirname "$0")/../examples/harpia.toml" "$cfg/config/harpia.toml"
docker create --name "$name" "$image" >/dev/null
tar -C "$cfg" -c config | docker cp - "$name:/"
docker start "$name" >/dev/null
for _ in $(seq 1 30); do
docker exec "$name" curl -fsS http://127.0.0.1:8788/api/health >/dev/null 2>&1 && break
sleep 1
done
# Capture output instead of piping into `grep -q`: grep exits at the first match,
# the writer gets SIGPIPE and `pipefail` turns that into a flaky failure.
out=$(docker exec "$name" curl -fsS http://127.0.0.1:8788/api/health) || fail "/api/health did not answer"
grep -q '"status":"ok"' <<<"$out" || fail "/api/health is not ok"
out=$(docker exec "$name" curl -fsS http://127.0.0.1:8788/) || fail "dashboard did not answer"
grep -qi '<!doctype html' <<<"$out" || fail "dashboard is not served"
out=$(docker exec "$name" harpia doctor --json --config /config/harpia.toml --data-dir /data/harpia) || { echo "$out" >&2; fail "harpia doctor --json failed"; }
grep -q '"version"' <<<"$out" || fail "harpia doctor --json has no version"
[ "$(docker inspect -f '{{if .Config.Healthcheck}}yes{{end}}' "$name")" = yes ] || fail "image has no HEALTHCHECK"
[ "$(docker exec "$name" id -u)" != 0 ] || fail "daemon runs as root"
docker stop -t 10 "$name" >/dev/null
code=$(docker inspect -f '{{.State.ExitCode}}' "$name")
[ "$code" = 0 ] || fail "exit code $code after SIGTERM (expected 0: SIGTERM must stop serve)"
echo "smoke: $image ok"