Download the PHP package staabm/annotate-pull-request-from-checkstyle without Composer
On this page you can find all versions of the php package staabm/annotate-pull-request-from-checkstyle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package annotate-pull-request-from-checkstyle
Annotate a Pull Request based on a Checkstyle XML-report
Turns checkstyle based XML-Reports into GitHub Pull Request Annotations via the Checks API. This script is meant for use within your GitHub Action.
That means you no longer search thru your GitHub Action logfiles. No need to interpret messages which are formatted differently with every tool. Instead you can focus on your Pull Request, and you don't need to leave the Pull Request area.
Images from https://github.com/mheap/phpunit-github-actions-printer
DEMO - See how Pull Request warnings/errors are rendered in action
Installation
Install the binary via composer
💌 Give back some love
Consider supporting the project, so we can make this tool even better even faster for everyone.
Example Usage
cs2pr
can be used on a already existing checkstyle-report xml-file. Alternatively you might use it in the unix-pipe notation to chain it into your existing cli command.
Run one of the following commands within your GitHub Action workflow:
Process a checkstyle formatted file
Available Options
--graceful-warnings
: Don't exit with error codes if there are only warnings--colorize
: Colorize the output. Useful if the same lint script should be used locally on the command line and remote on GitHub Actions. With this option, errors and warnings are better distinguishable on the command line and the output is still compatible with GitHub Annotations--notices-as-warnings
Converts notices to warnings. This can be useful because GitHub does not annotate notices.--prepend-filename
Prepend the filename to the output message--prepend-source
When the checkstyle generating tool provides asource
attribute, prepend the source to the output message.
Pipe the output of another commmand
... works for any command which produces a checkstyle-formatted report.
Examples can bee seen below:
Using PHPStan
Phpstan 0.12.32 introduced native github actions support, therefore you might use this instead:
Using Psalm
Psalm even supports the required format natively, therefore you might use this instead:
Using PHP Coding Standards Fixer
Using PHP_CodeSniffer
Note: the -q
option means that no output will be shown in the action logs anymore.
To see the output both in the PR as well as in the action logs, use two steps, like so:
Using PHP Parallel Lint
Using Laravel Pint
Note: if you want to have both logs and annotations you need to run pint
twice:
phpunit support?
PHPUnit does not support checkstyle, therefore cs2pr
will not work for you.
you might instead try
Example GithubAction workflow
If you're using shivammathur/setup-php
to setup PHP, cs2pr
binary is shipped within:
If you use a custom PHP installation, then your project needs to require staabm/annotate-pull-request-from-checkstyle
Using cs2pr as a GitHub Action
You can also use cs2pr
itself as a GitHub Action. This is useful if you want to for instance use it for a project that does not use PHP or if you want to use it with a custom PHP installation.
See the example at the cs2pr GitHub Action repositiory.
Resources
Idea
This script is based on a suggestion of Benjamin Eberlei
The Code is inspired by https://github.com/mheap/phpunit-github-actions-printer
All versions of annotate-pull-request-from-checkstyle with dependencies
ext-libxml Version *
ext-simplexml Version *