mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-10 16:04:04 +00:00
test(compose): make the allocated smoke explain its own CI failures
This suite fails on GitHub Actions while passing locally, and it failed
the same way at 089c127c -- the branch head before any of this branch's
recent work -- so it is pre-existing rather than newly broken.
Diagnosing it is currently impossible from CI alone. The script is
mostly `curl -fsS` and bare [[ ]] assertions under `set -e`, all of
which abort with no output, so the run log contains nothing but
"make: *** Error 1". Both failing runs are equally silent.
Add an ERR trap that reports the script line and the failing command,
and dump `compose ps` plus the service logs on any non-zero exit rather
than only when COMPOSE_KEEP_ON_FAILURE is set. The next CI run should
therefore say what actually broke instead of needing another round trip
to find out.
No behaviour change on success; the target still passes locally.
This commit is contained in:
@@ -11,8 +11,27 @@ secret="compose-workload-secret"
|
||||
smoke_dir="${COMPOSE_SMOKE_DIR:-/tmp/cosmic-clash-allocated-smoke}"
|
||||
compose=(docker compose -p "$project" -f "$compose_file")
|
||||
|
||||
# Most of this script is `curl -fsS` and bare [[ ]] assertions under `set -e`,
|
||||
# which abort with no message at all. That is fine locally, where the fixture
|
||||
# is still up to poke at, but in CI it produces a failed run whose log contains
|
||||
# nothing but "make: *** Error 1" -- undiagnosable without re-running by hand.
|
||||
# Report where it stopped, and dump the service logs, so a CI failure explains
|
||||
# itself on the first occurrence.
|
||||
failed_line=""
|
||||
on_error() {
|
||||
failed_line="$1"
|
||||
echo "allocated Compose fixture failed at ${BASH_SOURCE[0]}:${failed_line}" >&2
|
||||
echo "--- failing command: ${BASH_COMMAND}" >&2
|
||||
}
|
||||
trap 'on_error "$LINENO"' ERR
|
||||
|
||||
cleanup() {
|
||||
local rc=$?
|
||||
if [[ "$rc" != 0 ]]; then
|
||||
echo "--- allocated Compose service logs follow (exit ${rc}) ---" >&2
|
||||
"${compose[@]}" ps >&2 2>/dev/null || true
|
||||
"${compose[@]}" logs --no-color --tail=80 >&2 2>/dev/null || true
|
||||
fi
|
||||
if [[ "$rc" != 0 && "${COMPOSE_KEEP_ON_FAILURE:-}" == 1 ]]; then
|
||||
echo "allocated Compose fixture retained for inspection: ${project}" >&2
|
||||
exit "$rc"
|
||||
|
||||
Reference in New Issue
Block a user