e2e.yml 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. name: End-to-end tests
  2. on:
  3. pull_request:
  4. branches: [main]
  5. workflow_dispatch:
  6. # A second push to the same branch makes the run in flight pointless.
  7. concurrency:
  8. group: e2e-${{ github.ref }}
  9. cancel-in-progress: true
  10. jobs:
  11. e2e:
  12. name: Playwright
  13. runs-on: ubuntu-latest
  14. timeout-minutes: 45
  15. services:
  16. postgres:
  17. image: postgres:16-alpine
  18. env:
  19. POSTGRES_USER: torqvoice
  20. POSTGRES_PASSWORD: torqvoice
  21. # The name has to carry "e2e" or "test": the harness refuses to reset
  22. # a database whose name says nothing about being throwaway.
  23. POSTGRES_DB: torqvoice_e2e
  24. ports:
  25. - 5432:5432
  26. options: >-
  27. --health-cmd "pg_isready -U torqvoice -d torqvoice_e2e"
  28. --health-interval 10s
  29. --health-timeout 5s
  30. --health-retries 5
  31. env:
  32. # Playwright starts the app itself on this port and resets this database
  33. # before it does; both come from playwright.config.ts.
  34. E2E_DATABASE_URL: postgresql://torqvoice:torqvoice@127.0.0.1:5432/torqvoice_e2e
  35. steps:
  36. - uses: actions/checkout@v4
  37. - uses: actions/setup-node@v4
  38. with:
  39. node-version: 22
  40. cache: npm
  41. # A fresh one per run: the sessions it signs live as long as the job, and
  42. # a short or guessable value makes better-auth warn on every request.
  43. - name: Make a session secret for this run
  44. run: echo "BETTER_AUTH_SECRET=$(openssl rand -base64 32)" >> "$GITHUB_ENV"
  45. - run: npm ci
  46. - run: npx prisma generate
  47. # Keyed on the pinned version, because the image tag and this download
  48. # have to be the same build.
  49. - name: Cache the browser
  50. id: browser-cache
  51. uses: actions/cache@v4
  52. with:
  53. path: ~/.cache/ms-playwright
  54. key: playwright-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
  55. - name: Install the browser
  56. run: npx playwright install --with-deps chromium
  57. # The seed copies bundled vehicle photos when they are in the tree and
  58. # downloads fifty of them from Unsplash when they are not, one after
  59. # another, which is minutes of a cold run and the flakiest thing in it.
  60. # Cached, a warm run copies them off disk instead.
  61. - name: Cache the seed's photos
  62. uses: actions/cache@v4
  63. with:
  64. # Where prepare-db.ts points the seed's DATA_ROOT, so a test run
  65. # cannot disturb a running instance's own uploads.
  66. path: e2e/.data
  67. key: seed-photos-${{ hashFiles('prisma/seed_dummy_data.ts') }}
  68. restore-keys: |
  69. seed-photos-
  70. # Next reuses its compiler cache across builds when it is given one.
  71. - name: Cache the build
  72. uses: actions/cache@v4
  73. with:
  74. path: .next/cache
  75. key: next-${{ hashFiles('package-lock.json') }}-${{ github.sha }}
  76. restore-keys: |
  77. next-${{ hashFiles('package-lock.json') }}-
  78. next-
  79. # NEXT_PUBLIC_APP_URL is baked into the client bundle, and better-auth
  80. # refuses a sign-in from an origin the build was not made for, so it has
  81. # to match the base URL the suite uses.
  82. - name: Build
  83. run: npm run build
  84. env:
  85. NEXT_PUBLIC_APP_URL: http://127.0.0.1:3100
  86. - name: Run the suite
  87. run: npm run test:e2e
  88. - name: Upload the report
  89. if: ${{ !cancelled() }}
  90. uses: actions/upload-artifact@v4
  91. with:
  92. name: playwright-report
  93. path: |
  94. playwright-report/
  95. test-results/
  96. retention-days: 7
  97. if-no-files-found: ignore