Nightly Integration Tests #167
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: Nightly Integration Tests | |
| on: | |
| schedule: | |
| # Run every day at 2 AM UTC | |
| - cron: '0 2 * * *' | |
| workflow_dispatch: # Allow manual trigger | |
| jobs: | |
| integration-tests: | |
| name: Backend Integration Tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Node.js and pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 8 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'pnpm' | |
| cache-dependency-path: 'webapp/pnpm-lock.yaml' | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.10' | |
| - name: Install Node.js dependencies | |
| working-directory: ./webapp | |
| run: pnpm install | |
| - name: Install Python dependencies | |
| working-directory: ./webapp/packages/api/user-service | |
| run: pip install -r requirements.txt | |
| - name: Create .env file for Docker Compose | |
| working-directory: ./webapp/infra/docker | |
| run: | | |
| echo "OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }}" >> .env | |
| echo "GEMINI_API_KEY=${{ secrets.GEMINI_API_KEY }}" >> .env | |
| echo "AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }}" >> .env | |
| echo "AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }}" >> .env | |
| echo "AWS_REGION=${{ secrets.AWS_REGION || 'us-east-1' }}" >> .env | |
| env: | |
| OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | |
| GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }} | |
| AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| AWS_REGION: ${{ secrets.AWS_REGION }} | |
| - name: Start services with Docker Compose | |
| working-directory: ./webapp/infra/docker | |
| run: docker compose up -d --build | |
| - name: Wait for services to be healthy | |
| run: | | |
| echo "Waiting for API server to be ready..." | |
| timeout 120s bash -c 'until curl -s http://localhost:8000/health | grep -q "healthy"; do sleep 2; done' | |
| echo "API server is up." | |
| echo "Waiting for Web UI to be ready..." | |
| timeout 60s bash -c 'until curl -s -o /dev/null http://localhost:3000; do sleep 2; done' | |
| echo "Web UI is up." | |
| echo "Waiting for CouchDB to be ready..." | |
| timeout 60s bash -c 'until curl -s -o /dev/null http://localhost:5984; do sleep 2; done' | |
| echo "CouchDB is up." | |
| echo "Waiting for MinIO to be ready..." | |
| timeout 60s bash -c 'until curl -s -o /dev/null http://localhost:9000; do sleep 2; done' | |
| echo "MinIO is up." | |
| - name: Run backend integration tests | |
| working-directory: ./webapp/packages/api/user-service | |
| run: python -m pytest tests/integration -v --cov=. --cov-report=xml --cov-report=term-missing | |
| env: | |
| OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | |
| GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }} | |
| AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| AWS_REGION: ${{ secrets.AWS_REGION }} | |
| - name: Upload integration test coverage | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| files: ./webapp/packages/api/user-service/coverage.xml | |
| flags: integration | |
| name: integration-coverage | |
| - name: Collect Docker logs on failure | |
| if: failure() | |
| working-directory: ./webapp/infra/docker | |
| run: | | |
| echo "=== API Logs ===" | |
| docker compose logs api | |
| echo "=== WebUI Logs ===" | |
| docker compose logs webui | |
| echo "=== CouchDB Logs ===" | |
| docker compose logs couchdb | |
| echo "=== MinIO Logs ===" | |
| docker compose logs minio | |
| - name: Stop services | |
| if: always() | |
| working-directory: ./webapp/infra/docker | |
| run: docker compose down -v | |
| e2e-tests: | |
| name: End-to-End Tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Node.js and pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 8 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'pnpm' | |
| cache-dependency-path: 'webapp/pnpm-lock.yaml' | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.10' | |
| - name: Install Node.js dependencies | |
| working-directory: ./webapp | |
| run: pnpm install | |
| - name: Install Python dependencies | |
| working-directory: ./webapp/packages/api/user-service | |
| run: pip install -r requirements.txt | |
| - name: Install Playwright Browsers | |
| working-directory: ./webapp | |
| run: pnpm exec playwright install --with-deps chromium | |
| - name: Create .env file for Docker Compose | |
| working-directory: ./webapp/infra/docker | |
| run: | | |
| echo "OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }}" >> .env | |
| echo "GEMINI_API_KEY=${{ secrets.GEMINI_API_KEY }}" >> .env | |
| echo "AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }}" >> .env | |
| echo "AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }}" >> .env | |
| env: | |
| OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | |
| GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }} | |
| AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| - name: Start services with Docker Compose | |
| working-directory: ./webapp/infra/docker | |
| run: docker compose up -d --build | |
| - name: Wait for services to be healthy | |
| run: | | |
| echo "Waiting for API server to be ready..." | |
| timeout 120s bash -c 'until curl -s http://localhost:8000/health | grep -q "healthy"; do sleep 2; done' | |
| echo "API server is up." | |
| echo "Waiting for Web UI to be ready..." | |
| timeout 60s bash -c 'until curl -s -o /dev/null http://localhost:3000; do sleep 2; done' | |
| echo "Web UI is up." | |
| - name: Run Playwright E2E Tests | |
| working-directory: ./webapp | |
| run: pnpm test:e2e | |
| env: | |
| OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | |
| GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }} | |
| - name: Upload Playwright report | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: playwright-report | |
| path: webapp/playwright-report/ | |
| retention-days: 30 | |
| - name: Collect Docker logs on failure | |
| if: failure() | |
| working-directory: ./webapp/infra/docker | |
| run: | | |
| echo "=== API Logs ===" | |
| docker compose logs api | |
| echo "=== WebUI Logs ===" | |
| docker compose logs webui | |
| - name: Stop services | |
| if: always() | |
| working-directory: ./webapp/infra/docker | |
| run: docker compose down -v | |
| notify-on-failure: | |
| name: Notify on Failure | |
| runs-on: ubuntu-latest | |
| needs: [integration-tests, e2e-tests] | |
| if: failure() | |
| steps: | |
| - name: Send notification | |
| run: | | |
| echo "Nightly tests failed. Please check the GitHub Actions logs." | |
| echo "Integration tests: ${{ needs.integration-tests.result }}" | |
| echo "E2E tests: ${{ needs.e2e-tests.result }}" |