Hopefully fix e2e tests on CI #5
This file contains 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, master] | |
pull_request: | |
branches: [main, master] | |
jobs: | |
generate-test-run-id: | |
name: Generate Test Run ID | |
runs-on: ubuntu-latest | |
steps: | |
- run: yarn add uuid | |
shell: sh | |
- uses: actions/github-script@v6 | |
id: uuid | |
with: | |
result-encoding: string | |
script: return require("uuid").v4() | |
outputs: | |
testRunId: ${{ steps.uuid.outputs.result }} | |
preview-branch: | |
name: Wait for Vercel Preview Branch | |
runs-on: ubuntu-latest | |
steps: | |
- name: Waiting for 200 from the Vercel Preview | |
uses: patrickedqvist/[email protected] | |
id: waitFor200 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
max_timeout: 960 | |
check_interval: 60 | |
environment: ${{ fromJSON('["", "production"]')[github.ref == 'refs/heads/main'] }} | |
outputs: | |
url: ${{ steps.waitFor200.outputs.url }} | |
e2e-test: | |
name: Playwright e2e tests | |
needs: [preview-branch] | |
timeout-minutes: 60 | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: lts/* | |
- name: Install dependencies | |
run: npm install -g pnpm && pnpm install | |
- name: Install Playwright Browsers | |
run: pnpm exec playwright install --with-deps | |
- name: Run Playwright tests | |
run: pnpm test:e2e | |
env: | |
NEXT_PUBLIC_APP_URL: ${{ needs.preview-branch.outputs.url }} | |
RECORD_REPLAY_TEST_RUN_ID: ${{ needs.generate-test-run-id.outputs.testRunId }} | |
- uses: actions/upload-artifact@v4 | |
if: always() | |
with: | |
name: playwright-report | |
path: playwright-report/ | |
retention-days: 30 | |
unit-test: | |
name: Unit Tests | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "16" | |
- name: Install dependencies | |
run: npm install -g pnpm && pnpm install | |
- name: Run tests | |
run: pnpm test |