Build/Test Tools: Migrate Puppeteer tests to Playwright.

As per the migration plan shared last year, this migrates all browser-based tests in WordPress core to use Playwright.
This includes end-to-end, performance, and visual regression tests.

Props swissspidy, mamaduka, kevin940726, bartkalisz, desrosj, adamsilverstein.
Fixes #59517.

git-svn-id: https://develop.svn.wordpress.org/trunk@56926 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Pascal Birchler
2023-10-13 08:11:41 +00:00
parent ac0bae2359
commit 5a838d1bb7
40 changed files with 1122 additions and 1006 deletions

View File

@@ -142,8 +142,6 @@ jobs:
contents: read
timeout-minutes: 20
if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }}
env:
PUPPETEER_SKIP_DOWNLOAD: ${{ true }}
steps:
- name: Checkout repository

View File

@@ -42,11 +42,13 @@ jobs:
# - Sets up Node.js.
# - Logs debug information about the GitHub Action runner.
# - Installs npm dependencies.
# - Install Playwright browsers.
# - Builds WordPress to run from the `build` directory.
# - Starts the WordPress Docker container.
# - Logs the running Docker containers.
# - Logs Docker debug information (about both the Docker installation within the runner and the WordPress container).
# - Install WordPress within the Docker container.
# - Install Gutenberg.
# - Run the E2E tests.
# - Ensures version-controlled files are not modified or deleted.
e2e-tests:
@@ -90,6 +92,9 @@ jobs:
- name: Install npm Dependencies
run: npm ci
- name: Install Playwright browsers
run: npx playwright install --with-deps
- name: Build WordPress
run: npm run build
@@ -115,6 +120,9 @@ jobs:
LOCAL_SCRIPT_DEBUG: ${{ matrix.LOCAL_SCRIPT_DEBUG }}
run: npm run env:install
- name: Install Gutenberg
run: npm run env:cli -- plugin install gutenberg --path=/var/www/${{ env.LOCAL_DIR }}
- name: Run E2E tests
run: npm run test:e2e
@@ -129,6 +137,22 @@ jobs:
- name: Ensure version-controlled files are not modified or deleted
run: git diff --exit-code
slack-notifications:
name: Slack Notifications
uses: WordPress/wordpress-develop/.github/workflows/slack-notifications.yml@trunk
permissions:
actions: read
contents: read
needs: [ e2e-tests ]
if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' && always() }}
with:
calling_status: ${{ contains( needs.*.result, 'cancelled' ) && 'cancelled' || contains( needs.*.result, 'failure' ) && 'failure' || 'success' }}
secrets:
SLACK_GHA_SUCCESS_WEBHOOK: ${{ secrets.SLACK_GHA_SUCCESS_WEBHOOK }}
SLACK_GHA_CANCELLED_WEBHOOK: ${{ secrets.SLACK_GHA_CANCELLED_WEBHOOK }}
SLACK_GHA_FIXED_WEBHOOK: ${{ secrets.SLACK_GHA_FIXED_WEBHOOK }}
SLACK_GHA_FAILURE_WEBHOOK: ${{ secrets.SLACK_GHA_FAILURE_WEBHOOK }}
failed-workflow:
name: Failed workflow tasks
runs-on: ubuntu-latest
@@ -141,7 +165,8 @@ jobs:
github.event_name != 'pull_request' &&
github.run_attempt < 2 &&
(
needs.e2e-tests.result == 'cancelled' || needs.e2e-tests.result == 'failure'
contains( needs.*.result, 'cancelled' ) ||
contains( needs.*.result, 'failure' )
)
steps:
- name: Dispatch workflow run

View File

@@ -31,10 +31,10 @@ permissions: {}
env:
# Performance testing should be performed in an environment reflecting a standard production environment.
WP_DEBUG: false
SCRIPT_DEBUG: false
SAVEQUERIES : false
WP_DEVELOPMENT_MODE: ''
LOCAL_WP_DEBUG: false
LOCAL_SCRIPT_DEBUG: false
LOCAL_SAVEQUERIES: false
LOCAL_WP_DEVELOPMENT_MODE: "''"
# This workflow takes two sets of measurements — one for the current commit,
# and another against a consistent version that is used as a baseline measurement.
@@ -56,6 +56,7 @@ jobs:
# - Set up Node.js.
# - Log debug information.
# - Install npm dependencies.
# - Install Playwright browsers.
# - Build WordPress.
# - Start Docker environment.
# - Log running Docker containers.
@@ -73,6 +74,7 @@ jobs:
# - Run performance tests (previous/target commit).
# - Print target performance tests results.
# - Reset to original commit.
# - Install npm dependencies.
# - Set the environment to the baseline version.
# - Run baseline performance tests.
# - Print baseline performance tests results.
@@ -119,6 +121,9 @@ jobs:
- name: Install npm dependencies
run: npm ci
- name: Install Playwright browsers
run: npx playwright install --with-deps
- name: Build WordPress
run: npm run build
@@ -182,24 +187,35 @@ jobs:
run: npm run build
- name: Run target performance tests (base/previous commit)
run: npm run test:performance -- --prefix=before
env:
TEST_RESULTS_PREFIX: before
run: npm run test:performance
- name: Print target performance tests results
run: node ./tests/performance/results.js --prefix=before
env:
TEST_RESULTS_PREFIX: before
run: node ./tests/performance/results.js
- name: Reset to original commit
run: git reset --hard $GITHUB_SHA
- name: Install npm dependencies
run: npm ci
- name: Set the environment to the baseline version
run: |
npm run env:cli -- core update --version=${{ env.BASE_TAG }} --force --path=/var/www/${{ env.LOCAL_DIR }}
npm run env:cli -- core version --path=/var/www/${{ env.LOCAL_DIR }}
- name: Run baseline performance tests
run: npm run test:performance -- --prefix=base
env:
TEST_RESULTS_PREFIX: base
run: npm run test:performance
- name: Print baseline performance tests results
run: node ./tests/performance/results.js --prefix=base
env:
TEST_RESULTS_PREFIX: base
run: node ./tests/performance/results.js
- name: Compare results with base
run: node ./tests/performance/compare-results.js ${{ runner.temp }}/summary.md

View File

@@ -51,7 +51,6 @@ env:
LOCAL_DB_VERSION: ${{ inputs.db-version }}
LOCAL_PHP_MEMCACHED: ${{ inputs.memcached }}
PHPUNIT_CONFIG: ${{ inputs.phpunit-config }}
PUPPETEER_SKIP_DOWNLOAD: ${{ true }}
jobs:
# Runs the PHPUnit tests for WordPress.

View File

@@ -29,7 +29,6 @@ on:
permissions: {}
env:
PUPPETEER_SKIP_DOWNLOAD: ${{ true }}
LOCAL_PHP: '7.4-fpm'
LOCAL_PHP_XDEBUG: true
LOCAL_PHP_XDEBUG_MODE: 'coverage'

View File

@@ -37,9 +37,6 @@ concurrency:
# Any needed permissions should be configured at the job level.
permissions: {}
env:
PUPPETEER_SKIP_DOWNLOAD: ${{ true }}
jobs:
# Verifies that installing npm dependencies and building WordPress works as expected.
#