File tree Expand file tree Collapse file tree 3 files changed +89
-0
lines changed
Expand file tree Collapse file tree 3 files changed +89
-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_order_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_order_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+
14+ # Get HTTP response code and body
15+ local response=$( curl -s -w " \n%{http_code}" " $url " )
16+ local body=$( echo " $response " | sed ' $d' )
17+ local http_code=$( echo " $response " | tail -n1)
18+
19+ if [ " $http_code " == " 200" ]; then
20+ # Check if status is UP
21+ if echo " $body " | grep -q ' "status":"UP"' ; then
22+ return 0
23+ else
24+ echo " Health check returned 200 but status is not UP: $body "
25+ return 1
26+ fi
27+ else
28+ echo " Health check returned HTTP $http_code "
29+ return 1
30+ fi
31+ }
32+
33+ # Wait for service to be ready
34+ echo " Waiting for service to be up..."
35+ for (( i= 1 ; i<= MAX_RETRIES; i++ )) ; do
36+ if check_health " $SERVICE_URL " ; then
37+ echo " ✅ Service is UP and healthy!"
38+
39+ # Print health details
40+ echo " Health endpoint response:"
41+ curl -s " $SERVICE_URL /actuator/health" | head -c 500
42+ echo " "
43+
44+ exit 0
45+ fi
46+ echo " Attempt $i /$MAX_RETRIES : Service not ready yet... waiting ${SLEEP_INTERVAL} s"
47+ sleep $SLEEP_INTERVAL
48+ done
49+
50+ echo " ❌ Service failed to start within timeout."
51+ echo " Final health check attempt:"
52+ curl -s " $SERVICE_URL /actuator/health" || echo " Could not reach service"
53+ exit 1
Original file line number Diff line number Diff line change @@ -16,3 +16,7 @@ spring.jpa.properties.hibernate.format_sql=true
1616# Feign Client Service URLs (override via env vars in production)
1717catalog.service.url =${CATALOG_SERVICE_URL:http://localhost:8082}
1818cart.service.url =${CART_SERVICE_URL:http://localhost:8084}
19+
20+ # Actuator Configuration
21+ management.endpoints.web.exposure.include =health,info
22+ management.endpoint.health.show-details =always
You can’t perform that action at this time.
0 commit comments