test: add E2E tests using Playwright #7
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: Playwright Tests | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| jobs: | |
| test: | |
| timeout-minutes: 60 | |
| runs-on: self-hosted | |
| # We use different ports than the defaults because they are busy on our VM | |
| env: | |
| FRONTEND_PORT: 5174 | |
| BACKEND_PORT: 3002 | |
| DATABASE_URL: postgresql://postgres@127.0.0.1:5434/readr | |
| BETTER_AUTH_SECRET: e2e-test-secret-do-not-use-in-production | |
| SEED_BOOK_LIMIT: 5000 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: lts/* | |
| - name: Install pnpm | |
| run: npm install -g pnpm | |
| - name: Install frontend dependencies | |
| run: pnpm install | |
| - name: Install backend dependencies | |
| working-directory: backend | |
| run: pnpm install | |
| - name: Set up test database | |
| working-directory: backend | |
| # We have the seed data available at ~/ci-data/book-data.csv on the self-hosted runner | |
| run: | | |
| initdb -D db-data -U postgres -E UTF8 --auth=trust | |
| pg_ctl -D db-data -l db-data/db-data.log -w -o "-p 5434 -c listen_addresses=127.0.0.1" start | |
| createdb -h 127.0.0.1 -p 5434 -U postgres readr | |
| cp ~/ci-data/book-data.csv src/db/seed/ | |
| pnpm db:migrate | |
| pnpm db:seed | |
| - name: Install Playwright Browsers | |
| # System dependencies installed once manually so we do not need sudo in CI | |
| run: pnpm exec playwright install | |
| - name: Run Playwright tests | |
| run: pnpm exec playwright test | |
| - uses: actions/upload-artifact@v4 | |
| if: ${{ !cancelled() }} | |
| with: | |
| name: playwright-report | |
| path: frontend/playwright-report/ | |
| retention-days: 30 | |
| - name: Stop and delete test database | |
| if: always() | |
| working-directory: backend | |
| run: | | |
| pg_ctl -D db-data stop || true | |
| rm -rf db-data | |
| defaults: | |
| run: | |
| working-directory: frontend |