Skip to content

Add PHPUnit, Plugin Check, JS/CSS lint and image compression workflows - #100

Merged
jdevalk merged 6 commits into
developfrom
claude/ci-workflow-gaps-3a5ea7
Nov 18, 2026
Merged

jdevalk merged 6 commits into
developfrom
claude/ci-workflow-gaps-3a5ea7

Conversation

@jdevalk

@jdevalk jdevalk commented Nov 18, 2026

Copy link
Copy Markdown
Member

Closes the CI gaps found in the workflow audit of 2026-11-18. One workflow file per concern, every action pinned to a commit SHA, minimal permissions:.

What's added

  • PHPUnit — yoast/wp-test-utils, tests/bin/install-wp-tests.sh, composer test, and a first suite of 52 integration tests: the tracking table, option access tracking, activation, the known-plugins mapping, and the REST routes that flip autoload or delete options (including capability and nonce checks).
  • test.yml — PHP 7.4 / WP 6.7, PHP 8.2 / WP latest, PHP 8.4 / WP latest multisite.
  • plugin-check.yml — WordPress.org Plugin Check on the wp dist-archive build.
  • js-css-lint.yml — runs the existing lint:js and lint:css scripts.
  • image-actions.yml — compresses images under .wordpress-org, same-repo PRs only.
  • playground-merged.yml removed — it was empty, so every push recorded a failed run. playground.yml already comments on every PR. Same change as Remove the empty playground-merged.yml workflow #96.

Changes outside the workflows

  • composer.json: config.platform.php set to 7.4.33 so the lock stays installable on the lowest supported PHP. The lock only gained packages; no existing version moved.
  • package.json: lint:css could not run (root @wordpress/stylelint-config ^22 pulled stylelint 14, @wordpress/scripts 30 needs 16). Removed the root config and added stylelint ^16.
  • css/style.css, js/admin-script.js: lint auto-fixes only (whitespace, bold to 700, one line join). Two no-descending-specificity findings are baselined.
  • src/autoload.php: ABSPATH guard, the one error Plugin Check reported. Same hunk as in Harden option actions, tracking, and release workflows #93.
  • phpstan.neon.dist: excludes node_modules.

Verified locally

  • composer test on PHP 8.4 with WP 7.1.4 (single and multisite) and WP 6.7, and on PHP 7.4 with WP 6.7.
  • composer check-cs, phpstan, lint, npm run lint:js, npm run lint:css, actionlint.
  • Plugin Check on a throwaway site: 0 errors, 8 DirectDB.UnescapedDBParameter warnings (these do not fail the check).

Notes for review

  • Harden option actions, tracking, and release workflows #93 merges cleanly with this branch, but it rewrites the REST and Database classes, so some REST tests will likely need updating when it lands.
  • aaa_option_optimizer_deactivation() does not actually turn off autoload for option_optimizer: update_option() with an unchanged value returns early. Not fixed here; the test only asserts the value is kept.

🤖 Generated with Claude Code

jdevalk and others added 5 commits November 18, 2026 12:12
Sets up PHPUnit the way fewer-tags and comment-experience do: yoast/wp-test-utils,
tests/bin/install-wp-tests.sh and `composer test`. The lock file is resolved for
PHP 7.4 (config.platform.php), the lowest version the plugin supports.

The first suite (52 tests) covers the tracking table, option access tracking,
activation/deactivation, the known-plugins mapping, and the REST routes that
change or delete options, including the capability and nonce checks.

test.yml runs it on PHP 7.4/WP 6.7, PHP 8.2/WP latest and PHP 8.4/WP latest
multisite. PHPStan now also skips node_modules, which holds PHP files after
`npm ci`.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
`npm run lint:css` could not run at all: the root @wordpress/stylelint-config
^22 pulled in stylelint 14, while @wordpress/scripts 30 ships a config that needs
stylelint 16. Drop the redundant root config (wp-scripts brings its own) and
depend on stylelint 16 directly.

Apply the auto-fixes (whitespace, `bold` to `700`, one Prettier line join) and
baseline the two no-descending-specificity findings, since reordering those rules
would change the cascade.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Copied from comment-experience/brand-assets, with every action pinned to a commit
SHA. It checks the same file set that is deployed (wp dist-archive + .distignore).

Add the direct file access guard to src/autoload.php, the one error Plugin Check
reports. The remaining findings are warnings and do not fail the check.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
calibreapp/image-actions, as in brand-assets, limited to images under
.wordpress-org and to pull requests from this repository.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The file has been empty since the playground logic moved into playground.yml,
which comments on every pull request. GitHub can't parse an empty workflow, so
each push recorded a failed run. Same change as #96.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Plugin readme preview

Open preview · Commit dc39856

29 passed · 1 warning · 0 notes

Warnings

  • “Tested up to” is 7.2; the latest WordPress major release is 7.1. Test with 7.1 and update the header.
Passed checks (29)
  • 76 / 150 characters in the short description.
  • Plugin name header recognized.
  • License header recognized: GPL-3.0-or-later.
  • 5 tags accepted within the five-tag limit.
  • Description is within the parser’s word limit.
  • Installation is within the parser’s word limit.
  • Faq is within the parser’s word limit.
  • Changelog is within the parser’s word limit.
  • Stable tag is declared: 1.7.1.
  • The PHP Version header is declared: 1.7.1.
  • Stable tag matches the PHP Version header: 1.7.1.
  • The readme “Requires at least” value is valid: 6.7.
  • The PHP “Requires at least” header is a numeric version: 6.7.
  • “Requires at least” matches between the readme and PHP header: 6.7.
  • The readme “Requires PHP” value is valid: 7.4.
  • The PHP “Requires PHP” header is a numeric version: 7.4.
  • “Requires PHP” matches between the readme and PHP header: 7.4.
  • “Tested up to” 7.2 meets the minimum WordPress version 6.7.
  • Installation content is present.
  • FAQ content is present.
  • Changelog content is present.
  • Screenshot captions are present.
  • The first changelog release matches Stable tag: 1.7.1.
  • The first changelog release matches PHP Version: 1.7.1.
  • Banner image loaded.
  • Plugin icon loaded.
  • Screenshot 1 has a matching image and caption.
  • Screenshot 2 has a matching image and caption.
  • Plugin PHP header loaded.

Readme and PHP-header checks only; this does not test plugin runtime compatibility.

@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Test on Playground
Test this pull request on the Playground
or download the zip

@github-actions

Copy link
Copy Markdown
Composer package changes
Dev Packages Operation Base Target
antecedent/patchwork New - 2.2.5
brain/monkey New - 2.7.0
doctrine/instantiator New - 1.5.0
hamcrest/hamcrest-php New - v3.0.0
mockery/mockery New - 1.6.15
myclabs/deep-copy New - 1.13.4
nikic/php-parser New - v5.9.0
phar-io/manifest New - 2.0.4
phar-io/version New - 3.2.1
phpunit/php-code-coverage New - 9.2.32
phpunit/php-file-iterator New - 3.0.6
phpunit/php-invoker New - 3.1.1
phpunit/php-text-template New - 2.0.4
phpunit/php-timer New - 5.0.3
phpunit/phpunit New - 9.6.39
sebastian/cli-parser New - 1.0.2
sebastian/code-unit New - 1.0.8
sebastian/code-unit-reverse-lookup New - 2.0.3
sebastian/comparator New - 4.0.10
sebastian/complexity New - 2.0.3
sebastian/diff New - 4.0.6
sebastian/environment New - 5.1.5
sebastian/exporter New - 4.0.9
sebastian/global-state New - 5.0.8
sebastian/lines-of-code New - 1.0.4
sebastian/object-enumerator New - 4.0.4
sebastian/object-reflector New - 2.0.4
sebastian/recursion-context New - 4.0.7
sebastian/resource-operations New - 3.0.4
sebastian/type New - 3.2.1
sebastian/version New - 3.0.2
theseer/tokenizer New - 1.3.1
yoast/phpunit-polyfills New - 1.1.5
yoast/wp-test-utils New - 1.2.1

Deactivation re-saved the unchanged option with update_option(), which
returns before touching autoload, so the option stayed autoloaded. Use
wp_set_option_autoload() and assert it in the test.

The two REST tests created their admin user before batch_insert(), whose
COMMIT made the user (and the multisite super admin grant) permanent.
Create the user after the commit so it is rolled back.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@ilicfilip ilicfilip left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pushed dc39856: deactivation now uses wp_set_option_autoload() because update_option() with an unchanged value never turned autoload off (the test now asserts it), and the two REST tests create their admin user after batch_insert() commits so the user is rolled back instead of leaking.

@jdevalk
jdevalk merged commit 6ad2f4a into develop Nov 18, 2026
15 checks passed
@jdevalk
jdevalk deleted the claude/ci-workflow-gaps-3a5ea7 branch November 18, 2026 13:01
jdevalk added a commit that referenced this pull request Nov 18, 2026
#100 was squash-merged, so the branch needed develop's history. No content
change beyond the extra deactivation test.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
jdevalk added a commit that referenced this pull request Nov 18, 2026
…tions

The REST tests from #100 asserted the old behaviour. Adjust them to the hardened
routes: schema validation rejects unknown autoload values, missing options are
reported as update_failed instead of 404 or being skipped silently, and the
in-handler nonce checks are gone (core REST authentication checks cookie nonces).
The admin page only pauses tracking for an administrator in wp-admin, so cover
both that and the front-end case.

Add tests for what the hardening introduces: protected options can't be deleted
or have their autoload flag changed, a protected name refuses a whole batch, and
malformed option names are rejected.

Make js/admin-script.js pass the JS lint job that develop now has: Prettier
formatting, eslint-disable comments moved to the lines they apply to, and the
DataTable lookup moved after the early return.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
jdevalk added a commit that referenced this pull request Nov 18, 2026
* Harden option actions, tracking, and release workflows

* Return raw stored option values without serializing again

* Fix protected options, sort direction and CI pinning from #93 review

- Protect the active theme's real theme_mods_{stylesheet} option instead of the
  non-existent "theme_mods"; inactive themes' leftovers stay removable.
- Protect salts and keys WordPress stores in the database when wp-config.php
  doesn't define them.
- Build the lowercased protected-name map once per request and resolve bulk
  collation aliases with a single IN query instead of one query per name.
- Compare the sort direction case-insensitively again, as develop did.
- Pin the new javascript-regressions job's actions to commit SHAs.
- Fetch a full page in the list-response test so fixtures aren't paginated
  away on sites with more than 25 matching options.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Rework tracking limits from #93 review

The tracking-limited flag paused unused-option recommendations site-wide and
only a manual reset cleared it, yet it was set by routine events: a 1s lock
timeout under concurrent traffic, any request reading over 1,000 options, or a
transient SQL error. Legacy migrations over 10,000 names could never finish,
and pruning deleted the oldest (core) rows.

- Drop the GET_LOCK serialisation; the 10,000-name cap is now a soft limit
  checked without a lock. No MySQL-only lock functions or DELETE ... LIMIT.
- Set the flag only when a new name is actually dropped for capacity, or one
  request reads more names than storage holds. Write failures don't set it.
- Detect existing names with a SQL join, so case/accent variants of a stored
  row count as existing, matching the primary key's collation.
- Migrate legacy data without the cap so migration always completes.
- Never prune rows, and don't truncate reads at the limit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Keep the tracking table first in the existing-name join

wpdb parses the first FROM to check the table charset for non-ASCII queries;
a leading subquery made every at-capacity write with a non-ASCII name fail.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Update the tracking-limited notice to the new trigger

Write failures no longer pause recommendations, so the notice now names the
only remaining cause: a full tracking table.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Make the alias protection test independent of the database engine

SQLite folds case but not accents, so 'sitéurl' is a distinct, unprotected
option there; the test now only expects 403 where the engine maps the name to
a protected row.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Use an alias both MySQL and SQLite fold in the non-ASCII capacity test

SQLite's case folding is ASCII-only, so vary only the ASCII letters; the name
stays non-ASCII to keep exercising wpdb's charset check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Start the integration test from empty tracking data

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Update the PHPUnit suite and JS formatting for the hardened option actions

The REST tests from #100 asserted the old behaviour. Adjust them to the hardened
routes: schema validation rejects unknown autoload values, missing options are
reported as update_failed instead of 404 or being skipped silently, and the
in-handler nonce checks are gone (core REST authentication checks cookie nonces).
The admin page only pauses tracking for an administrator in wp-admin, so cover
both that and the front-end case.

Add tests for what the hardening introduces: protected options can't be deleted
or have their autoload flag changed, a protected name refuses a whole batch, and
malformed option names are rejected.

Make js/admin-script.js pass the JS lint job that develop now has: Prettier
formatting, eslint-disable comments moved to the lines they apply to, and the
DataTable lookup moved after the early return.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

---------

Co-authored-by: Filip Ilic <ilic.filip@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants