<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[59287] trunk/.github/workflows: Build/Test Tools: Use the reusable PHPUnit test workflow for coverage.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/59287">59287</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/59287","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>desrosj</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2024-10-24 15:07:06 +0000 (Thu, 24 Oct 2024)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Build/Test Tools: Use the reusable PHPUnit test workflow for coverage.
This updates the Test Coverage workflow to make use of the reusable PHPUnit test workflow to avoid having duplicate code.
`concurrency` has also been configured for the workflow, and 4 test jobs have been consolidated into 2.
Props jrf.
Fixes <a href="https://core.trac.wordpress.org/ticket/62296">#62296</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkgithubworkflowsreusablephpunittestsv3yml">trunk/.github/workflows/reusable-phpunit-tests-v3.yml</a></li>
<li><a href="#trunkgithubworkflowstestcoverageyml">trunk/.github/workflows/test-coverage.yml</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkgithubworkflowsreusablephpunittestsv3yml"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/.github/workflows/reusable-phpunit-tests-v3.yml</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/.github/workflows/reusable-phpunit-tests-v3.yml 2024-10-23 22:37:35 UTC (rev 59286)
+++ trunk/.github/workflows/reusable-phpunit-tests-v3.yml 2024-10-24 15:07:06 UTC (rev 59287)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -52,6 +52,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> required: false
</span><span class="cx" style="display: block; padding: 0 10px"> type: 'string'
</span><span class="cx" style="display: block; padding: 0 10px"> default: 'example.org'
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ coverage-report:
+ description: 'Whether to generate a code coverage report.'
+ required: false
+ type: boolean
+ default: false
</ins><span class="cx" style="display: block; padding: 0 10px"> report:
</span><span class="cx" style="display: block; padding: 0 10px"> description: 'Whether to report results to WordPress.org Hosting Tests'
</span><span class="cx" style="display: block; padding: 0 10px"> required: false
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -62,8 +67,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> required: false
</span><span class="cx" style="display: block; padding: 0 10px"> type: boolean
</span><span class="cx" style="display: block; padding: 0 10px"> default: false
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ secrets:
+ CODECOV_TOKEN:
+ description: 'The Codecov token required for uploading reports.'
+ required: false
</ins><span class="cx" style="display: block; padding: 0 10px"> env:
</span><span class="cx" style="display: block; padding: 0 10px"> LOCAL_PHP: ${{ inputs.php }}-fpm
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ LOCAL_PHP_XDEBUG: ${{ inputs.coverage-report || false }}
+ LOCAL_PHP_XDEBUG_MODE: ${{ inputs.coverage-report && 'coverage' || 'develop,debug' }}
</ins><span class="cx" style="display: block; padding: 0 10px"> LOCAL_DB_TYPE: ${{ inputs.db-type }}
</span><span class="cx" style="display: block; padding: 0 10px"> LOCAL_DB_VERSION: ${{ inputs.db-version }}
</span><span class="cx" style="display: block; padding: 0 10px"> LOCAL_PHP_MEMCACHED: ${{ inputs.memcached }}
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -88,13 +99,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> # - Logs debug information about what's installed within the WordPress Docker containers.
</span><span class="cx" style="display: block; padding: 0 10px"> # - Install WordPress within the Docker container.
</span><span class="cx" style="display: block; padding: 0 10px"> # - Run the PHPUnit tests.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ # - Upload the code coverage report to Codecov.io.
+ # - Upload the HTML code coverage report as an artifact.
</ins><span class="cx" style="display: block; padding: 0 10px"> # - Ensures version-controlled files are not modified or deleted.
</span><span class="cx" style="display: block; padding: 0 10px"> # - Checks out the WordPress Test reporter repository.
</span><span class="cx" style="display: block; padding: 0 10px"> # - Submit the test results to the WordPress.org host test results.
</span><span class="cx" style="display: block; padding: 0 10px"> phpunit-tests:
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- name: PHP ${{ inputs.php }} / ${{ 'mariadb' == inputs.db-type && 'MariaDB' || 'MySQL' }} ${{ inputs.db-version }}${{ inputs.multisite && ' multisite' || '' }}${{ inputs.phpunit-test-groups && format( ' ({0})', inputs.phpunit-test-groups ) || '' }}${{ inputs.memcached && ' with memcached' || '' }}${{ inputs.report && ' (test reporting enabled)' || '' }} ${{ 'example.org' != inputs.tests-domain && inputs.tests-domain || '' }}
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ name: PHP ${{ inputs.php }} ${{ ! inputs.coverage-report && '/ ' || 'with ' }}${{ 'mariadb' == inputs.db-type && 'MariaDB' || 'MySQL' }} ${{ inputs.db-version }}${{ inputs.multisite && ' multisite' || '' }}${{ inputs.phpunit-test-groups && format( ' ({0})', inputs.phpunit-test-groups ) || '' }}${{ inputs.memcached && ' with memcached' || '' }}${{ inputs.report && ' (test reporting enabled)' || '' }} ${{ 'example.org' != inputs.tests-domain && inputs.tests-domain || '' }}
</ins><span class="cx" style="display: block; padding: 0 10px"> runs-on: ${{ inputs.os }}
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- timeout-minutes: 20
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ timeout-minutes: ${{ inputs.coverage-report && 120 || 20 }}
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> steps:
</span><span class="cx" style="display: block; padding: 0 10px"> - name: Configure environment variables
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -167,31 +180,48 @@
</span><span class="cx" style="display: block; padding: 0 10px"> - name: Install WordPress
</span><span class="cx" style="display: block; padding: 0 10px"> run: npm run env:install
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- - name: Run PHPUnit tests${{ inputs.phpunit-test-groups && format( ' ({0} groups)', inputs.phpunit-test-groups ) || '' }}
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ - name: Run PHPUnit tests${{ inputs.phpunit-test-groups && format( ' ({0} groups)', inputs.phpunit-test-groups ) || '' }}${{ inputs.coverage-report && ' with coverage report' || '' }}
</ins><span class="cx" style="display: block; padding: 0 10px"> continue-on-error: ${{ inputs.allow-errors }}
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- run: node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit --verbose -c ${{ env.PHPUNIT_CONFIG }}${{ inputs.phpunit-test-groups && format( ' --group {0}', inputs.phpunit-test-groups ) || '' }}
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ run: node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit --verbose -c ${{ env.PHPUNIT_CONFIG }}${{ inputs.phpunit-test-groups && format( ' --group {0}', inputs.phpunit-test-groups ) || '' }}${{ inputs.coverage-report && format( ' --coverage-clover wp-code-coverage-{0}-{1}.xml --coverage-html wp-code-coverage-{0}-{1}', ( inputs.multisite && 'multisite' || 'single' ), github.sha ) || '' }}
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> - name: Run AJAX tests
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if: ${{ ! inputs.phpunit-test-groups }}
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if: ${{ ! inputs.phpunit-test-groups && ! inputs.coverage-report }}
</ins><span class="cx" style="display: block; padding: 0 10px"> continue-on-error: ${{ inputs.allow-errors }}
</span><span class="cx" style="display: block; padding: 0 10px"> run: node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit --verbose -c ${{ env.PHPUNIT_CONFIG }} --group ajax
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> - name: Run ms-files tests as a multisite install
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if: ${{ inputs.multisite && ! inputs.phpunit-test-groups }}
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if: ${{ inputs.multisite && ! inputs.phpunit-test-groups && ! inputs.coverage-report }}
</ins><span class="cx" style="display: block; padding: 0 10px"> continue-on-error: ${{ inputs.allow-errors }}
</span><span class="cx" style="display: block; padding: 0 10px"> run: node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit --verbose -c ${{ env.PHPUNIT_CONFIG }} --group ms-files
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> - name: Run external HTTP tests
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if: ${{ ! inputs.multisite && ! inputs.phpunit-test-groups }}
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if: ${{ ! inputs.multisite && ! inputs.phpunit-test-groups && ! inputs.coverage-report }}
</ins><span class="cx" style="display: block; padding: 0 10px"> continue-on-error: ${{ inputs.allow-errors }}
</span><span class="cx" style="display: block; padding: 0 10px"> run: node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit --verbose -c ${{ env.PHPUNIT_CONFIG }} --group external-http
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> # __fakegroup__ is excluded to force PHPUnit to ignore the <exclude> settings in phpunit.xml.dist.
</span><span class="cx" style="display: block; padding: 0 10px"> - name: Run (Xdebug) tests
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if: ${{ inputs.php != '8.4' && ! inputs.phpunit-test-groups }}
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if: ${{ inputs.php != '8.4' && ! inputs.phpunit-test-groups && ! inputs.coverage-report }}
</ins><span class="cx" style="display: block; padding: 0 10px"> continue-on-error: ${{ inputs.allow-errors }}
</span><span class="cx" style="display: block; padding: 0 10px"> run: LOCAL_PHP_XDEBUG=true node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit -v --group xdebug --exclude-group __fakegroup__
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ - name: Upload test coverage report to Codecov
+ if: ${{ inputs.coverage-report }}
+ uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4.6.0
+ with:
+ token: ${{ secrets.CODECOV_TOKEN }}
+ file: wp-code-coverage${{ inputs.multisite && '-multisite' || '-single' }}-${{ github.sha }}.xml
+ flags: ${{ inputs.multisite && 'multisite' || 'single' }},php
+ fail_ci_if_error: true
+
+ - name: Upload HTML coverage report as artifact
+ if: ${{ inputs.coverage-report }}
+ uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
+ with:
+ name: wp-code-coverage${{ inputs.multisite && '-multisite' || '-single' }}-${{ github.sha }}
+ path: wp-code-coverage${{ inputs.multisite && '-multisite' || '-single' }}-${{ github.sha }}
+ overwrite: true
+
</ins><span class="cx" style="display: block; padding: 0 10px"> - name: Ensure version-controlled files are not modified or deleted
</span><span class="cx" style="display: block; padding: 0 10px"> run: git diff --exit-code
</span><span class="cx" style="display: block; padding: 0 10px">
</span></span></pre></div>
<a id="trunkgithubworkflowstestcoverageyml"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/.github/workflows/test-coverage.yml</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/.github/workflows/test-coverage.yml 2024-10-23 22:37:35 UTC (rev 59286)
+++ trunk/.github/workflows/test-coverage.yml 2024-10-24 15:07:06 UTC (rev 59287)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -24,6 +24,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> # Allow manually triggering the workflow.
</span><span class="cx" style="display: block; padding: 0 10px"> workflow_dispatch:
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+# Cancels all previous workflow runs for pull requests that have not completed.
+concurrency:
+ # The concurrency group contains the workflow name and the branch name for pull requests
+ # or the commit hash for any other events.
+ group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
+ cancel-in-progress: true
+
</ins><span class="cx" style="display: block; padding: 0 10px"> # Disable permissions for all available scopes by default.
</span><span class="cx" style="display: block; padding: 0 10px"> # Any needed permissions should be configured at the job level.
</span><span class="cx" style="display: block; padding: 0 10px"> permissions: {}
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -35,161 +42,27 @@
</span><span class="cx" style="display: block; padding: 0 10px"> PUPPETEER_SKIP_DOWNLOAD: ${{ true }}
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> jobs:
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- # Runs the PHPUnit tests for WordPress.
</del><span class="cx" style="display: block; padding: 0 10px"> #
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- # Performs the following steps:
- # - Sets environment variables.
- # - Checks out the repository.
- # - Sets up Node.js.
- # - Sets up PHP.
- # - Installs Composer dependencies.
- # - Installs npm dependencies
- # - Logs general debug information about the runner.
- # - Logs Docker debug information (about the Docker installation within the runner).
- # - Starts the WordPress Docker container.
- # - Logs the running Docker containers.
- # - Logs debug information about what's installed within the WordPress Docker containers.
- # - Install WordPress within the Docker container.
- # - Run the PHPUnit tests as a single site.
- # - Ensures version-controlled files are not modified or deleted.
- # - Upload the single site code coverage report to Codecov.io.
- # - Run the PHPUnit tests as a multisite installation.
- # - Ensures version-controlled files are not modified or deleted.
- # - Upload the multisite code coverage report to Codecov.io.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ # Creates a PHPUnit test jobs for generating code coverage reports.
+ #
</ins><span class="cx" style="display: block; padding: 0 10px"> test-coverage-report:
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- name: ${{ matrix.multisite && 'Multisite' || 'Single site' }} report (${{ matrix.format }})
- runs-on: ubuntu-latest
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ name: ${{ matrix.multisite && 'Multisite' || 'Single site' }} report
+ uses: WordPress/wordpress-develop/.github/workflows/reusable-phpunit-tests-v3.yml@trunk
</ins><span class="cx" style="display: block; padding: 0 10px"> permissions:
</span><span class="cx" style="display: block; padding: 0 10px"> contents: read
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- timeout-minutes: 120
</del><span class="cx" style="display: block; padding: 0 10px"> if: ${{ github.repository == 'WordPress/wordpress-develop' }}
</span><span class="cx" style="display: block; padding: 0 10px"> strategy:
</span><span class="cx" style="display: block; padding: 0 10px"> fail-fast: false
</span><span class="cx" style="display: block; padding: 0 10px"> matrix:
</span><span class="cx" style="display: block; padding: 0 10px"> multisite: [ false, true ]
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- format: [ clover, html ]
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ coverage-report: [ true ]
+ with:
+ php: '8.3'
+ multisite: ${{ matrix.multisite }}
+ coverage-report: ${{ matrix.coverage-report }}
+ secrets:
+ CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- steps:
- - name: Configure environment variables
- run: |
- echo "PHP_FPM_UID=$(id -u)" >> $GITHUB_ENV
- echo "PHP_FPM_GID=$(id -g)" >> $GITHUB_ENV
-
- - name: Checkout repository
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- with:
- show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
-
- - name: Set up Node.js
- uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4
- with:
- node-version-file: '.nvmrc'
- cache: npm
-
- ##
- # This allows Composer dependencies to be installed using a single step.
- #
- # Since the tests are currently run within the Docker containers where the PHP version varies,
- # the same PHP version needs to be configured for the action runner machine so that the correct
- # dependency versions are installed and cached.
- ##
- - name: Set up PHP
- uses: shivammathur/setup-php@c541c155eee45413f5b09a52248675b1a2575231 # v2.31.1
- with:
- php-version: '7.4'
- coverage: none
-
- # Since Composer dependencies are installed using `composer update` and no lock file is in version control,
- # passing a custom cache suffix ensures that the cache is flushed at least once per week.
- - name: Install Composer dependencies
- uses: ramsey/composer-install@57532f8be5bda426838819c5ee9afb8af389d51a # v3.0.0
- with:
- custom-cache-suffix: $(/bin/date -u --date='last Mon' "+%F")
-
- - name: Install npm Dependencies
- run: npm ci
-
- - name: Log debug information
- run: |
- echo "$GITHUB_REF"
- echo "$GITHUB_EVENT_NAME"
- npm --version
- node --version
- curl --version
- git --version
- composer --version
- locale -a
-
- - name: Docker debug information
- run: |
- docker -v
-
- - name: Start Docker environment
- run: |
- npm run env:start
-
- - name: Log running Docker containers
- run: docker ps -a
-
- - name: WordPress Docker container debug information
- run: |
- docker compose run --rm mysql mysql --version
- docker compose run --rm php php --version
- docker compose run --rm php php -m
- docker compose run --rm php php -i
- docker compose run --rm php locale -a
-
- - name: Install WordPress
- run: npm run env:install
-
- - name: Run tests as a single site
- if: ${{ ! matrix.multisite }}
- run: npm run test:php -- --verbose -c phpunit.xml.dist --coverage-${{ 'html' == matrix.format && 'html' || 'clover' }} wp-code-coverage-single-${{ github.sha }}${{ 'clover' == matrix.format && '.xml' || '' }}
-
- - name: Ensure version-controlled files are not modified during the tests
- run: git diff --exit-code
-
- - name: Upload single site report to Codecov
- if: ${{ ! matrix.multisite && matrix.format == 'clover' && github.event_name != 'pull_request' }}
- uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4.6.0
- with:
- token: ${{ secrets.CODECOV_TOKEN }}
- file: wp-code-coverage-single-${{ github.sha }}${{ 'clover' == matrix.format && '.xml' || '' }}
- flags: single,php
- fail_ci_if_error: true
-
- - name: Upload single site HTML report as artifact
- if: ${{ ! matrix.multisite && matrix.format == 'html' }}
- uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
- with:
- name: wp-code-coverage-single-${{ github.sha }}
- path: wp-code-coverage-single-${{ github.sha }}
- overwrite: true
-
- - name: Run tests as a multisite install
- if: ${{ matrix.multisite }}
- run: npm run test:php -- --verbose -c tests/phpunit/multisite.xml --coverage-${{ 'html' == matrix.format && 'html' || 'clover' }} wp-code-coverage-multisite-${{ github.sha }}${{ 'clover' == matrix.format && '.xml' || '' }}
-
- - name: Ensure version-controlled files are not modified during the tests
- run: git diff --exit-code
-
- - name: Upload multisite report to Codecov
- if: ${{ matrix.multisite && matrix.format == 'clover' && github.event_name != 'pull_request' }}
- uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4.6.0
- with:
- token: ${{ secrets.CODECOV_TOKEN }}
- file: wp-code-coverage-multisite-${{ github.sha }}${{ 'clover' == matrix.format && '.xml' || '' }}
- flags: multisite,php
- fail_ci_if_error: true
-
- - name: Upload multisite HTML report as artifact
- if: ${{ matrix.multisite && matrix.format == 'html' }}
- uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
- with:
- name: wp-code-coverage-multisite-${{ github.sha }}
- path: wp-code-coverage-multisite-${{ github.sha }}
- overwrite: true
-
</del><span class="cx" style="display: block; padding: 0 10px"> slack-notifications:
</span><span class="cx" style="display: block; padding: 0 10px"> name: Slack Notifications
</span><span class="cx" style="display: block; padding: 0 10px"> uses: WordPress/wordpress-develop/.github/workflows/slack-notifications.yml@trunk
</span></span></pre>
</div>
</div>
</body>
</html>