Skip to content

Commit 924e06d

Browse files
committed
feat(workflows): add smoke tests to validate API Gateway readiness
1 parent 0c76ff5 commit 924e06d

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

.github/workflows/build-test.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,15 @@ jobs:
7070
vuln-type: 'os,library'
7171
severity: 'CRITICAL,HIGH' # Only fail on Critical and High issues
7272

73+
# --- NEW STEP: Run Smoke Tests ---
74+
- name: Run Smoke Tests
75+
run: |
76+
docker run -d --name app -p 8080:8080 local-image-scan:latest
77+
sleep 5
78+
chmod +x ./scripts/smoke-test.sh
79+
./scripts/smoke-test.sh http://localhost:8080
80+
docker stop app && docker rm app
81+
7382
- name: Log in to GHCR
7483
uses: docker/login-action@v3
7584
with:

scripts/smoke-test.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
3+
# Configuration
4+
SERVICE_URL=${1:-"http://localhost:8080"}
5+
MAX_RETRIES=30
6+
SLEEP_INTERVAL=2
7+
8+
echo "Starting smoke tests against $SERVICE_URL..."
9+
10+
# Wait for gateway to be ready
11+
echo "Waiting for gateway to be up..."
12+
for ((i=1; i<=MAX_RETRIES; i++)); do
13+
response=$(curl -s -o /dev/null -w "%{http_code}" "$SERVICE_URL/healthz")
14+
if [ "$response" == "200" ]; then
15+
echo "✅ API Gateway is UP and healthy!"
16+
exit 0
17+
fi
18+
echo "Attempt $i/$MAX_RETRIES: Gateway not ready yet... waiting ${SLEEP_INTERVAL}s"
19+
sleep $SLEEP_INTERVAL
20+
done
21+
22+
echo "❌ Gateway failed to start within timeout."
23+
exit 1

0 commit comments

Comments
 (0)