File tree Expand file tree Collapse file tree 1 file changed +46
-0
lines changed
Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Docker Compose Validation
2+
3+ on :
4+ pull_request :
5+ push :
6+ branches : [ main ]
7+
8+ jobs :
9+ validate-compose :
10+ name : Spin up and test health of services
11+ runs-on : ubuntu-latest
12+
13+ steps :
14+ - name : Checkout repository
15+ uses : actions/checkout@v4
16+
17+ - name : Set up Docker Buildx
18+ uses : docker/setup-buildx-action@v3
19+
20+ - name : Start Docker Compose stack
21+ run : |
22+ docker compose up -d --build
23+
24+ - name : Wait for services with health checks to become healthy
25+ run : |
26+ timeout 180 bash -c '
27+ while true; do
28+ unhealthy=$(docker compose ps --format "{{.Service}} {{.Health}}" | awk '\''$2 != "healthy" && $2 != "" {print $1}'\'')
29+ if [ -z "$unhealthy" ]; then
30+ echo "✅ All services with health checks are healthy!"
31+ break
32+ fi
33+ echo "Still waiting for unhealthy services:"
34+ echo "$unhealthy"
35+ sleep 5
36+ done
37+ '
38+
39+ - name : Run basic sanity checks
40+ run : |
41+ echo "Checking logs for errors..."
42+ docker compose logs --no-color | grep -i "error" && exit 1 || echo "No errors detected."
43+
44+ - name : Tear down Docker Compose
45+ if : always()
46+ run : docker compose down -v
You can’t perform that action at this time.
0 commit comments