Skip to content

Add Playwright boilerplate #1296

Add Playwright boilerplate

Add Playwright boilerplate #1296

Workflow file for this run

name: Build, TypeScripts, tests
on:
push:
branches: [canary]
pull_request:
branches: [canary]
concurrency:
group: tests-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
build_and_test:
runs-on: ubuntu-latest
env:
NEXT_PUBLIC_SALEOR_API_URL: ${{ vars.NEXT_PUBLIC_SALEOR_API_URL }}
steps:
- uses: actions/checkout@v4
- name: Get PNPM version from package.json
id: pnpm-version
run: echo "pnpm_version=$(cat package.json | jq '.engines.pnpm' | sed -E 's/[^0-9.]//g')" >> $GITHUB_OUTPUT
- name: Get Playwright version
id: playwright-version
run: echo "playwright_version=$(cat package.json | jq '.devDependencies.[\"@playwright/test\"]')" >> $GITHUB_ENV
- uses: actions/cache@v3
name: Playwright Cache
id: playwright-cache
with:
path: |
~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ steps.playwright-version.outputs.playwright_version }}
- name: Install PNPM
uses: pnpm/action-setup@v2
with:
version: ${{ steps.pnpm-version.outputs.pnpm_version }}
- uses: actions/setup-node@v3
with:
node-version-file: package.json
cache: "pnpm"
- name: Install dependencies
run: pnpm --version && pnpm install --frozen-lockfile
- run: pnpm exec playwright install --with-deps
if: steps.playwright-cache.outputs.cache-hit != 'true'
- run: pnpm exec playwright install-deps
if: steps.playwright-cache.outputs.cache-hit == 'true'
- uses: actions/cache@v3
name: Next.js cache
with:
path: |
${{ github.workspace }}/.next/cache
key: |
${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}
- name: Build
run: pnpm run build
- name: Run Playwright tests
run: pnpm exec playwright test
- uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30