Add CTRF export format for reports (admin + WP-CLI)#1271
Add CTRF export format for reports (admin + WP-CLI)#1271davidperezgar merged 6 commits intotrunkfrom
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Luc45
left a comment
There was a problem hiding this comment.
Howdy David, I passed the results through a CTRF validator using ctrf-cli and it failed one small thing:
-
Check out this PR in wp-env, install a plugin with findings (e.g.
wp plugin install hello-dolly --activate), then generate a CTRF report:wp plugin check hello-dolly --format=ctrf > report.json -
Validate it:
npx --package=ctrf-cli@0.0.5 -- ctrf-cli validate report.json -
Output:
✗ report.json failed validation: - /results/tests/0: must NOT have additional properties - /results/tests/1: must NOT have additional properties ...
The culprit is tests[].labels — it isn't in the CTRF spec, and the test-item schema is additionalProperties: false. CTRF reserves extra (object) as the official extension point ("Extension point for arbitrary metadata"), so renaming labels → extra in Results_Exporter::build_ctrf_test() (plus the matching assertions in Results_Exporter_Tests.php) should be enough. I confirmed locally — after that rename both validate and validate-strict pass clean.
|
I do wonder, though, that ideally this should be a PR to PHPCS. For now, I'm converting PHPCS to CTRF in my tool, so Plugin Check being able to generate CTRF isn't a blocker for me. |
|
I've opened a PR to PHPCS: PHPCSStandards/PHP_CodeSniffer#1420 If they merge this, we could update the PHPCS binary here and use the upstream CTRF reporter instead (since I'll be using CTRF for other PHPCS checks other than plugin check, too) |
|
We could make the conversion in this repository. |
|
Yes - so, as discussed in DM, I've pushed CTRF reporter for PHPCS as a library: https://github.com/Luc45/phpcs-ctrf-reporter Your call if you want to use it or integrate something in PCP directly. |
|
As part of validating that reporter, I used it against WooCommerce and compared the integrity of the CTRF output against a native PHPCS output and they match, both in serial mode or in parallel, passing strict validation by This, together with the unit/integration tests it has, gives me confidence that it's in a good shape. |
|
I tested the PR locally and confirm that replacing "labels" to "extra" will generate valid CTRF report. |
Co-authored-by: Nilambar Sharma <ernilambar@users.noreply.github.com>
What?
Closes #1270
Add CTRF export support for Plugin Check reports in both admin exports and WP-CLI output.
Why?
Plugin Check already supports CSV/JSON/Markdown exports, but lacks a standardized test report format for CI tooling and platforms that consume CTRF.
This PR adds first-class CTRF output so results can be integrated with the CTRF ecosystem.
How?
Results_Exporter::FORMAT_CTRFconstant.reportFormat: "CTRF"specVersion: "1.0.0"results.tool.name: "plugin-check"results.summary+results.tests[].ctrf.json.Export CTRFlocalized string.format: ctrf).ctrfandstrict-ctrfto accepted--formatoptions.FILE:headers), while preserving existing filtering behavior.docs/CLI.mdnow documentsctrfandstrict-ctrfand includes CLI example.readme.txtchangelog updated.--format=ctrfand--format=strict-ctrf.Testing Instructions
rg -n "ctrf|strict-ctrf" docs/CLI.md includes/CLI/Plugin_Check_Command.phpExport CTRF."reportFormat": "CTRF"..ctrf.json.AI Usage Disclosure
If AI tools were used, please describe how they were used:
Used Codex/ChatGPT to draft and implement code changes, tests, and documentation updates based on issue requirements.