Fix workflow validation by polling inside container
Build and Validate / build-and-test (push) Failing after 16s
Build and Validate / build-and-test (push) Failing after 16s
This commit is contained in:
@@ -22,14 +22,21 @@ jobs:
|
||||
|
||||
- name: Validate web application loads
|
||||
run: |
|
||||
HTTP_STATUS=$(curl -o /dev/null -s -w "%{http_code}\n" http://localhost:4567/)
|
||||
if [ "$HTTP_STATUS" -ne 200 ]; then
|
||||
echo "Failed to load web application. HTTP status: $HTTP_STATUS"
|
||||
docker logs todoizer
|
||||
exit 1
|
||||
else
|
||||
echo "Web application loaded successfully. HTTP status: $HTTP_STATUS"
|
||||
fi
|
||||
echo "Waiting for application to start..."
|
||||
for i in {1..15}; do
|
||||
# Run curl inside the container to bypass any host-runner networking port mapping quirks
|
||||
HTTP_STATUS=$(docker exec todoizer curl -o /dev/null -s -w "%{http_code}\n" http://localhost:4567/ || echo "failed")
|
||||
if [ "$HTTP_STATUS" == "200" ]; then
|
||||
echo "Web application loaded successfully. HTTP status: $HTTP_STATUS"
|
||||
exit 0
|
||||
fi
|
||||
echo "Attempt $i: App not ready (Status: $HTTP_STATUS). Sleeping 2s..."
|
||||
sleep 2
|
||||
done
|
||||
|
||||
echo "Failed to load web application after 30 seconds."
|
||||
docker logs todoizer
|
||||
exit 1
|
||||
|
||||
- name: Cleanup Test Container
|
||||
if: always()
|
||||
|
||||
Reference in New Issue
Block a user