Merge branch 'feat/improve-ui-ux-across-pages' into dev #761
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: Service Health Checks | |
| on: | |
| push: | |
| branches: | |
| - dev | |
| pull_request: | |
| branches: | |
| - dev | |
| jobs: | |
| service-health: | |
| name: Run Service Health Checks | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Maximize build space | |
| uses: AdityaGarg8/remove-unwanted-software@v4.1 | |
| with: | |
| remove-android: 'true' | |
| remove-haskell: 'true' | |
| remove-codeql: 'true' | |
| - name: Free up additional space | |
| run: | | |
| sudo rm -rf /usr/share/dotnet | |
| sudo rm -rf /usr/local/lib/android | |
| sudo rm -rf /opt/ghc | |
| sudo rm -rf /opt/hostedtoolcache/CodeQL | |
| sudo docker system prune -af | |
| sudo apt-get autoremove -y | |
| sudo apt-get autoclean | |
| echo "=== Disk space after cleanup ===" | |
| df -h | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| - name: Copy example.env to .env | |
| run: | | |
| echo "Copying example.env to .env..." | |
| find . -name "example.env" | while read f; do | |
| cp "$f" "$(dirname "$f")/.env" | |
| echo "✓ Created $(dirname "$f")/.env" | |
| done | |
| - name: Test each service from services-to-test.txt | |
| run: | | |
| echo "=== Reading services from .github/services-to-test.txt ===" | |
| if [ ! -f ".github/services-to-test.txt" ]; then | |
| echo "Error: .github/services-to-test.txt not found" | |
| exit 1 | |
| fi | |
| # Read services from file, ignore comments and blank lines | |
| SERVICE_LIST=$(grep -v '^#' .github/services-to-test.txt | grep -v '^$' | tr '\n' ' ') | |
| if [ -z "$SERVICE_LIST" ]; then | |
| echo "No services found in .github/services-to-test.txt" | |
| exit 1 | |
| fi | |
| echo "Found services to test: $SERVICE_LIST" | |
| echo "=== Initial disk space ===" | |
| df -h | |
| FAILED_SERVICES="" | |
| SUCCESSFUL_SERVICES="" | |
| # Test each service individually | |
| for SERVICE in $SERVICE_LIST; do | |
| echo "" | |
| echo "==========================================" | |
| echo "Testing $SERVICE" | |
| echo "==========================================" | |
| # Build the service | |
| echo "Building $SERVICE..." | |
| docker compose build $SERVICE | |
| # Start the service | |
| echo "Starting $SERVICE..." | |
| docker compose up -d $SERVICE | |
| # Wait for service to be running | |
| sleep 5 | |
| # Check if container is running | |
| if ! docker ps --filter "name=${SERVICE}" --format "{{.Names}}" | grep -q "${SERVICE}"; then | |
| echo "✗ $SERVICE failed to start" | |
| docker logs $SERVICE --tail 20 2>/dev/null || echo "No logs available" | |
| FAILED_SERVICES="$FAILED_SERVICES $SERVICE" | |
| else | |
| echo "✓ $SERVICE container is running" | |
| # Health check | |
| echo "Checking health of $SERVICE..." | |
| HEALTHY=false | |
| for i in {1..30}; do | |
| STATUS=$(docker exec "$SERVICE" python3 -c 'import urllib.request; response = urllib.request.urlopen("http://localhost:8000/health", timeout=5); print(response.getcode())' 2>/dev/null || echo "000") | |
| if [ "$STATUS" == "200" ]; then | |
| echo "✓ $SERVICE is healthy" | |
| SUCCESSFUL_SERVICES="$SUCCESSFUL_SERVICES $SERVICE" | |
| HEALTHY=true | |
| break | |
| fi | |
| echo "Still waiting for $SERVICE health check (attempt $i/30, HTTP $STATUS)..." | |
| sleep 3 | |
| done | |
| if [ "$HEALTHY" = false ]; then | |
| echo "✗ $SERVICE failed health check" | |
| docker logs "$SERVICE" --tail 30 | |
| FAILED_SERVICES="$FAILED_SERVICES $SERVICE" | |
| fi | |
| fi | |
| # Stop and remove the service | |
| echo "Stopping and removing $SERVICE..." | |
| docker compose stop $SERVICE | |
| docker compose rm -f $SERVICE | |
| # Clean up build artifacts | |
| docker builder prune --force | |
| docker system prune --force | |
| echo "=== Disk space after testing $SERVICE ===" | |
| df -h | grep -E "(/$)" | |
| done | |
| echo "" | |
| echo "==========================================" | |
| echo "TEST RESULTS SUMMARY" | |
| echo "==========================================" | |
| if [ ! -z "$SUCCESSFUL_SERVICES" ]; then | |
| echo "✓ SUCCESSFUL SERVICES:$SUCCESSFUL_SERVICES" | |
| fi | |
| if [ ! -z "$FAILED_SERVICES" ]; then | |
| echo "✗ FAILED SERVICES:$FAILED_SERVICES" | |
| exit 1 | |
| fi | |
| echo "All services from services-to-test.txt passed individual testing!" | |
| - name: Service health checks completed | |
| run: | | |
| echo "✅ All service health checks completed successfully!" | |
| echo "" | |
| echo "Note: E2E tests are disabled and located in e2e-tests.yml.disabled" | |
| echo "To enable E2E tests when frontend is ready:" | |
| echo " 1. Rename e2e-tests.yml.disabled to e2e-tests.yml" | |
| echo " 2. Uncomment the push/pull_request triggers in that file" |