PHPCS: Color changed-lines output and annotate violations on the PR diff - #780
PHPCS: Color changed-lines output and annotate violations on the PR diff#780obenland wants to merge 2 commits into
Conversation
…iff. New files are scanned by phpcs itself, whose report honors the colors arg in phpcs.xml.dist — but modified files get their report rendered by phpcs-changed, which has no color support at all, leaving that section of the log plain. Colorize it in the script to match phpcs's look: red/yellow ERROR/WARNING labels and bold FILE/FOUND headers. Additionally emit every violation from both paths as a GitHub workflow command (::error/::warning with file, line, and column), so violations show up as inline annotations on the PR diff. Modified files report under their real path rather than the temporary scan copy. Outside of Actions the annotations are skipped and local output stays unchanged. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
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 Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
There was a problem hiding this comment.
Pull request overview
Updates the PHPCS PR-check helper script to improve readability and reviewer ergonomics by (1) re-adding ANSI color styling to phpcs-changed output and (2) emitting GitHub Actions inline annotations so violations appear directly on the PR diff.
Changes:
- Adds ANSI colorization for
phpcs-changedlog output to matchphpcsstyling. - Adds GitHub Actions workflow-command annotations for PHPCS violations (new files via
phpcsJSON, modified files viaphpcs-changedJSON). - Documents inline annotations behavior in
.github/README.md.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| .github/README.md | Documents that the PHPCS check emits inline PR annotations in GitHub Actions. |
| .github/bin/phpcs-branch.php | Adds colorized phpcs-changed output and emits GitHub Actions annotations from PHPCS JSON reports. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
bb7cb0b to
bbd23c9
Compare
The JSON reports and the second phpcs-changed pass exist solely to feed GitHub's inline annotations, which are skipped outside of Actions — gate the report generation the same way so local runs (composer run phpcs-changed) don't pay for output nothing consumes. Remove the report file with unlink() instead of shelling out. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The phpcs check renders its two sections differently: new files are reported by
phpcsitself, which honors thecolorsarg inphpcs.xml.dist, while modified files are reported byphpcs-changed, whose reporter has no color support at all — so the changed-lines section prints plain.phpcs-changedoutput inphpcs-branch.phpto match phpcs's look: red/yellowERROR/WARNINGlabels, boldFILE:/FOUNDheader lines.::error/::warningworkflow command with file, line, and column, so it shows up directly on the PR diff view. Modified files annotate under their real path (the report itself is keyed by the temporary scan copy). Outside of GitHub Actions the annotations are skipped, so local runs are unchanged.Verified locally against seeded violations in a new and a modified file: changed-lines output now carries the same ANSI styling as the phpcs section, and both sections emit correctly escaped workflow commands with accurate paths/lines/columns. Note GitHub caps inline annotations at 10 per type per step; overflow violations still appear in the log output.
🤖 Generated with Claude Code