remove #18
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: CI Health Check | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| branches: [ main ] | |
| jobs: | |
| health-check: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/[email protected] | |
| - name: Set up Docker Buildx | |
| uses: docker/[email protected] | |
| - name: Docker & system info | |
| run: | | |
| set -x | |
| docker version | |
| docker compose version | |
| uname -a | |
| df -h | |
| - name: Build and start services | |
| run: | | |
| set -Eeuo pipefail | |
| docker compose up --build -d | |
| echo "=== Running containers ===" | |
| docker ps | |
| - name: Wait for API port to be open | |
| run: | | |
| set -Eeuo pipefail | |
| echo "Waiting for API on port 4000..." | |
| for i in {1..30}; do | |
| if curl -sf http://localhost:4000/health > /dev/null; then | |
| echo "API is ready." | |
| exit 0 | |
| fi | |
| echo "[$i/30] API not ready..." | |
| sleep 2 | |
| done | |
| echo "API did not become ready in time" | |
| docker compose logs | |
| exit 1 | |
| - name: Health check API (/health) | |
| run: | | |
| set -Eeuo pipefail | |
| sleep 5 | |
| echo "===== Checking /health =====" | |
| curl -v --connect-timeout 5 --max-time 10 \ | |
| -w "\nHTTP_CODE=%{http_code}\nTOTAL_TIME=%{time_total}\n" \ | |
| http://localhost:4000/health || true | |
| code=$(curl -s -o /tmp/health.out -w "%{http_code}" http://localhost:4000/health || echo "000") | |
| echo "/health HTTP: $code" | |
| echo "--- /health body ---" | |
| cat /tmp/health.out || true | |
| if [ "$code" != "200" ]; then | |
| echo "API health check failed." | |
| exit 1 | |
| fi | |
| echo "API health check passed." | |
| - name: Health check database (/health/db) | |
| run: | | |
| set -Eeuo pipefail | |
| sleep 3 | |
| echo "===== Checking /health/db =====" | |
| curl -v --connect-timeout 5 --max-time 10 \ | |
| -w "\nHTTP_CODE=%{http_code}\nTOTAL_TIME=%{time_total}\n" \ | |
| http://localhost:4000/health/db || true | |
| code=$(curl -s -o /tmp/healthdb.out -w "%{http_code}" http://localhost:4000/health/db || echo "000") | |
| echo "/health/db HTTP: $code" | |
| echo "--- /health/db body ---" | |
| cat /tmp/healthdb.out || true | |
| if [ "$code" != "200" ]; then | |
| echo "Database health check failed." | |
| exit 1 | |
| fi | |
| echo "Database health check passed." | |
| - name: Dump Docker diagnostics on failure | |
| if: failure() | |
| run: | | |
| echo "=== docker ps ===" | |
| docker ps -a | |
| echo "=== docker compose logs ===" | |
| docker compose logs --no-color | |
| # echo "=== docker inspect ===" | |
| # docker inspect $(docker ps -aq) || true | |
| - name: Stop services | |
| if: always() | |
| run: | | |
| docker compose down -v |