Playwright #242
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Playwright | |
on: | |
pull_request: | |
paths-ignore: | |
- '**.md' | |
- '**.txt' | |
- '.github/config.json' | |
- 'bin/**' | |
- '.gitignore' | |
- 'docs/**' | |
schedule: | |
- cron: '30 08 * * 0,1,2,3,4,5' | |
workflow_dispatch: | |
inputs: | |
path-to-results: | |
required: false | |
description: 'Provide path to reporter files' | |
default: allure-results | |
type: choice | |
options: | |
- test-results/ | |
- tests/playwright/blob-report | |
- allure-results | |
fail_fast: | |
type: boolean | |
required: true | |
description: 'Cancel tests when one of them fails' | |
default: false | |
tag: | |
description: 'Provide @tag or a keyword' | |
required: false | |
# This allows a subsequently queued workflow run to interrupt previous runs | |
concurrency: | |
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}' | |
cancel-in-progress: true | |
jobs: | |
build-plugin: | |
name: Build plugin | |
uses: ./.github/workflows/build.yml | |
Playwright: | |
name: Playwright test - ${{ matrix.shardIndex }} on PHP 8.1 | |
runs-on: ubuntu-latest | |
needs: [build-plugin] | |
if: ${{ ( github.event.pull_request.title == null || needs.build-plugin.outputs.changelog_diff ) && github.event.inputs.tag == '' }} | |
strategy: | |
fail-fast: ${{ inputs.fail_fast || false }} | |
matrix: | |
shardIndex: [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ] | |
shardTotal: [ 10 ] | |
include: | |
- shardIndex: "elements-regression" | |
steps: | |
- name: Checkout source code | |
uses: actions/checkout@v4 | |
- name: Cache Docker images. | |
uses: ScribeMD/[email protected] | |
with: | |
key: docker-${{ runner.os }}-${{ hashFiles('tests/playwright/.playwright-wp-lite-env.json') }} | |
- name: Install Node.js 20.x | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
cache: 'npm' | |
- name: Install dependencies | |
run: | | |
npm ci | |
- name: Download build artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: ${{ needs.build-plugin.outputs.artifact_name }} | |
path: ./build | |
- name: Download hello-elementor theme | |
run: | | |
curl -L --output hello-elementor.zip "https://downloads.wordpress.org/theme/hello-elementor.zip" | |
unzip hello-elementor | |
- name: Install WordPress environment | |
run: | | |
npm run start-local-server | |
- name: Update wordpress to nightly build | |
if: ${{ github.event_name == 'schedule' }} | |
run: npx wp-lite-env cli --config=./tests/playwright/.playwright-wp-lite-env.json --port=8888 --command="wp core update https://wordpress.org/nightly-builds/wordpress-latest.zip" | |
- name: Setup test data | |
run: npm run test:setup:playwright | |
- name: WordPress debug information | |
run: | | |
npx wp-lite-env cli --config=./tests/playwright/.playwright-wp-lite-env.json --port=8888 --command="wp core version" | |
npx wp-lite-env cli --config=./tests/playwright/.playwright-wp-lite-env.json --port=8888 --command="wp --info" | |
- name: Install playwright/test | |
run: | | |
npx playwright install chromium | |
- name: Run Playwright tests | |
if: ${{ matrix.shardIndex != 'elements-regression' }} | |
run: npm run test:playwright -- --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }} | |
- name: Run element regression tests | |
if: ${{ matrix.shardIndex == 'elements-regression' }} | |
run: npm run test:playwright:elements-regression | |
- uses: actions/upload-artifact@v4 | |
if: always() | |
with: | |
name: playwright-test-results-${{ matrix.shardIndex }} | |
path: ${{ inputs.path-to-results || 'test-results/' }} | |
if-no-files-found: ignore | |
retention-days: 2 | |
PlaywrightWithTag: | |
name: Playwright test - tagged tests on PHP 8.1 | |
runs-on: ubuntu-latest | |
needs: [ build-plugin ] | |
if: ${{ github.event.inputs.tag }} | |
steps: | |
- name: Checkout source code | |
uses: actions/checkout@v4 | |
- name: Install Node.js 20.x | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
cache: 'npm' | |
- name: Install dependencies | |
run: | | |
npm ci | |
sed -i -e "s/image: 'mariadb:lts'/image: 'mariadb:11.2.4-jammy'/g" node_modules/@wordpress/env/lib/build-docker-compose-config.js | |
- name: Download build artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: ${{ needs.build-plugin.outputs.artifact_name }} | |
path: ./build | |
- name: Download hello-elementor theme | |
run: | | |
curl -L --output hello-elementor.zip "https://downloads.wordpress.org/theme/hello-elementor.zip" | |
unzip hello-elementor | |
- name: Install WordPress environment | |
run: | | |
npm run start-local-server | |
- name: Setup test data | |
run: npm run test:setup:playwright | |
- name: WordPress debug information | |
run: | | |
npx wp-lite-env cli --config=./tests/playwright/.playwright-wp-lite-env.json --port=8888 --command="wp core version" | |
npx wp-lite-env cli --config=./tests/playwright/.playwright-wp-lite-env.json --port=8888 --command="wp --info" | |
- name: Install playwright/test | |
run: | | |
npx playwright install chromium | |
- name: Run Playwright tests | |
run: | | |
npm run test:playwright -- --grep="${{ inputs.tag }}" | |
- uses: actions/upload-artifact@v4 | |
if: always() | |
with: | |
name: playwright-test-results-tagged-tests | |
path: ${{ inputs.path-to-results || 'test-results/' }} | |
if-no-files-found: ignore | |
retention-days: 2 | |
test-result: | |
needs: [ Playwright, PlaywrightWithTag ] | |
if: ${{ always() }} # Will be run even if 'Playwright' matrix will be skipped | |
runs-on: ubuntu-22.04 | |
name: Playwright - Test Results | |
steps: | |
- name: Test status | |
run: echo "Test status is - ${{ needs.Playwright.result }}" | |
- name: Checkout source code | |
if: ${{ needs.Playwright.result == 'failure' && github.event_name == 'schedule' }} | |
uses: actions/checkout@v4 | |
- name: Send slack message | |
if: ${{ needs.Playwright.result == 'failure' && github.event_name == 'schedule' }} | |
uses: ./.github/workflows/post-to-slack | |
with: | |
SLACK_BOT_TOKEN: ${{ secrets.SLACK_TOKEN }} | |
SLACK_TAG_CHANNELS: ${{ secrets.TEST_AUTOMATION_RESULTS }} | |
PAYLOAD: | | |
{ | |
"text": "Elementor Core: Playwright with WordPress nightly has failed: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}", | |
"blocks": [ | |
{ | |
"type": "section", | |
"text": { | |
"type": "mrkdwn", | |
"text": "Elementor Core: Playwright with WordPress nightly failed: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" | |
} | |
} | |
] | |
} | |
- name: Check Playwright matrix status | |
if: ${{ needs.Playwright.result != 'success' && needs.Playwright.result != 'skipped' }} | |
run: exit 1 |