2023-04-17 12:01:41 +00:00
|
|
|
name: Playwright Tests
|
|
|
|
on:
|
|
|
|
push:
|
2023-04-21 11:07:37 +00:00
|
|
|
branches: [ trunk ]
|
2023-04-17 12:01:41 +00:00
|
|
|
pull_request:
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
PlaywrightE2ETests:
|
2023-05-05 11:03:36 +00:00
|
|
|
|
2023-08-16 05:23:43 +00:00
|
|
|
name: Playwright E2E tests - ${{ matrix.config.name }}
|
2023-04-17 12:01:41 +00:00
|
|
|
timeout-minutes: 60
|
|
|
|
runs-on: ubuntu-latest
|
2023-08-16 05:23:43 +00:00
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
config: [
|
|
|
|
{ name: Normal, file: playwright.config.ts, resultPath: test-results },
|
2023-08-28 10:04:28 +00:00
|
|
|
{ name: Classic, file: playwright.classic-theme.config.ts, resultPath: test-results-classic-theme },
|
2023-08-16 05:23:43 +00:00
|
|
|
{ name: SideEffects, file: playwright.side-effects.config.ts, resultPath: test-results-side-effects },
|
|
|
|
]
|
2023-04-17 12:01:41 +00:00
|
|
|
steps:
|
2023-08-04 11:07:31 +00:00
|
|
|
|
2023-04-21 11:07:37 +00:00
|
|
|
- uses: actions/checkout@v3
|
|
|
|
|
2023-08-16 05:23:43 +00:00
|
|
|
- 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-
|
|
|
|
|
2023-04-21 11:07:37 +00:00
|
|
|
- name: Setup node version and npm cache
|
2023-11-03 15:06:34 +00:00
|
|
|
uses: actions/setup-node@v4
|
2023-04-21 11:07:37 +00:00
|
|
|
with:
|
|
|
|
node-version-file: '.nvmrc'
|
|
|
|
cache: 'npm'
|
|
|
|
|
|
|
|
- name: Install Node dependencies
|
2023-08-16 05:23:43 +00:00
|
|
|
if: steps.cache-node-modules.outputs.cache-hit != 'true'
|
2023-05-05 11:03:36 +00:00
|
|
|
run: npm ci
|
2023-04-21 11:07:37 +00:00
|
|
|
|
2023-05-05 11:03:36 +00:00
|
|
|
- name: Build Assets
|
|
|
|
run: FORCE_REDUCED_MOTION=true npm run build
|
2023-04-21 11:07:37 +00:00
|
|
|
|
2023-05-05 11:03:36 +00:00
|
|
|
- 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
|
2023-04-21 11:07:37 +00:00
|
|
|
run: |
|
2023-05-05 11:03:36 +00:00
|
|
|
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') }}
|
2023-08-16 05:23:43 +00:00
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-composer-
|
2023-04-21 11:07:37 +00:00
|
|
|
|
2023-05-05 11:03:36 +00:00
|
|
|
- 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
|
2023-04-21 11:07:37 +00:00
|
|
|
run: npx playwright install --with-deps
|
|
|
|
|
2023-05-05 11:03:36 +00:00
|
|
|
- name: Load wp-env
|
|
|
|
run: npm run env:start
|
|
|
|
|
2023-04-21 11:07:37 +00:00
|
|
|
- name: Run Playwright tests
|
2023-08-16 05:23:43 +00:00
|
|
|
run: npm run test:e2e -- --config=tests/e2e/${{ matrix.config.file }}
|
2023-05-05 11:03:36 +00:00
|
|
|
|
2023-08-04 11:07:31 +00:00
|
|
|
- uses: actions/upload-artifact@v3
|
|
|
|
if: ${{ failure() }}
|
|
|
|
|
2023-04-21 11:07:37 +00:00
|
|
|
with:
|
2023-08-16 05:23:43 +00:00
|
|
|
name: playwright-report-${{ matrix.config.name }}
|
|
|
|
path: artifacts/${{ matrix.config.resultPath }}
|
2023-08-04 11:07:31 +00:00
|
|
|
if-no-files-found: error # 'warn' or 'ignore' are also available, defaults to `warn`
|
|
|
|
|