docs: add comprehensive deployment pipeline architecture and optimiza… #55
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: Test Suite | |
| on: | |
| pull_request: | |
| branches: [develop, main] | |
| push: | |
| branches: [develop, main] | |
| env: | |
| NODE_VERSION: '20' # 18 is fine; 20 is current LTS | |
| PYTHON_VERSION: '3.11' # 3.9 is old; bump if you can | |
| jobs: | |
| frontend-tests: | |
| name: Frontend (lint/type/unit/build) | |
| runs-on: ubuntu-latest | |
| if: ${{ github.event_name == 'pull_request' || github.event_name == 'push' }} | |
| # Only run if frontend changed | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Skip if frontend untouched | |
| id: changes | |
| uses: dorny/paths-filter@v3 | |
| with: | |
| filters: | | |
| frontend: | |
| - 'frontend/**' | |
| - name: Setup Node | |
| if: steps.changes.outputs.frontend == 'true' | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| cache: 'npm' | |
| cache-dependency-path: frontend/package-lock.json | |
| - name: Install deps | |
| if: steps.changes.outputs.frontend == 'true' | |
| working-directory: frontend | |
| run: npm ci | |
| - name: Lint | |
| if: steps.changes.outputs.frontend == 'true' | |
| working-directory: frontend | |
| run: npm run lint | |
| - name: Typecheck | |
| if: steps.changes.outputs.frontend == 'true' | |
| working-directory: frontend | |
| run: npm run typecheck | |
| - name: Build (no real secrets) | |
| if: steps.changes.outputs.frontend == 'true' | |
| working-directory: frontend | |
| env: | |
| # Dummy/public-safe values; your build should not need server secrets | |
| NEXT_PUBLIC_API_URL: http://localhost:9999 | |
| NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY: ${{ secrets.CLERK_PUBLISHABLE_KEY_CI_TEST }} | |
| CLERK_SECRET_KEY: dummy | |
| run: npm run build | |
| backend-tests: | |
| name: Backend (unit + coverage) | |
| runs-on: ubuntu-latest | |
| # Only run if backend changed | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Skip if backend untouched | |
| id: changes | |
| uses: dorny/paths-filter@v3 | |
| with: | |
| filters: | | |
| backend: | |
| - 'backend/**' | |
| - name: Setup Python | |
| if: steps.changes.outputs.backend == 'true' | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| - name: Install uv | |
| if: steps.changes.outputs.backend == 'true' | |
| run: curl -LsSf https://astral.sh/uv/install.sh | sh | |
| - name: Test | |
| if: steps.changes.outputs.backend == 'true' | |
| working-directory: backend | |
| env: | |
| DATABASE_URI: mongodb://localhost:27017 | |
| DATABASE_NAME: autoauthor_test | |
| OPENAI_AUTOAUTHOR_API_KEY: test-key | |
| CLERK_API_KEY: test-key | |
| CLERK_JWT_PUBLIC_KEY: test | |
| CLERK_FRONTEND_API: https://example.dev | |
| CLERK_BACKEND_API: https://api.clerk.dev | |
| ENVIRONMENT: test | |
| run: | | |
| # Prefer uv run to avoid manual venv activation | |
| $HOME/.cargo/bin/uv run pip install -r requirements.txt | |
| $HOME/.cargo/bin/uv run pip install pytest pytest-cov | |
| docker run -d --name mongo -p 27017:27017 --health-cmd="mongosh --eval 'db.runCommand({ping:1})'" --health-interval=10s --health-timeout=5s --health-retries=5 mongo:6 | |
| # wait for healthy | |
| for i in {1..20}; do docker inspect --format='{{json .State.Health.Status}}' mongo | grep -q healthy && break || sleep 2; done | |
| $HOME/.cargo/bin/uv run pytest tests/ \ | |
| --cov=app --cov-report=term-missing --cov-report=xml:coverage.xml \ | |
| --ignore=tests/test_debug_chapter_questions.py \ | |
| --ignore=tests/test_debug_questions.py \ | |
| --ignore=tests/test_e2e_no_mocks.py \ | |
| -k "not test_generate_toc_endpoint and not test_toc_generation_workflow_e2e" | |
| - name: Upload coverage | |
| if: steps.changes.outputs.backend == 'true' | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| files: backend/coverage.xml | |
| flags: backend | |
| e2e-tests: | |
| name: E2E (staging) | |
| runs-on: ubuntu-latest | |
| needs: [frontend-tests, backend-tests] | |
| if: github.event_name == 'push' && (github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/main') | |
| environment: | |
| name: staging | |
| url: https://dev.autoauthor.app | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| cache: 'npm' | |
| cache-dependency-path: frontend/package-lock.json | |
| - name: Install deps | |
| working-directory: frontend | |
| run: npm ci | |
| - name: Install Playwright (chromium only) | |
| run: npx playwright install --with-deps chromium | |
| - name: Run E2E against staging | |
| working-directory: frontend | |
| env: | |
| NEXT_PUBLIC_API_URL: https://api.dev.autoauthor.app/api/v1 | |
| NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY: ${{ secrets.CLERK_PUBLISHABLE_KEY }} | |
| CLERK_SECRET_KEY: ${{ secrets.CLERK_SECRET_KEY }} | |
| run: npx playwright test --reporter=line | |
| - name: Upload Playwright report (on failure) | |
| if: failure() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: playwright-report | |
| path: frontend/playwright-report/ | |
| retention-days: 7 |