Skip to content

Commit bf603c8

Browse files
authored
chore: add integration test to validate docker-compose (#18)
* chore: add integration test to validate docker-compose * chore: only fire other workflows if their directories are touched
1 parent d43a525 commit bf603c8

2 files changed

Lines changed: 64 additions & 0 deletions

File tree

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Docker Compose Integration
2+
3+
on:
4+
pull_request:
5+
branches: [ main ]
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
docker-compose-integration:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
18+
- name: Set up Docker Buildx
19+
uses: docker/setup-buildx-action@v3
20+
21+
- name: Start services
22+
run: docker compose up -d
23+
24+
- name: Wait for services to be healthy
25+
run: |
26+
echo "Waiting for all services to be healthy..."
27+
# Wait for services with health checks to be healthy (4 services) and all services to be up
28+
timeout 300 bash -c 'until [ $(docker compose ps --format "{{.Health}}" | grep -c "healthy") -ge 4 ] && [ $(docker compose ps --format "{{.Status}}" | grep -c "Up") -ge 5 ]; do sleep 5; done'
29+
docker compose ps
30+
31+
- name: Test dashboard endpoints
32+
run: |
33+
curl -f http://localhost:8081/dashboard/ || exit 1
34+
curl -f http://localhost:8082 || exit 1
35+
36+
- name: Test API endpoints
37+
run: |
38+
# Test sticker award API with sample user data
39+
curl -f -X GET "http://localhost:8080/api/award/v1/users/user-001/stickers" || exit 1
40+
# TODO!
41+
# curl -f -X GET "http://localhost:8080/api/users/v1/health" || exit 1
42+
43+
- name: Show service logs on failure
44+
if: failure()
45+
run: |
46+
echo "=== Docker Compose Services Status ==="
47+
docker compose ps
48+
echo "=== Traefik Logs ==="
49+
docker compose logs traefik
50+
echo "=== Sticker Award Logs ==="
51+
docker compose logs sticker-award
52+
echo "=== User Management Logs ==="
53+
docker compose logs user-management
54+
echo "=== Database Logs ==="
55+
docker compose logs sticker-award-db
56+
docker compose logs user-management-db
57+
58+
- name: Cleanup
59+
if: always()
60+
run: docker compose down -v

.github/workflows/user-management-test.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,12 @@ name: User Management Tests
33
on:
44
push:
55
branches: ["main"]
6+
paths:
7+
- "user-management/**"
68
pull_request:
79
branches: ["main"]
10+
paths:
11+
- "user-management/**"
812
workflow_dispatch:
913

1014
jobs:

0 commit comments

Comments
 (0)