Playwright #107
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: | |
schedule: | |
- cron: '30 08 * * 0,1,2,3,4,5' | |
workflow_dispatch: | |
inputs: | |
reporter: | |
required: false | |
description: 'Select a reporter' | |
type: choice | |
options: | |
- allure-playwright | |
- html | |
- blob | |
- list | |
default: allure-playwright | |
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 | |
# 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.0 | |
runs-on: ubuntu-latest | |
needs: [build-plugin] | |
if: ${{ github.event.pull_request.title == null || needs.build-plugin.outputs.changelog_diff }} | |
strategy: | |
fail-fast: ${{ inputs.fail_fast || true }} | |
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: 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: Update wp-env.json file | |
env: | |
PHP_VERSION: '8.0' | |
WP_CORE_VERSION: 'latest' | |
run: node ./.github/scripts/build-wp-env.js | |
- name: Install WordPress environment | |
run: | | |
npm run start-local-server | |
- name: Update wordpress to nightly build | |
if: ${{ github.event_name == 'schedule' }} | |
run: npx wp-env run cli 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-env run cli wp core version | |
npx wp-env run cli 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 }} --reporter=${{ inputs.reporter || 'list,github' }} | |
- name: Run element regression tests | |
if: ${{ matrix.shardIndex == 'elements-regression' }} | |
run: npm run test:playwright:elements-regression -- --reporter=${{ inputs.reporter || 'list,github' }} | |
- 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 | |
test-result: | |
needs: Playwright | |
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 |