Harden Docker CI smoke test readiness checks
This commit is contained in:
parent
e08c55d4c9
commit
5e19b78259
1 changed files with 36 additions and 9 deletions
|
|
@ -51,8 +51,6 @@ jobs:
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: "22"
|
node-version: "22"
|
||||||
cache: "npm"
|
|
||||||
cache-dependency-path: frontend/package-lock.json
|
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
working-directory: frontend
|
working-directory: frontend
|
||||||
|
|
@ -94,38 +92,67 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
set -Eeuo pipefail
|
set -Eeuo pipefail
|
||||||
|
|
||||||
|
docker rm --force paperjet-ci >/dev/null 2>&1 || true
|
||||||
|
|
||||||
docker run \
|
docker run \
|
||||||
--detach \
|
--detach \
|
||||||
--name paperjet-ci \
|
--name paperjet-ci \
|
||||||
--publish 18080:80 \
|
|
||||||
--env PAPERJET_SECRET_KEY=ci-only-secret \
|
--env PAPERJET_SECRET_KEY=ci-only-secret \
|
||||||
--env PAPERJET_COOKIE_SECURE=false \
|
--env PAPERJET_COOKIE_SECURE=false \
|
||||||
--env PAPERJET_DEBUG=false \
|
--env PAPERJET_DEBUG=false \
|
||||||
paperjet:ci
|
paperjet:ci
|
||||||
|
|
||||||
cleanup() {
|
cleanup() {
|
||||||
|
echo "----- PaperJet container logs -----"
|
||||||
|
docker logs paperjet-ci || true
|
||||||
docker rm --force paperjet-ci >/dev/null 2>&1 || true
|
docker rm --force paperjet-ci >/dev/null 2>&1 || true
|
||||||
}
|
}
|
||||||
trap cleanup EXIT
|
trap cleanup EXIT
|
||||||
|
|
||||||
curl --fail --retry 30 --retry-delay 1 --retry-connrefused \
|
for attempt in $(seq 1 30); do
|
||||||
http://127.0.0.1:18080/
|
running=$(docker inspect --format '{{.State.Running}}' paperjet-ci 2>/dev/null || true)
|
||||||
curl --fail --retry 30 --retry-delay 1 --retry-connrefused \
|
if [ "$running" != "true" ]; then
|
||||||
http://127.0.0.1:18080/api/v1/health
|
echo "PaperJet container exited before becoming ready"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if docker exec paperjet-ci \
|
||||||
|
python -c "import urllib.request; response = urllib.request.urlopen('http://127.0.0.1/', timeout=2); assert response.status == 200" \
|
||||||
|
>/dev/null 2>&1 \
|
||||||
|
&& docker exec paperjet-ci \
|
||||||
|
python -c "import urllib.request; response = urllib.request.urlopen('http://127.0.0.1/api/v1/health', timeout=2); assert response.status == 200" \
|
||||||
|
>/dev/null 2>&1; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
|
||||||
|
running=$(docker inspect --format '{{.State.Running}}' paperjet-ci)
|
||||||
|
if [ "$running" != "true" ]; then
|
||||||
|
echo "PaperJet container did not become ready within 30 seconds"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
docker exec paperjet-ci \
|
||||||
|
python -c "import urllib.request; response = urllib.request.urlopen('http://127.0.0.1/', timeout=2); assert response.status == 200"
|
||||||
|
docker exec paperjet-ci \
|
||||||
|
python -c "import urllib.request; response = urllib.request.urlopen('http://127.0.0.1/api/v1/health', timeout=2); assert response.status == 200"
|
||||||
|
|
||||||
for attempt in $(seq 1 30); do
|
for attempt in $(seq 1 30); do
|
||||||
status=$(docker inspect --format '{{.State.Health.Status}}' paperjet-ci)
|
status=$(docker inspect --format '{{.State.Health.Status}}' paperjet-ci)
|
||||||
if [ "$status" = "healthy" ]; then
|
if [ "$status" = "healthy" ]; then
|
||||||
|
echo "PaperJet smoke test passed"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
if [ "$status" = "unhealthy" ]; then
|
if [ "$status" = "unhealthy" ]; then
|
||||||
docker logs paperjet-ci
|
echo "PaperJet container healthcheck reported unhealthy"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
|
|
||||||
docker logs paperjet-ci
|
echo "PaperJet container did not become healthy within 30 seconds"
|
||||||
exit 1
|
exit 1
|
||||||
|
|
||||||
- name: Log into Local Registry
|
- name: Log into Local Registry
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue