@@ -55,12 +55,57 @@ jobs:
5555 - name : Start
5656 run : |
5757 # testenv started before
58- BUILDAH_FORMAT=docker ${DOCKER_CMD} compose ${TESTENV_COMPOSE_OPTS} up -d --force-recreate
59- BUILDAH_FORMAT=docker ${DOCKER_CMD} compose ${ANMS_COMPOSE_OPTS} up -d --force-recreate --wait --wait-timeout 600
58+ ${DOCKER_CMD} compose ${TESTENV_COMPOSE_OPTS} up -d --force-recreate
59+ ${DOCKER_CMD} compose ${ANMS_COMPOSE_OPTS} up -d --force-recreate
60+ - name : Wait for containers to become healthy
61+ run : |
62+ set -e
63+
64+ TIMEOUT=600
65+ INTERVAL=5
66+ ELAPSED=0
67+
68+ echo "Waiting for containers to become healthy (timeout: ${TIMEOUT}s)..."
69+
70+ while true; do
71+ # Get all running container IDs
72+ CONTAINERS=$(${DOCKER_CMD} ps -q)
73+
74+ if [ -z "$CONTAINERS" ]; then
75+ echo "No running containers found yet..."
76+ sleep $INTERVAL
77+ ELAPSED=$((ELAPSED + INTERVAL))
78+ continue
79+ fi
80+
81+ # Check health status (ignore containers without healthchecks)
82+ UNHEALTHY=$(${DOCKER_CMD} inspect \
83+ --format '{{if .State.Health}}{{.Name}} {{.State.Health.Status}}{{end}}' \
84+ $CONTAINERS | grep -v ' healthy' || true)
85+
86+ if [ -z "$UNHEALTHY" ]; then
87+ echo "All containers are healthy ✅"
88+ break
89+ fi
90+
91+ echo "Still waiting on:"
92+ echo "$UNHEALTHY"
93+ echo "---"
94+
95+ sleep $INTERVAL
96+ ELAPSED=$((ELAPSED + INTERVAL))
97+
98+ if [ "$ELAPSED" -ge "$TIMEOUT" ]; then
99+ echo "ERROR: Timed out waiting for healthy containers"
100+ ${DOCKER_CMD} ps
101+ exit 1
102+ fi
103+ done
60104 - name : Status
61105 if : always()
62106 run : |
63107 ${DOCKER_CMD} compose ${ANMS_COMPOSE_OPTS} ps
108+ ${DOCKER_CMD} compose ${TESTENV_COMPOSE_OPTS} ps
64109 for BADSTATUS in stopped restarting; do
65110 ${DOCKER_CMD} compose ${ANMS_COMPOSE_OPTS} ps --services --filter status=${BADSTATUS} | tee -a /tmp/notgood
66111 done
0 commit comments