E2E test #1
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: E2E Cat App Test | |
| on: | |
| push: | |
| branches: ['main'] | |
| pull_request: | |
| branches: ['main'] | |
| env: | |
| # Using the same local DB credentials as in docker-compose.yml | |
| # These will be used by the PostgreSQL service and the application | |
| POSTGRES_USER: manicode_user_local | |
| POSTGRES_PASSWORD: secretpassword_local | |
| POSTGRES_DB: manicode_db_local | |
| # Ensure the application connects to the service container | |
| DATABASE_URL: postgres://manicode_user_local:secretpassword_local@localhost:5432/manicode_db_local | |
| # Set environment to local to avoid production database requirements for the script | |
| NEXT_PUBLIC_CB_ENVIRONMENT: 'local' | |
| # Disable BigQuery for testing, as seen in e2e-cat-app-script.ts | |
| DISABLE_BIGQUERY: 'true' | |
| # Port for the backend service started by the E2E script | |
| PORT: 3001 | |
| # Backend URL for the CLI started by the E2E script | |
| CODEBUFF_BACKEND_URL: http://localhost:3001 | |
| # NEXTAUTH_SECRET for the seeding script | |
| NEXTAUTH_SECRET: ${{ secrets.NEXTAUTH_SECRET_E2E_TEST }} # Use a dedicated secret for this | |
| jobs: | |
| e2e-test: | |
| runs-on: ubuntu-latest | |
| services: | |
| postgres: | |
| image: postgres:16 | |
| env: | |
| POSTGRES_USER: ${{ env.POSTGRES_USER }} | |
| POSTGRES_PASSWORD: ${{ env.POSTGRES_PASSWORD }} | |
| POSTGRES_DB: ${{ env.POSTGRES_DB }} | |
| ports: | |
| - 5432:5432 | |
| # Options to ensure the service is healthy before proceeding | |
| options: >- | |
| --health-cmd pg_isready | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| - name: Set up Bun | |
| uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: '1.2.12' # Using version from ci.yml | |
| - name: Cache dependencies | |
| uses: actions/cache@v3 | |
| with: | |
| path: | | |
| node_modules | |
| */node_modules | |
| packages/*/node_modules | |
| key: ${{ runner.os }}-deps-${{ hashFiles('**/bun.lockb') }} | |
| restore-keys: | | |
| ${{ runner.os }}-deps- | |
| - name: Install dependencies | |
| run: bun install --frozen-lockfile | |
| - name: Wait for PostgreSQL to be ready | |
| run: | | |
| echo "Waiting for PostgreSQL to start..." | |
| until pg_isready -h localhost -p 5432 -U ${{ env.POSTGRES_USER }}; do | |
| sleep 1 | |
| done | |
| echo "PostgreSQL is ready." | |
| - name: Run database migrations | |
| run: bun --cwd common db:migrate | |
| env: | |
| # Drizzle Kit needs the DATABASE_URL | |
| DATABASE_URL: ${{ env.DATABASE_URL }} | |
| - name: Seed test user | |
| run: bun evals/e2e/seed-test-user.ts | |
| env: | |
| DATABASE_URL: ${{ env.DATABASE_URL }} | |
| NEXTAUTH_SECRET: ${{ env.NEXTAUTH_SECRET }} | |
| - name: Run E2E Cat App Test Script | |
| run: bun evals/e2e/e2e-cat-app-script.ts | |
| # The script has its own timeouts, but we can add a general timeout for the step | |
| timeout-minutes: 5 # Adjust as needed, the script itself has a 2-minute task timeout + setup time |