Skip to content

Commit 67b8f8a

Browse files
committed
Add github workflow to validate docker compose
1 parent a105e19 commit 67b8f8a

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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

0 commit comments

Comments
 (0)