Skip to content

Commit 17b6954

Browse files
committed
feat: Add smoke tests to CI workflow and implement health check endpoint
1 parent e74c653 commit 17b6954

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

.github/workflows/build-test.yml

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

91+
# --- NEW STEP: Run Smoke Tests ---
92+
- name: Run Smoke Tests
93+
run: |
94+
docker run -d --name app -p 3000:3000 local-image-scan:latest
95+
sleep 15
96+
chmod +x ./scripts/smoke-test.sh
97+
./scripts/smoke-test.sh http://localhost:3000
98+
docker stop app && docker rm app
99+
91100
- name: Log in to GHCR
92101
uses: docker/login-action@v3
93102
with:

app/api/health/route.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export async function GET() {
2+
return Response.json({
3+
status: 'healthy',
4+
timestamp: new Date().toISOString()
5+
})
6+
}

scripts/smoke-test.sh

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

0 commit comments

Comments
 (0)