Choices/.github/workflows/browsers.yml

102 lines
No EOL
3.3 KiB
YAML

name: End-to-end tests (playwright)
on:
push:
branches: [ playwright ]
pull_request:
branches: [ main, master ]
jobs:
test-e2e-playwright:
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
os: [windows-latest, macos-latest, ubuntu-latest]
browser: [chromium, firefox, webkit]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
- uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
- name: Install dependencies
run: npm ci --no-audit
env:
HUSKY_SKIP_INSTALL: true
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
# https://github.com/microsoft/playwright/issues/7249#issuecomment-2301568516
# - name: Detect Playwright version (Windows)
# if: runner.os == 'windows'
# run: echo "PLAYWRIGHT_VERSION=$(npm ll -p --depth=0 playwright | grep -o '@.*')" | Out-File -FilePath $env:GITHUB_ENV -Append
- name: Detect Playwright version (Linux and Mac)
if: runner.os != 'windows'
run: echo "PLAYWRIGHT_VERSION=$(npm ll -p --depth=0 playwright | grep -o '@.*')" >> $GITHUB_ENV
- name: Put $HOME in env
if: runner.os == 'windows'
run: echo "HOME=$HOME" | Out-File -FilePath $env:GITHUB_ENV -Append
- name: Cache playwright binaries
uses: actions/cache@v4
id: playwright-cache
with:
# see https://playwright.dev/docs/browsers#managing-browser-binaries
path: ${{ runner.os == 'Windows' && format('{0}{1}', env.HOME, '\AppData\Local\ms-playwright') || runner.os == 'Linux' && '~/.cache/ms-playwright' || '~/Library/Caches/ms-playwright' }}
key: ${{ runner.os }}-playwright-${{ env.PLAYWRIGHT_VERSION }}
restore-keys: |
${{ runner.os }}-playwright-
- name: Install Playwright Browsers
run: npx playwright install --with-deps
if: steps.playwright-cache.outputs.cache-hit != 'true'
- run: npx playwright install-deps
if: steps.playwright-cache.outputs.cache-hit != 'true'
- name: Run Playwright tests
run: npx playwright test --project=${{ matrix.browser }}
- uses: actions/upload-artifact@v4
if: failure()
with:
name: screenshot-${{ matrix.os }}
path: test-results/**/*.png
- uses: actions/upload-artifact@v4
if: '!cancelled()'
with:
name: blob-report-${{ matrix.os }}-${{ matrix.browser }}
path: blob-report/
retention-days: 1
merge-reports:
# Merge reports after playwright-tests, even if some shards have failed
if: ${{ !cancelled() }}
needs: [test-e2e-playwright]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- name: Install dependencies
run: npm ci
- name: Download blob reports from GitHub Actions Artifacts
uses: actions/download-artifact@v4
with:
path: all-blob-reports
pattern: blob-report-*
merge-multiple: true
- name: Merge into HTML Report
run: npx playwright merge-reports --reporter html,github ./all-blob-reports
- name: Upload HTML report
uses: actions/upload-artifact@v4
with:
name: html-report--attempt-${{ github.run_attempt }}
path: playwright-report
retention-days: 30