Skip to content

Commit 70812b1

Browse files
committed
Capture container logs and exit state on REST smoke failure
1 parent 5ede3b1 commit 70812b1

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

.github/workflows/docker.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,29 @@ jobs:
8282
8383
- name: Smoke test the entrypoint (rest mode)
8484
run: |
85-
docker run --rm -d --name ac-rest -p 9939:9939 \
85+
# Run without --rm so a quick crash leaves the container in
86+
# place for ``docker logs`` to inspect afterwards. Final
87+
# ``docker rm -f`` cleans up regardless of exit state.
88+
docker run -d --name ac-rest -p 9939:9939 \
8689
-e AC_TOKEN=ci-token autocontrol:ci rest
90+
ok=0
8791
for attempt in 1 2 3 4 5 6 7 8 9 10; do
8892
if curl -fsS -H "Authorization: Bearer ci-token" \
8993
http://127.0.0.1:9939/health; then
9094
echo "REST API is up"
95+
ok=1
9196
break
9297
fi
9398
sleep 2
9499
done
100+
echo "::group::docker logs ac-rest"
95101
docker logs ac-rest || true
96-
docker stop ac-rest
102+
echo "::endgroup::"
103+
echo "::group::docker inspect (state)"
104+
docker inspect --format '{{json .State}}' ac-rest || true
105+
echo "::endgroup::"
106+
docker rm -f ac-rest >/dev/null 2>&1 || true
107+
if [ "$ok" -ne 1 ]; then
108+
echo "REST health probe never succeeded" >&2
109+
exit 1
110+
fi

0 commit comments

Comments
 (0)