Skip to content

Repair wp/5.3 branch Actions: Run PHP coding standards on the runner - #820

Draft
desrosj wants to merge 1 commit into
fix-actions-5.3/check-database-readiness-over-tcpfrom
fix-actions-5.3/run-phpcs-on-runner
Draft

desrosj wants to merge 1 commit into
fix-actions-5.3/check-database-readiness-over-tcpfrom
fix-actions-5.3/run-phpcs-on-runner

Conversation

@desrosj

@desrosj desrosj commented Oct 20, 2026 •

Copy link
Copy Markdown
Owner

What?

Adds a phpcs job to unit-test.yml that runs PHP coding standards checks on the runner and reports violations as annotations with cs2pr. The .cache/.gitkeep, .gitignore and phpcs.xml.dist changes add the PHPCS scan cache. The job gets timeout-minutes: 20, like the PHP unit test job.

Why?

The unit test workflow added in #745 doesn't check coding standards: its parity table lists npm run lint-php as not ported, because the locked PHPCS installers only support Composer 1. This PR adds that check.

How?

Ports the phpcs job from WordPress#46510 (WordPress@9ee17a7), following wp/5.5's WordPress#85003, including its weekly-reset scan cache.

Unlike wp/5.5, this branch's composer.lock pins composer/installers 1.6.0 and dealerdirect/phpcodesniffer-composer-installer 0.5.0, which require Composer 1 and PHP 7 or older. The job installs Composer 1 with setup-php and runs on PHP 7.3: on PHP 7.4, the locked WPCS 2.1.1 raises notices (Trying to access array offset on value of type bool in WordPress/Sniff.php) that setup-php's E_ALL error reporting turns into scan-aborting errors. The testVersion in phpcs.xml.dist still checks compatibility with the PHP versions WordPress 5.3 supports. It runs phpcs without --runtime-set ignore_warnings_on_exit 1, as this branch's composer run-script lint does. package.json is unchanged: npm run test-php still runs lint-php, and the PHP unit test job keeps calling npm run test-unit-php directly.

Testing Instructions

actionlint passes. Locally, in the composer:1.9 Docker image (Composer 1.9.3), and again on PHP 7.3 with -d error_reporting=-1, composer install installs the lock and phpcs --report-full --report-checkstyle=./.cache/phpcs-report.xml passes on all 65 files. A second run reuses .cache/phpcs.json and finishes in under a second, and an added violation makes phpcs exit with an error and appear in the checkstyle report. Check that the PHP coding standards job passes on this PR.

Use of AI Tools

This PR was created by Claude Code under my supervision. All code should be treated as AI-produced and not yet reviewed by a human until this PR is marked Ready for Review.

🤖 Generated with Claude Code

https://claude.ai/code/session_013wZdkg9DSpSbQmRpBymFfV

Add a `phpcs` job to the Unit Tests workflow that installs the locked
Composer dependencies on the runner and runs PHPCS, reporting violations
as annotations with `cs2pr`. The locked `composer/installers` and
`dealerdirect/phpcodesniffer-composer-installer` releases only support
Composer 1 and PHP 7 or older, so the job uses Composer 1. It runs on
PHP 7.3 because on PHP 7.4 the locked WPCS 2.1.1 raises notices that
abort the scan.

Also add a PHPCS scan cache in `.cache/phpcs.json`, cached between runs
and reset weekly, as trunk does.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013wZdkg9DSpSbQmRpBymFfV
@desrosj
desrosj force-pushed the fix-actions-5.3/run-phpcs-on-runner branch from 48a5192 to 5d61648 Compare October 21, 2026 02:05

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant