File tree Expand file tree Collapse file tree 2 files changed +70
-0
lines changed
Expand file tree Collapse file tree 2 files changed +70
-0
lines changed Original file line number Diff line number Diff line change 7979 vuln-type : ' os,library'
8080 severity : ' CRITICAL,HIGH' # Only fail on Critical and High issues
8181
82+ # --- NEW STEP: Run Smoke Tests ---
83+ - name : Start Services and Run Smoke Tests
84+ run : |
85+ # Create a network
86+ docker network create smoke-test-net
87+
88+ # Start Postgres
89+ docker run -d --name postgres --network smoke-test-net \
90+ -e POSTGRES_USER=cso2 -e POSTGRES_PASSWORD=password123 -e POSTGRES_DB=CSO2_user_identity_service \
91+ postgres:15-alpine
92+
93+ # Wait a bit for Postgres
94+ sleep 10
95+
96+ # Start App
97+ docker run -d --name app --network smoke-test-net \
98+ -e SERVER_PORT=8080 \
99+ -e DATABASE_URL=jdbc:postgresql://postgres:5432/CSO2_user_identity_service \
100+ -e DATABASE_USERNAME=cso2 \
101+ -e DATABASE_PASSWORD=password123 \
102+ -p 8080:8080 \
103+ local-image-scan:latest
104+
105+ # Run smoke test script
106+ chmod +x ./scripts/smoke-test.sh
107+ ./scripts/smoke-test.sh http://localhost:8080
108+
109+ # Cleanup
110+ docker stop app postgres
111+ docker rm app postgres
112+ docker network rm smoke-test-net
113+
82114 - name : Log in to GHCR
83115 uses : docker/login-action@v3
84116 with :
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ # Configuration
4+ SERVICE_URL=${1:- " http://localhost:8080" }
5+ MAX_RETRIES=30
6+ SLEEP_INTERVAL=5
7+
8+ echo " Starting smoke tests against $SERVICE_URL ..."
9+
10+ # Function to check health
11+ check_health () {
12+ local url=" $1 /actuator/health"
13+ local response=$( curl -s -o /dev/null -w " %{http_code}" " $url " )
14+
15+ if [ " $response " == " 200" ]; then
16+ return 0
17+ else
18+ return 1
19+ fi
20+ }
21+
22+ # Wait for service to be ready
23+ echo " Waiting for service to be up..."
24+ for (( i= 1 ; i<= MAX_RETRIES; i++ )) ; do
25+ if check_health " $SERVICE_URL " ; then
26+ echo " ✅ Service is UP!"
27+
28+ # Verify specific status in JSON response if needed (optional enhancement)
29+ # curl -s "$SERVICE_URL/actuator/health" | grep "UP"
30+
31+ exit 0
32+ fi
33+ echo " Attempt $i /$MAX_RETRIES : Service not ready yet... waiting ${SLEEP_INTERVAL} s"
34+ sleep $SLEEP_INTERVAL
35+ done
36+
37+ echo " ❌ Service failed to start within timeout."
38+ exit 1
You can’t perform that action at this time.
0 commit comments