Fix lint error in campaign orchestrator #105
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: Full Test Suite | |
| on: | |
| pull_request: | |
| branches: [ main ] | |
| push: | |
| branches: [ '**' ] | |
| paths: | |
| - 'src/**' | |
| - 'tests/**' | |
| - 'services/**' | |
| - 'docker-compose.yml' | |
| - 'Dockerfile' | |
| - 'pyproject.toml' | |
| - '.github/workflows/full-test-suite.yaml' | |
| workflow_dispatch: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| jobs: | |
| docker-image-targets: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Build base orchestrator image target | |
| run: docker build --target runner -t campaign-orchestrator-base:test . | |
| - name: Build full orchestrator image target | |
| run: docker build --target full -t campaign-orchestrator-full:test . | |
| - name: Test base and full image dependencies | |
| run: | | |
| docker run --rm campaign-orchestrator-base:test python -c "import intersect_orchestrator" | |
| docker run --rm campaign-orchestrator-full:test python -c "import intersect_orchestrator, pymongo, psycopg" | |
| full-tests: | |
| runs-on: ubuntu-latest | |
| needs: docker-image-targets | |
| services: | |
| broker: | |
| image: rabbitmq:3-management-alpine | |
| ports: | |
| - 5672:5672 | |
| - 15672:15672 | |
| env: | |
| RABBITMQ_DEFAULT_USER: intersect_username | |
| RABBITMQ_DEFAULT_PASS: intersect_password | |
| options: >- | |
| --health-cmd="rabbitmq-diagnostics ping" | |
| --health-interval=10s | |
| --health-timeout=10s | |
| --health-retries=5 | |
| mongo: | |
| image: mongo:7.0 | |
| ports: | |
| - 27017:27017 | |
| env: | |
| MONGO_INITDB_ROOT_USERNAME: intersect | |
| MONGO_INITDB_ROOT_PASSWORD: intersect | |
| options: >- | |
| --health-cmd="mongosh --eval 'db.adminCommand(\"ping\")'" | |
| --health-interval=10s | |
| --health-timeout=10s | |
| --health-retries=5 | |
| postgres: | |
| image: postgres:16 | |
| ports: | |
| - 5432:5432 | |
| env: | |
| POSTGRES_USER: intersect | |
| POSTGRES_PASSWORD: intersect | |
| POSTGRES_DB: intersect_orchestrator | |
| options: >- | |
| --health-cmd="pg_isready -U intersect -d intersect_orchestrator" | |
| --health-interval=10s | |
| --health-timeout=10s | |
| --health-retries=5 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.13' | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v3 | |
| with: | |
| version: "latest" | |
| - name: Install system dependencies | |
| run: sudo apt-get update && sudo apt-get install -y libpq-dev | |
| - name: Install dependencies with DB extras | |
| run: uv sync --dev --extra mongo --extra postgres | |
| - name: Build and start random-number-service | |
| run: | | |
| docker build -t random-number-service ./services/random_number_service/ | |
| docker run -d --name rng-service \ | |
| --network host \ | |
| -e BROKER_HOST=localhost \ | |
| -e BROKER_PORT=5672 \ | |
| -e BROKER_USERNAME=intersect_username \ | |
| -e BROKER_PASSWORD=intersect_password \ | |
| -e BROKER_PROTOCOL=amqp0.9.1 \ | |
| random-number-service | |
| # Give the service time to connect to the broker | |
| sleep 15 | |
| - name: Run integration tests with coverage | |
| env: | |
| BROKER_HOST: localhost | |
| BROKER_PORT: 5672 | |
| BROKER_USERNAME: intersect_username | |
| BROKER_PASSWORD: intersect_password | |
| BROKER_PROTOCOL: amqp0.9.1 | |
| CAMPAIGN_REPOSITORY_MONGO_URI: mongodb://intersect:intersect@localhost:27017 | |
| CAMPAIGN_REPOSITORY_MONGO_DB: intersect_orchestrator | |
| CAMPAIGN_REPOSITORY_POSTGRES_DSN: postgresql://intersect:intersect@localhost:5432/intersect_orchestrator | |
| RANDOM_NUMBER_SERVICE_AVAILABLE: "true" | |
| run: uv run pytest tests/integration --cov=intersect_orchestrator --cov-report=term-missing --cov-report=html | |
| - name: Upload coverage HTML report | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: coverage-report | |
| path: htmlcov/ | |
| full-tests-docker-compose: | |
| if: github.event_name == 'pull_request' || github.ref == 'refs/heads/main' | |
| runs-on: ubuntu-latest | |
| needs: docker-image-targets | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.13' | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v3 | |
| with: | |
| version: "latest" | |
| - name: Install system dependencies | |
| run: sudo apt-get update && sudo apt-get install -y libpq-dev | |
| - name: Install dependencies with DB extras | |
| run: uv sync --dev --extra mongo --extra postgres | |
| - name: Start services with docker-compose | |
| run: docker compose up -d | |
| - name: Wait for services to be healthy | |
| run: | | |
| # Wait specifically for the orchestrator to become healthy. | |
| # The orchestrator depends on broker + mongo + postgres being healthy | |
| # before it starts, so waiting for it implies all backing services are | |
| # ready. The random-number-service also starts after the broker is | |
| # healthy, so it will be connected before the orchestrator finishes its | |
| # own startup sequence. | |
| timeout 120 bash -c 'until docker compose ps | grep -w orchestrator | grep -q "(healthy)"; do sleep 2; done' | |
| docker compose ps | |
| - name: Run integration tests with coverage | |
| env: | |
| API_KEY: test-api-key-12345678901234567890 | |
| BROKER_HOST: localhost | |
| BROKER_PORT: 5672 | |
| BROKER_USERNAME: intersect_username | |
| BROKER_PASSWORD: intersect_password | |
| BROKER_PROTOCOL: amqp0.9.1 | |
| CAMPAIGN_REPOSITORY_MONGO_URI: mongodb://intersect:intersect@localhost:27017 | |
| CAMPAIGN_REPOSITORY_MONGO_DB: intersect_orchestrator | |
| CAMPAIGN_REPOSITORY_POSTGRES_DSN: postgresql://intersect:intersect@localhost:5432/intersect_orchestrator | |
| ORCHESTRATOR_HOST: localhost | |
| ORCHESTRATOR_PORT: 8000 | |
| run: uv run pytest tests/integration --cov=intersect_orchestrator --cov-report=term-missing --cov-report=html | |
| - name: Show docker-compose logs on failure | |
| if: failure() | |
| run: docker compose logs | |
| - name: Cleanup docker-compose | |
| if: always() | |
| run: docker compose down -v | |
| - name: Upload coverage HTML report | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: coverage-report-docker-compose | |
| path: htmlcov/ |