Integration Tests #23
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: Integration Tests | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - 'app/**' | |
| - 'worker/**' | |
| - 'tests/integration/**' | |
| - 'sql/**' | |
| - 'requirements.txt' | |
| - '.github/workflows/integration-tests.yml' | |
| pull_request: | |
| paths: | |
| - 'app/**' | |
| - 'worker/**' | |
| - 'tests/integration/**' | |
| - 'sql/**' | |
| - 'requirements.txt' | |
| - '.github/workflows/integration-tests.yml' | |
| workflow_dispatch: | |
| schedule: | |
| # Run nightly at 2 AM UTC | |
| - cron: '0 2 * * *' | |
| permissions: | |
| contents: read | |
| jobs: | |
| integration-tests: | |
| name: Integration Tests | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 30 | |
| permissions: | |
| contents: read | |
| actions: read | |
| services: | |
| postgres: | |
| image: postgres:16 | |
| env: | |
| POSTGRES_USER: postgres | |
| POSTGRES_PASSWORD: postgres | |
| POSTGRES_DB: postgres | |
| ports: | |
| - 5432:5432 | |
| options: >- | |
| --health-cmd pg_isready | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python 3.11 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| cache: 'pip' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements-dev.txt | |
| pip install -r requirements.txt | |
| - name: Apply database schema | |
| env: | |
| DATABASE_URL: postgresql://postgres:postgres@localhost:5432/postgres | |
| run: | | |
| PGPASSWORD=postgres psql -h localhost -U postgres -d postgres -f sql/schema.sql | |
| - name: Run integration tests | |
| env: | |
| DATABASE_URL: postgresql://postgres:postgres@localhost:5432/postgres | |
| SESSION_SECRET: test-secret-key-for-ci-only | |
| FRONTEND_ORIGIN: http://localhost:5173 | |
| PYTEST_TIMEOUT: 300 | |
| run: | | |
| pytest tests/integration/ \ | |
| -v \ | |
| --tb=short \ | |
| --timeout=120 \ | |
| --maxfail=5 \ | |
| -x | |
| - name: Generate test summary | |
| if: always() | |
| run: | | |
| echo "## Integration Test Results" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "Integration tests completed." >> $GITHUB_STEP_SUMMARY | |
| - name: Upload test logs on failure | |
| if: failure() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: integration-test-logs | |
| path: | | |
| *.log | |
| /tmp/*.log | |
| retention-days: 7 | |
| if-no-files-found: ignore | |
| integration-tests-with-services: | |
| name: Integration Tests (Full Stack) | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 45 | |
| permissions: | |
| contents: read | |
| actions: read | |
| # Only run full stack tests on schedule or manual trigger | |
| if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python 3.11 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| cache: 'pip' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements-dev.txt | |
| pip install -r requirements.txt | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: ./Dockerfile | |
| push: false | |
| tags: transcript-create:test | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| build-args: | | |
| ROCM_WHEEL_INDEX=https://download.pytorch.org/whl/cpu | |
| - name: Create test environment file | |
| run: | | |
| cat > .env << EOF | |
| DATABASE_URL=postgresql+psycopg://postgres:postgres@db:5432/transcripts | |
| SESSION_SECRET=test-secret-key-for-ci-only | |
| FRONTEND_ORIGIN=http://localhost:5173 | |
| WHISPER_MODEL=base | |
| WHISPER_BACKEND=faster-whisper | |
| LOG_LEVEL=INFO | |
| EOF | |
| - name: Start services | |
| run: | | |
| docker compose up -d db migrations | |
| sleep 10 | |
| - name: Wait for database | |
| run: | | |
| for i in {1..30}; do | |
| PGPASSWORD=postgres psql -h localhost -U postgres -p 5434 -d transcripts -c "SELECT 1" && break | |
| echo "Waiting for database..." | |
| sleep 2 | |
| done | |
| - name: Run integration tests against services | |
| env: | |
| DATABASE_URL: postgresql://postgres:postgres@localhost:5434/transcripts | |
| SESSION_SECRET: test-secret-key-for-ci-only | |
| FRONTEND_ORIGIN: http://localhost:5173 | |
| run: | | |
| pytest tests/integration/ \ | |
| -v \ | |
| --tb=short \ | |
| --timeout=180 \ | |
| --maxfail=5 | |
| - name: Collect service logs on failure | |
| if: failure() | |
| run: | | |
| docker compose logs db > db.log | |
| docker compose logs api > api.log || true | |
| docker compose logs worker > worker.log || true | |
| - name: Upload service logs | |
| if: failure() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: service-logs | |
| path: | | |
| *.log | |
| retention-days: 7 | |
| - name: Cleanup | |
| if: always() | |
| run: | | |
| docker compose down -v | |
| test-summary: | |
| name: Integration Test Summary | |
| runs-on: ubuntu-latest | |
| needs: [integration-tests] | |
| if: always() | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Generate summary | |
| run: | | |
| echo "# Integration Test Summary" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "✅ Integration tests completed" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "See individual job results above for details." >> $GITHUB_STEP_SUMMARY |