diff --git a/.github/workflows/phpunit-tests.yml b/.github/workflows/phpunit-tests.yml index b40237f82802d..d99d7b32fff69 100644 --- a/.github/workflows/phpunit-tests.yml +++ b/.github/workflows/phpunit-tests.yml @@ -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 @@ -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. @@ -92,6 +93,42 @@ 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 }} @@ -99,6 +136,7 @@ jobs: 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 }} diff --git a/.github/workflows/reusable-phpunit-tests.yml b/.github/workflows/reusable-phpunit-tests.yml index 60949915e4d1c..5f7aa2ef2b798 100644 --- a/.github/workflows/reusable-phpunit-tests.yml +++ b/.github/workflows/reusable-phpunit-tests.yml @@ -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 @@ -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 @@ -156,19 +161,36 @@ 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/html5lib-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 settings in phpunit.xml.dist. - name: Run (Xdebug) tests if: ${{ inputs.php != '8.3' }} @@ -178,7 +200,7 @@ 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' @@ -186,7 +208,7 @@ jobs: 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