chore: make health checks gooder-er #16
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Docker Compose Integration | |
| on: | |
| pull_request: | |
| branches: [ main ] | |
| permissions: | |
| contents: read | |
| jobs: | |
| docker-compose-integration: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Start services | |
| run: docker compose up -d | |
| - name: Wait for services to be healthy | |
| run: | | |
| echo "Waiting for all services to be healthy..." | |
| # Wait for services with health checks to be healthy (7 services) and all services to be up | |
| # Increased timeout to 10 minutes for CI environment | |
| timeout 600 bash -c 'while true; do | |
| echo "=== Detailed Service Status ===" | |
| docker compose ps --format "table {{.Name}}\t{{.Status}}\t{{.Health}}" | |
| echo "=== Unhealthy Services ===" | |
| unhealthy_services=$(docker compose ps --format "{{.Name}} {{.Health}}" | grep -v healthy | grep -v "^[[:space:]]*$" || echo "") | |
| if [ -n "$unhealthy_services" ]; then | |
| echo "$unhealthy_services" | |
| echo "=== Logs for unhealthy services ===" | |
| for service in $(echo "$unhealthy_services" | awk "{print \$1}"); do | |
| echo "--- Logs for $service ---" | |
| docker compose logs --tail=10 "$service" || echo "No logs for $service" | |
| done | |
| else | |
| echo "All services healthy or no health check" | |
| fi | |
| healthy_count=$(docker compose ps --format "{{.Health}}" | grep -c "healthy" || echo "0") | |
| up_count=$(docker compose ps --format "{{.Status}}" | grep -c "Up" || echo "0") | |
| echo "Progress: $healthy_count/7 healthy, $up_count services up" | |
| if [ "$healthy_count" -ge 7 ] && [ "$up_count" -ge 7 ]; then | |
| echo "All services are healthy!" | |
| break | |
| fi | |
| sleep 10 | |
| done' | |
| docker compose ps | |
| - name: Test dashboard endpoints | |
| run: | | |
| curl -f http://localhost:8081/dashboard/ || exit 1 | |
| curl -f http://localhost:8082 || exit 1 | |
| - name: Test API endpoints | |
| run: | | |
| # Test sticker award API with sample user data | |
| curl -f -X GET "http://localhost:8080/api/award/v1/users/user-001/stickers" || exit 1 | |
| # TODO! | |
| # curl -f -X GET "http://localhost:8080/api/users/v1/health" || exit 1 | |
| - name: Show service logs on failure | |
| if: failure() | |
| run: | | |
| echo "=== Docker Compose Services Status ===" | |
| docker compose ps | |
| echo "=== All Service Logs ===" | |
| docker compose logs --tail=50 | |
| echo "=== Health Check Details ===" | |
| docker compose ps --format "table {{.Name}}\t{{.Status}}\t{{.Health}}" | |
| echo "=== Resource Usage ===" | |
| docker stats --no-stream | |
| - name: Cleanup | |
| if: always() | |
| run: docker compose down -v |