CI: harden and consolidate test workflows - #8695
Conversation
Implements items 2-5 of #8692: - Pin all third-party actions to full commit SHAs with version comments across the four PHP test workflows and deploy_plugin.yml (item 2). - Add .github/dependabot.yml with a grouped weekly github-actions update entry targeting develop (item 2). - Cache the WordPress test suite (/tmp/wordpress-develop, /tmp/tests) keyed on wp-version and the install-wp-tests.sh hash (item 3). - Replace the runner's built-in MySQL with a mysql:8.0 services container and drop the mysql_native_password auth workaround step (item 4). - Cleanups: drop unused phpunit from setup-php tools; run apt-get update before installing subversion (item 5). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Coverage variation | Report missing for e061b221 |
| Diff coverage | ✅ ∅ diff coverage (50.00%) |
Coverage variation details
Coverable lines Covered lines Coverage Common ancestor commit (e061b22) Report Missing Report Missing Report Missing Head commit (02a3b1e) 46713 22380 47.91% Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch:
<coverage of head commit> - <coverage of common ancestor commit>
Diff coverage details
Coverable lines Covered lines Diff coverage Pull request (#8695) 0 0 ∅ (not applicable) Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified:
<covered lines added or modified>/<coverable lines added or modified> * 100%
1 Codacy didn't receive coverage data for the commit, or there was an error processing the received data. Check your integration for errors and validate that your coverage setup is correct.
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
The `--default-authentication-plugin=mysql_native_password` server arg was placed in the service `options:`, which maps to `docker create` flags only — causing "unknown flag" and failing container creation. GitHub service containers can't pass server command args, so restore the native-password behaviour as a post-startup step instead: ALTER root@'%' over TCP (with --get-server-public-key for the cold-cache handshake) before installing the test suite. This keeps PHP 7.4 mysqli working against MySQL 8 while still replacing the runner's built-in MySQL. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Move the cache step ahead of "Install SVN" and gate the install on a cache miss (steps.wp-cache.outputs.cache-hit != 'true'). Subversion is only invoked by install-wp-tests.sh when the test suite isn't already present, so on a warm cache the ~12s apt install is pure waste. Also add --no-install-recommends to trim the download on cache-miss runs. Subversion is not preinstalled on the ubuntu-24.04 runner (verified: "4 newly installed"), so the step is still required on cache misses. The DB is created inside install-wp-tests.sh, which always runs, so skipping only the SVN install is safe. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Replace the duplicated PHPUnit setup (setup-php, problem matchers, composer install, WP test-suite cache, SVN, MySQL native-password auth, install-wp-tests.sh) in the four test workflows with the shared wp-media/workflows composite actions setup-php-composer and setup-wp-tests. Job-level concerns (services, secrets) and the test commands stay in each workflow. WP_TESTS_DIR / WP_CORE_DIR are now exported by setup-wp-tests, so they are dropped from the job env. bin/install-wp-tests.sh is kept for local development (referenced by .github/agents/test-agent.agent.md); CI now uses the copy bundled in the setup-wp-tests action. The actions are referenced at @feature/3-reusable-test-workflow while wp-media/workflows#4 is in review; bump to @main (or a pinned SHA/tag) once it merges. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Description
Fixes #8692
Implements all five follow-up items from #8692 — reducing duplication, hardening supply-chain security, and cutting CI runtime across the four PHP test workflows and
deploy_plugin.yml.uses: wp-media/workflows/.github/actions/…@main:setup-php-composer— inputs:php-version, optionalcoverage(e.g.xdebug), optionalextra-require(used forwpackagist-plugin/woocommerce "^7"on Old PHP andphpunit/phpcovon the coverage run).setup-wp-tests— input:wp-version.Each workflow now differs only in its matrix and its
composertest command(s). This drops ~180 lines of duplication.actions/checkout(all four workflows +deploy_plugin.yml) andcodacy/codacy-coverage-reporter-action(coverage workflow) are pinned to full commit SHAs with version comments;deploy_plugin.ymlalso pinsshivammathur/setup-phpandramsey/composer-install. The remaining third-party actions are now SHA-pinned inside the shared composite actions. Added.github/dependabot.ymlwith a grouped weeklygithub-actionsupdate entry targetingdevelop.setup-wp-tests— caches the WordPress core + test library keyed onwp-version, and skips the SVN install/download on a cache hit.services:container: Each job now uses amysql:8.0service container on127.0.0.1:3306(with a health check) instead of the runner's built-in MySQL. Themysql_native_passwordrequirement (for PHP 7.4 mysqli against MySQL 8) is applied insidesetup-wp-testsas a post-startupALTER USERstep, so the old init.d start + socket workaround is gone.phpunittool is dropped from PHP setup, andapt-get updatenow precedes thesubversioninstall — both folded into the shared actions.Type of change
Detailed scenario
What was tested
This PR's own GitHub Actions runs. All four PHP test workflows are green on the latest commit: WP 5.9/PHP 7.4 (Old PHP), and WP latest across PHP 8.0–8.4 including the xdebug coverage run. Verified that: the shared composite actions resolve and run; the MySQL
mysql:8.0service container is used and the native-password auth succeeds (specifically exercised on PHP 7.4); and the WP test-suite cache produces a hit on re-runs, skipping the SVN install/download.How to test
Open this PR's Actions tab and confirm the four PHP test workflow runs are green. In a job log, verify the "Setup PHP + Composer" and "Setup WordPress test suite" steps invoke the
wp-media/workflowscomposite actions, the MySQL service container starts under "Initialize containers", and on a second run the test-suite cache reports a hit (SVN install skipped).Affected Features & Quality Assurance Scope
CI/tooling only. No plugin runtime behavior changes.
Technical description
services.<id>.optionsmaps todocker createflags, so the MySQL server arg--default-authentication-plugincannot live there; root is instead switched tomysql_native_passwordviaALTER USER 'root'@'%'over TCP after the container is healthy (with--get-server-public-keyfor the cold-cache handshake), preserving PHP 7.4 mysqli compatibility. The setup duplication across the four workflows is removed by delegating to composite actions inwp-media/workflows, leaving each workflow with only its matrix and test command(s).Documentation
n/a
New dependencies
No runtime dependencies. CI now depends on two
wp-media/workflowscomposite actions (setup-php-composer,setup-wp-tests) and SHA-pins all third-party actions;.github/dependabot.ymlautomates future action bumps.Risks
@main; a breaking change there could affect these workflows. Merge order matters — thewp-media/workflowschanges must land first.latest: thewp-versions: 'latest'workflows key their WP cache on the literallatest, so a newly-released WP core is not re-fetched until the cache key changes. The5.9(Old PHP) job is unaffected.Mandatory Checklist
Code validation
Code style
Unticked items justification
Built-in tests are not applicable: the change is GitHub Actions workflow configuration only. The workflows are exercised directly by this PR's own CI runs.