Skip to content

Playwright

Playwright #64

Workflow file for this run

name: Playwright
on:
pull_request:
types: [ labeled, synchronize, opened, reopened ]
push:
branches:
- 'main'
- '3.*'
paths-ignore:
- '**.md'
- '**.txt'
- '.github/config.json'
- 'bin/**'
- '.gitignore'
- 'docs/**'
schedule:
- cron: '30 08 * * 0,1,2,3,4,5'
workflow_dispatch:
inputs:
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
concurrency:
group: playwright-${{ github.event_name }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
build-plugin:
if: github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'run-tests')
name: Build plugin
uses: ./.github/workflows/build.yml
Playwright:
name: Playwright test - ${{ matrix.shardIndex }} on PHP 8.1
runs-on: ubuntu-22.04
needs: [build-plugin]
if: github.event.inputs.tag == '' && (github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'run-tests'))
strategy:
fail-fast: ${{ inputs.fail_fast || false }}
matrix:
shardIndex: [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]
shardTotal: [ 10 ]
include:
- shardIndex: "v4-tests"
- shardIndex: "elements-regression"
- shardIndex: "plugin_tester_section"
- shardIndex: "plugin_tester_container"
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Cache Docker images.
uses: ScribeMD/docker-cache@0.5.0
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 run prepare-environment: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' &&
matrix.shardIndex != 'plugin_tester_container' &&
matrix.shardIndex != 'plugin_tester_section' &&
matrix.shardIndex != 'v4-tests'
}}
run: |
npm run test:playwright -- --grep-invert="@v4-tests|@plugin_tester_container|@plugin_tester_section" --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
- name: Run v4 tests
if: ${{ matrix.shardIndex == 'v4-tests' }}
run: npm run test:playwright -- --grep="@v4-tests"
- name: Run Playwright Plugin Container tests
if: ${{ matrix.shardIndex == 'plugin_tester_container' }}
run: npm run test:playwright -- --grep="@plugin_tester_container"
- name: Run Playwright Plugin Container tests
if: ${{ matrix.shardIndex == 'plugin_tester_section' }}
run: npm run test:playwright -- --grep="@plugin_tester_section"
- 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-22.04
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 run prepare-environment: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: 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() && (needs.Playwright.result != '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') }}
uses: actions/checkout@v4
- name: Send slack message
if: ${{ needs.Playwright.result == 'failure' && github.event_name != 'workflow_dispatch' && github.event_name != 'pull_request' }}
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 - ${{github.event_name}} has failed: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Elementor Core: Playwright - ${{github.event_name}} failed: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
}
},
{
"type": "divider"
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Github User : <${{ github.actor }}>"
}
}
]
}
- name: Check Playwright matrix status
if: ${{ (needs.Playwright.result != 'success' && needs.Playwright.result != 'skipped') || (needs.PlaywrightWithTag.result != 'success' && needs.PlaywrightWithTag.result != 'skipped') }}
run: exit 1