Skip to content

Commit a8c9578

Browse files
committed
ci: fix image test healthcheck, use auth properly
1 parent 6da89ee commit a8c9578

File tree

1 file changed

+61
-7
lines changed

1 file changed

+61
-7
lines changed

.github/workflows/image.yaml

Lines changed: 61 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,54 @@ jobs:
3535
run: |
3636
set -euxo pipefail
3737
38-
# Test server startup
39-
docker run -d --name test-server -p 8000:8000 -e HOSTS=0.0.0.0:8000 glim-test
38+
# Generate health check token
39+
HEALTHCHECK_TOKEN=$(openssl rand -hex 64)
40+
echo "Generated health check token: ${HEALTHCHECK_TOKEN}"
41+
42+
# Test server startup with debug logging
43+
docker run -d --name test-server \
44+
-p 8000:8000 \
45+
-e HOSTS=0.0.0.0:8000 \
46+
-e HEALTHCHECK_TOKEN=${HEALTHCHECK_TOKEN} \
47+
-e RUST_LOG=debug \
48+
-e LOG_LEVEL=debug \
49+
glim-test
4050
4151
# Wait for server to start with retry logic
4252
for i in {1..30}; do
43-
if curl -f -s http://0.0.0.0:8000/health > /dev/null 2>&1; then
53+
echo "Attempt $i: Testing health endpoint..."
54+
55+
# Test with verbose curl to see what's happening
56+
RESPONSE=$(curl -v -f -s -w "\nHTTP_CODE:%{http_code}\nTOTAL_TIME:%{time_total}\n" \
57+
-H "Authorization: Bearer ${HEALTHCHECK_TOKEN}" \
58+
http://0.0.0.0:8000/health 2>&1) || {
59+
echo "Curl failed with exit code $?"
60+
echo "Full curl response:"
61+
echo "$RESPONSE"
62+
63+
# Check if it's a 401 (unauthorized)
64+
if echo "$RESPONSE" | grep -q "HTTP_CODE:401"; then
65+
echo "::error::Health endpoint returned 401 Unauthorized - authentication required"
66+
echo "=== Container logs ==="
67+
docker logs test-server
68+
echo "=== End container logs ==="
69+
exit 1
70+
fi
71+
72+
# Check if it's a timeout
73+
if echo "$RESPONSE" | grep -q "timeout\|Connection refused"; then
74+
echo "Connection timeout or refused - server may not be ready yet"
75+
else
76+
echo "::error::Unexpected curl error"
77+
echo "=== Container logs ==="
78+
docker logs test-server
79+
echo "=== End container logs ==="
80+
exit 1
81+
fi
82+
}
83+
84+
# Check if we got a successful response
85+
if echo "$RESPONSE" | grep -q "HTTP_CODE:200"; then
4486
echo "Server is ready after $i seconds"
4587
if [ $i -gt 8 ]; then
4688
echo "::warning::Server took longer than expected to start ($i seconds)"
@@ -58,21 +100,33 @@ jobs:
58100
sleep 1
59101
done
60102
61-
# Test health endpoint
62-
if ! curl -f http://0.0.0.0:8000/health; then
103+
# Test health endpoint with proper logging
104+
echo "Testing health endpoint..."
105+
if ! curl -v -f -H "Authorization: Bearer ${HEALTHCHECK_TOKEN}" http://0.0.0.0:8000/health; then
63106
echo "::error::Health endpoint test failed"
107+
echo "=== Container logs ==="
108+
docker logs test-server
109+
echo "=== End container logs ==="
64110
exit 1
65111
fi
66112
67113
# Test main endpoint (should redirect)
68-
if ! curl -f -I http://0.0.0.0:8000/; then
114+
echo "Testing main endpoint..."
115+
if ! curl -v -f -I http://0.0.0.0:8000/; then
69116
echo "::error::Main endpoint test failed"
117+
echo "=== Container logs ==="
118+
docker logs test-server
119+
echo "=== End container logs ==="
70120
exit 1
71121
fi
72122
73123
# Test image generation
74-
if ! curl -f -o test-image.png -w "%{http_code}" http://0.0.0.0:8000/Xevion/Glim.png | grep -q "200"; then
124+
echo "Testing image generation..."
125+
if ! curl -v -f -o test-image.png -w "%{http_code}" http://0.0.0.0:8000/Xevion/Glim.png | grep -q "200"; then
75126
echo "::error::Image generation test failed"
127+
echo "=== Container logs ==="
128+
docker logs test-server
129+
echo "=== End container logs ==="
76130
exit 1
77131
fi
78132

0 commit comments

Comments
 (0)