90 lines
2.6 KiB
YAML
90 lines
2.6 KiB
YAML
name: Playwright Tests
|
|
on:
|
|
push:
|
|
branches: [ trunk ]
|
|
pull_request:
|
|
|
|
jobs:
|
|
PlaywrightE2ETests:
|
|
|
|
name: Playwright E2E tests - ${{ matrix.config.name }}
|
|
timeout-minutes: 60
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
config: [
|
|
{ name: Normal, file: playwright.config.ts, resultPath: test-results },
|
|
{ name: SideEffects, file: playwright.side-effects.config.ts, resultPath: test-results-side-effects },
|
|
]
|
|
steps:
|
|
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: Cache node_modules
|
|
id: cache-node-modules
|
|
uses: actions/cache@v3
|
|
env:
|
|
cache-name: cache-node-modules
|
|
with:
|
|
path: node_modules
|
|
key: ${{ runner.os }}-modified-build-${{ hashFiles('**/package-lock.json') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-modified-build-${{ env.cache-name }}-
|
|
${{ runner.os }}-modified-build-
|
|
${{ runner.os }}-modified-
|
|
|
|
- name: Setup node version and npm cache
|
|
uses: actions/setup-node@v3
|
|
with:
|
|
node-version-file: '.nvmrc'
|
|
cache: 'npm'
|
|
|
|
- name: Install Node dependencies
|
|
if: steps.cache-node-modules.outputs.cache-hit != 'true'
|
|
run: npm ci
|
|
|
|
- name: Build Assets
|
|
run: FORCE_REDUCED_MOTION=true npm run build
|
|
|
|
- name: blocks.ini setup
|
|
run: |
|
|
echo -e 'woocommerce_blocks_phase = 3\nwoocommerce_blocks_env = tests' > blocks.ini
|
|
- name: Get Composer Cache Directory
|
|
id: composer-cache
|
|
run: |
|
|
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
|
|
- uses: actions/cache@v3
|
|
with:
|
|
path: ${{ steps.composer-cache.outputs.dir }}
|
|
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-composer-
|
|
|
|
- name: Set up PHP
|
|
uses: shivammathur/setup-php@v2
|
|
with:
|
|
php-version: '8.0'
|
|
coverage: none
|
|
tools: composer
|
|
|
|
- name: Composer install
|
|
run: composer install
|
|
|
|
- name: Install Playwright
|
|
run: npx playwright install --with-deps
|
|
|
|
- name: Load wp-env
|
|
run: npm run env:start
|
|
|
|
- name: Run Playwright tests
|
|
run: npm run test:e2e -- --config=tests/e2e/${{ matrix.config.file }}
|
|
|
|
- uses: actions/upload-artifact@v3
|
|
if: ${{ failure() }}
|
|
|
|
with:
|
|
name: playwright-report-${{ matrix.config.name }}
|
|
path: artifacts/${{ matrix.config.resultPath }}
|
|
if-no-files-found: error # 'warn' or 'ignore' are also available, defaults to `warn`
|
|
|