Skip to content

Commit

Permalink
Add specific configurations for html5lib tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
costdev committed May 17, 2024
1 parent fe3bc4a commit 89340f9
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 6 deletions.
40 changes: 39 additions & 1 deletion .github/workflows/phpunit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
#
test-with-mysql:
name: PHP ${{ matrix.php }}
uses: WordPress/wordpress-develop/.github/workflows/reusable-phpunit-tests.yml@trunk
uses: costdev/wordpress-develop/.github/workflows/reusable-phpunit-tests.yml@add-html5lib-tests-to-phpunit-workflows
permissions:
contents: read
secrets: inherit
Expand All @@ -51,6 +51,7 @@ jobs:
tests-domain: [ 'example.org' ]
multisite: [ false, true ]
memcached: [ false ]
html5lib-tests: [ false ]

include:
# Include jobs for PHP 7.4 with memcached.
Expand Down Expand Up @@ -92,13 +93,50 @@ jobs:
multisite: false
memcached: false
report: true
# Include html5lib tests.
- os: ubuntu-latest
php: '7.2'
db-version: '5.7'
multisite: false
html5lib-tests: true
- os: ubuntu-latest
php: '7.3'
db-version: '5.7'
multisite: false
html5lib-tests: true
- os: ubuntu-latest
php: '7.4'
db-version: '5.7'
multisite: false
html5lib-tests: true
- os: ubuntu-latest
php: '8.0'
db-version: '5.7'
multisite: false
html5lib-tests: true
- os: ubuntu-latest
php: '8.1'
db-version: '5.7'
multisite: false
html5lib-tests: true
- os: ubuntu-latest
php: '8.2'
db-version: '5.7'
multisite: false
html5lib-tests: true
- os: ubuntu-latest
php: '8.3'
db-version: '5.7'
multisite: false
html5lib-tests: true
with:
os: ${{ matrix.os }}
php: ${{ matrix.php }}
db-type: ${{ matrix.db-type }}
db-version: ${{ matrix.db-version }}
multisite: ${{ matrix.multisite }}
memcached: ${{ matrix.memcached }}
html5lib-tests: ${{ matrix.html5lib-tests }}
phpunit-config: ${{ matrix.multisite && 'tests/phpunit/multisite.xml' || 'phpunit.xml.dist' }}
tests-domain: ${{ matrix.tests-domain }}
report: ${{ matrix.report || false }}
Expand Down
33 changes: 28 additions & 5 deletions .github/workflows/reusable-phpunit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ on:
required: false
type: 'boolean'
default: false
html5lib-tests:
description: 'Whether to run the html5lib tests'
required: false
type: 'boolean'
default: false
phpunit-config:
description: 'The PHPUnit configuration file to use'
required: false
Expand Down Expand Up @@ -80,7 +85,7 @@ jobs:
# - Checks out the WordPress Test reporter repository.
# - Submit the test results to the WordPress.org host test results.
phpunit-tests:
name: PHP ${{ inputs.php }} / ${{ 'mariadb' == inputs.db-type && 'MariaDB' || 'MySQL' }} ${{ inputs.db-version }}${{ inputs.multisite && ' multisite' || '' }}${{ inputs.memcached && ' with memcached' || '' }}${{ inputs.report && ' (test reporting enabled)' || '' }} ${{ 'example.org' != inputs.tests-domain && inputs.tests-domain || '' }}
name: PHP ${{ inputs.php }} / ${{ 'mariadb' == inputs.db-type && 'MariaDB' || 'MySQL' }} ${{ inputs.db-version }}${{ inputs.html5lib-tests && ' (html5lib tests only)' || '' }}${{ inputs.multisite && ' multisite' || '' }}${{ inputs.memcached && ' with memcached' || '' }}${{ inputs.report && ' (test reporting enabled)' || '' }} ${{ 'example.org' != inputs.tests-domain && inputs.tests-domain || '' }}
runs-on: ${{ inputs.os }}
timeout-minutes: 20

Expand Down Expand Up @@ -156,19 +161,37 @@ jobs:
run: npm run env:install

- name: Run PHPUnit tests
if: ${{ ! inputs.html5lib-tests }}
run: node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit --verbose -c ${{ env.PHPUNIT_CONFIG }}

- name: Run AJAX tests
if: ${{ ! inputs.html5lib-tests }}
run: node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit --verbose -c ${{ env.PHPUNIT_CONFIG }} --group ajax

- name: Run ms-files tests as a multisite install
if: ${{ inputs.multisite }}
if: ${{ inputs.multisite && ! inputs.html5lib-tests }}
run: node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit --verbose -c ${{ env.PHPUNIT_CONFIG }} --group ms-files

- name: Run external HTTP tests
if: ${{ ! inputs.multisite }}
if: ${{ ! inputs.multisite && ! inputs.html5lib-tests }}
run: node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit --verbose -c ${{ env.PHPUNIT_CONFIG }} --group external-http

- name: Check if the HTML API was modified
id: check-for-html-api-changes
if: ${{ inputs.html5lib-tests }}
uses: tj-actions/changed-files@v44
with:
files: |
src/wp-includes/html-api/**.php
tests/phpunit/tests/html-api/wpHtmlProcessorHtml5lib.php
tests/phpunit/data/html5lib-tests/**.dat
.github/workflows/phpunit-tests.yml
.github/workflows/reusable-phpunit-tests.yml
- name: Run html5lib tests
if: ${{ inputs.html5lib-tests && steps.check-for-html-api-changes.outputs.any_changed == 'true' }}
run: node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit --verbose -c ${{ env.PHPUNIT_CONFIG }} --group html-api-html5lib-tests

# __fakegroup__ is excluded to force PHPUnit to ignore the <exclude> settings in phpunit.xml.dist.
- name: Run (Xdebug) tests
if: ${{ inputs.php != '8.3' }}
Expand All @@ -178,15 +201,15 @@ jobs:
run: git diff --exit-code

- name: Checkout the WordPress Test Reporter
if: ${{ github.repository == 'WordPress/wordpress-develop' && github.ref == 'refs/heads/trunk' && inputs.report }}
if: ${{ github.repository == 'WordPress/wordpress-develop' && github.ref == 'refs/heads/trunk' && inputs.report && ! inputs.html5lib-tests }}
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
repository: 'WordPress/phpunit-test-runner'
path: 'test-runner'
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}

- name: Submit test results to the WordPress.org host test results
if: ${{ github.repository == 'WordPress/wordpress-develop' && github.ref == 'refs/heads/trunk' && inputs.report }}
if: ${{ github.repository == 'WordPress/wordpress-develop' && github.ref == 'refs/heads/trunk' && inputs.report && ! inputs.html5lib-tests }}
env:
WPT_REPORT_API_KEY: "${{ secrets.WPT_REPORT_API_KEY }}"
run: docker compose run --rm -e WPT_REPORT_API_KEY -e WPT_PREPARE_DIR=/var/www -e WPT_TEST_DIR=/var/www php php test-runner/report.php

0 comments on commit 89340f9

Please sign in to comment.