Skip to content

Playwright

Playwright #115

name: Visual regression tests
on:
pull_request:
branches:
- main
jobs:
changes:
runs-on: ubuntu-latest
if: ${{ !contains(github.event.sender.login, 'fremtind-bot') }}
outputs:
visual: ${{ steps.changes.outputs.visual }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Check for changes that require running regression tests
if: ${{ github.event_name != 'merge_group' }}
uses: ./actions/paths-filter
id: changes
with:
filters: |
visual:
- "packages/jokul/src/**/*.spec.ts"
- "packages/jokul/src/**/*.scss"
- "packages/jokul/src/**/!(*.test).tsx"
- "pnpm-lock.yaml"
snapshots:
needs: changes
# if: needs.changes.outputs.visual == 'true'
runs-on: ubuntu-latest
permissions:
actions: write
contents: write
pull-requests: write
steps:
- name: debug
run: echo ${{ needs.changes.outputs.visual }}
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.ref }}
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18
cache: "pnpm"
- name: Monorepo Runner Cache
uses: actions/cache@v3
id: nx-cache
with:
path: .nx
key: nx-${{ hashFiles('pnpm-lock.yaml') }}-${{ github.sha }}
restore-keys: |
nx-${{ hashFiles('pnpm-lock.yaml') }}-
- name: Install dependencies and build packages
run: pnpm ci:install
- name: Playwright binary cache
uses: actions/cache@v3
id: playwright-cache
with:
path: /home/runner/.cache/ms-playwright
key: playwright-${{ hashFiles('pnpm-lock.yaml') }}
- name: Playwright binaries
run: pnpm exec playwright install --with-deps
- name: Update integration screenshots
run: node ./run-regression-tests.js
- name: Upload Playwright report on failure
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: playwright-report.tar.gz
path: playwright-report/
- name: Upload Playwright test-results on failure
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: test-results.tar.gz
path: test-results/
- name: Commit screenshots
run: |
git config user.email "[email protected]"
git config user.name "fremtind-bot"
git add **/integration/__screenshots__/* || echo "No updated screenshots, nothing to add!"
git commit -m "chore: update integration screenshots [playwright]" --no-verify || echo "No updated screenshots, nothing to commit!"
git push