PHP CodeSniffer for CI workflow - #3347
lukasdchang wants to merge 17 commits into
Conversation
stobrien89
left a comment
There was a problem hiding this comment.
looks good, just had one request and when you push up those changes, let's see how it reacts to a change in one of the middleware files (move some things around in a file such that it falls out of compliance). You can do that in the same revised commit
lukasdchang
left a comment
There was a problem hiding this comment.
Created separate workflow file for coding-standards CI job
| echo "" | ||
|
|
||
| exit "$phpcs_exit" | ||
| fi |
There was a problem hiding this comment.
too much code in a string, write this as a shell or php script and then invoke it with arguments from the yml
There was a problem hiding this comment.
"Run PHP_CodeSniffer" job now runs run-phpcs.sh which contains the PHPCS bash output script under a new directory for scripts: .github/scripts/.
|
coding-standards CI workflow job is confirmed safe from security vulnerabilities by running zizmor locally. What run-phpcs.sh does is it:
I'm looking to iterate on this so that the workflow job makes PR review comments for PHPCS formatting errors similar to the way smithy-lang handles incorrect changelog entries here. That way developers do not have to sift through the workflow logs to see their formatting error. |
Description
Adds a
Coding StandardsCI job that runs PHP_CodeSniffer against changed PHP files insrc/, excludingsrc/data.The job compares the PR branch against
master, runs PHPCS withphpcs.xml.dist, and reports formatting violations in the workflow logs. When PHPCS finds violations, the job also runs PHPCBF in the CI checkout and prints a fixed-code preview for the affected block. The output includes the localphpcbfcommand developers can run to apply automatic fixes.Example:
Motivation
The SDK already runs static analysis in CI, but it does not currently enforce formatting. This workflow adds formatting checks without adding PHP_CodeSniffer as a package dependency for SDK consumers.
Developers still install PHPCS locally if they want automatic fixes. CI installs PHPCS only inside the GitHub Actions runner.
Possible Improvements
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution under the terms of your choice.