GH-433: [License] Adding Apache 2.0 License and Copyrights to each file on the repo #30
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: Ingestion API Test | |
| on: | |
| push: | |
| branches: [ main ] | |
| paths: | |
| - 'opengin/ingestion-api/**' | |
| - 'opengin/ingestion-api/docker/Dockerfile' | |
| - 'opengin/ingestion-api/docker/Dockerfile.choreo' | |
| - 'docker-compose.yml' | |
| pull_request: | |
| branches: [ main ] | |
| paths: | |
| - 'opengin/ingestion-api/**' | |
| - 'opengin/ingestion-api/docker/Dockerfile' | |
| - 'opengin/ingestion-api/docker/Dockerfile.choreo' | |
| - 'docker-compose.yml' | |
| jobs: | |
| ingestion-api-workflow: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Clear GitHub Actions cache | |
| run: | | |
| echo "π§Ή Clearing GitHub Actions cache..." | |
| rm -rf ~/.cache || true | |
| rm -rf /tmp/* || true | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v2 | |
| - name: Build and test Ingestion service | |
| run: | | |
| # Complete cache and container cleanup for fresh start | |
| echo "π§Ή Complete cleanup - removing all containers, images, and cache..." | |
| docker compose down --remove-orphans || true | |
| docker system prune -af || true # -a removes all unused images, -f forces without prompt | |
| docker builder prune -af || true # Clean build cache | |
| docker volume prune -f || true # Clean unused volumes | |
| # Build Ingestion service (force rebuild to pick up environment variable changes) | |
| docker compose build --no-cache ingestion | |
| # Start required dependencies with tmpfs volumes for fresh databases | |
| docker compose -f docker-compose.yml -f docker-compose.override.yml up -d mongodb neo4j postgres core | |
| # Wait for databases to be fully initialized | |
| echo "β³ Waiting for databases to be fully initialized..." | |
| sleep 30 | |
| # Verify databases are fresh and ready | |
| echo "π Verifying database state..." | |
| echo "MongoDB collections:" | |
| docker exec mongodb mongosh --eval "db.getMongo().getDBNames()" || echo "MongoDB not ready yet" | |
| echo "Neo4j nodes:" | |
| docker exec neo4j cypher-shell -u neo4j -p neo4j123 "MATCH (n) RETURN count(n) as nodeCount" || echo "Neo4j not ready yet" | |
| echo "PostgreSQL tables:" | |
| docker exec postgres psql -U postgres -d opengin -c "\dt" || echo "PostgreSQL not ready yet" | |
| # Wait for dependencies to be healthy | |
| echo "Waiting for dependencies to be healthy..." | |
| timeout=300 | |
| while [ $timeout -gt 0 ]; do | |
| if docker compose ps | grep -q "healthy"; then | |
| echo "Dependencies are starting to be healthy..." | |
| break | |
| fi | |
| # Check if any services have failed | |
| if docker compose ps | grep -q "Exit"; then | |
| echo "β Some services have failed during startup!" | |
| echo "=== Service Status ===" | |
| docker compose ps | |
| echo "=== Failed Service Logs ===" | |
| docker compose logs mongodb neo4j postgres core | |
| docker compose down | |
| exit 1 | |
| fi | |
| echo "Waiting for health checks... ($timeout seconds remaining)" | |
| sleep 5 | |
| timeout=$((timeout - 5)) | |
| done | |
| if [ $timeout -le 0 ]; then | |
| echo "β Timeout waiting for dependencies to be healthy!" | |
| echo "=== Service Status ===" | |
| docker compose ps | |
| echo "=== Dependency Logs ===" | |
| docker compose logs mongodb neo4j postgres core | |
| docker compose down | |
| exit 1 | |
| fi | |
| # Wait for CORE service to complete tests and start the server | |
| echo "Waiting for CORE service to complete tests and start server..." | |
| timeout=600 # 10 minutes for Go tests to complete | |
| while [ $timeout -gt 0 ]; do | |
| if docker compose logs core | grep -q "CORE Service is running on"; then | |
| echo "β CORE service is now running!" | |
| break | |
| elif docker compose logs core | grep -q "FAILED\|failed\|error.*test"; then | |
| echo "β CORE service tests failed!" | |
| echo "CORE service logs:" | |
| docker compose logs core | |
| docker compose down | |
| exit 1 | |
| elif docker compose logs core | grep -q "duplicate key error"; then | |
| echo "β CORE service tests failed due to duplicate key error!" | |
| echo "This indicates database cleanup didn't work properly." | |
| echo "CORE service logs:" | |
| docker compose logs core | |
| docker compose down | |
| exit 1 | |
| fi | |
| echo "Waiting for CORE service startup... ($timeout seconds remaining)" | |
| sleep 10 | |
| timeout=$((timeout - 10)) | |
| done | |
| if [ $timeout -le 0 ]; then | |
| echo "β Timeout waiting for CORE service to start!" | |
| echo "CORE service logs:" | |
| docker compose logs core | |
| docker compose down | |
| exit 1 | |
| fi | |
| # Start Ingestion service in detached mode | |
| echo "Starting Ingestion service and running tests..." | |
| if ! docker compose up -d ingestion; then | |
| echo "β Failed to start Ingestion service!" | |
| echo "=== All Service Status ===" | |
| docker compose ps | |
| echo "=== CORE Service Logs ===" | |
| docker compose logs core | |
| echo "=== Ingestion Service Logs ===" | |
| docker compose logs ingestion | |
| docker compose down | |
| exit 1 | |
| fi | |
| # Wait for tests to complete | |
| echo "Waiting for tests to complete..." | |
| sleep 30 | |
| # Check the logs for test results | |
| echo "=== Ingestion Service Logs ===" | |
| docker compose logs ingestion | |
| echo "=== CORE Service Logs ===" | |
| docker compose logs core | |
| echo "=== All Service Status ===" | |
| docker compose ps | |
| if docker compose logs ingestion | grep -q "failing" && ! docker compose logs ingestion | grep -q "0 failing"; then | |
| echo "β Ingestion API tests failed!" | |
| echo "Checking for specific error patterns..." | |
| if docker compose logs ingestion | grep -q "500"; then | |
| echo "π Found HTTP 500 errors - likely CORE service connectivity issue" | |
| echo "CORE service status:" | |
| docker compose ps core | |
| fi | |
| if docker compose logs ingestion | grep -q "Connection refused\|connect: connection refused"; then | |
| echo "π Found connection refused errors - CORE service may not be responding" | |
| fi | |
| docker compose down | |
| exit 1 | |
| elif docker compose logs ingestion | grep -q "0 failing"; then | |
| echo "β Ingestion API tests passed!" | |
| else | |
| echo "β οΈ Test results not found in logs. Checking for service startup..." | |
| if docker compose logs ingestion | grep -q "Starting Ingestion service\|Running executable"; then | |
| echo "β Ingestion API service started successfully!" | |
| else | |
| echo "β Could not determine test status and service may not have started properly" | |
| docker compose down | |
| exit 1 | |
| fi | |
| fi | |
| # Cleanup - ensure complete cleanup for next CI run | |
| echo "π§Ή Final cleanup - removing all containers..." | |
| docker compose -f docker-compose.yml -f docker-compose.override.yml down --remove-orphans | |
| docker system prune -f |