Merge pull request #468 from JeremyLoh/frontend #590
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: | |
playwright-tests: | |
timeout-minutes: 60 | |
defaults: | |
run: | |
working-directory: frontend | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
shardIndex: [1, 2, 3] | |
shardTotal: [3] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: lts/* | |
- name: Create envfile | |
run: | | |
echo "VITE_MAX_FAVOURITE_STATIONS_ANONYMOUS=${{ secrets.VITE_MAX_FAVOURITE_STATIONS_ANONYMOUS }}" >> .env.local | |
echo "VITE_BACKEND_ORIGIN='http://localhost:3000'" >> .env.local | |
echo "VITE_FRONTEND_ORIGIN='http://localhost:5173'" >> .env.local | |
- name: Install dependencies | |
run: npm ci | |
- name: Install Playwright Browsers | |
run: npx playwright install --with-deps | |
- name: Run Playwright tests | |
run: npx playwright test --reporter=blob --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }} | |
- name: Upload blob report to GitHub Actions Artifacts | |
if: ${{ !cancelled() }} | |
uses: actions/upload-artifact@v4 | |
with: | |
# use default blob-report name - https://playwright.dev/docs/test-reporters#blob-reporter | |
# upload-artifact action does not use "working-directory" path. Needs to be relative path from root - https://github.com/actions/upload-artifact/issues/232 | |
name: blob-report-${{ matrix.shardIndex }} | |
path: frontend/blob-report | |
retention-days: 1 | |
merge-reports: | |
# Merge reports after playwright-tests, even if some shards have failed | |
if: ${{ !cancelled() }} | |
needs: [playwright-tests] | |
defaults: | |
run: | |
working-directory: frontend | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: lts/* | |
- name: Install dependencies | |
run: npm ci | |
- name: Download blob reports from GitHub Actions Artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: frontend/blob-report | |
pattern: blob-report-* | |
merge-multiple: true | |
- name: Merge into HTML Report | |
run: npx playwright merge-reports --reporter html ./blob-report | |
- name: Upload HTML report | |
uses: actions/upload-artifact@v4 | |
with: | |
name: html-report--attempt-${{ github.run_attempt }} | |
path: frontend/playwright-report | |
retention-days: 14 |