Introduce ErrorFormatter for GitHub Actions#261
Conversation
There was a problem hiding this comment.
Composition over inheritance should be used. Ask for TableErrorFormatter in the constructor, do not extend from it.
|
While I'm applying the changes, you can find more details about the annotations here: https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-error-message |
|
Would be a good idea to link it in the implementation :) |
74f6bab to
cbba0cd
Compare
|
Changes have been applied. :) About your question:
GitHub will display them anyway in a dedicated space, below the diff. Unfortunately I don't have any link to provide as an example (the PR was updated), only a screenshot I took while PHPStan was in action. |
cbba0cd to
3cd86c0
Compare
|
That’s really nice! Could we somehow incorporate notFileSpecificErrors too? How GitHub behaves when we add an error to a nonexistent file? |
|
To achieve the same effect I usually use the checkstyle output format and https://github.com/staabm/annotate-pull-request-from-checkstyle This works across different tools and is already bundled in the often used GithubAction shivammathur/setup-php tools |
|
@Quetzacoalt91 I really like how it looks! Besides notFileSpecificErrors, we could also present warnings as actual warnings. You can create a warning for example by not escaping regex-special characters in * Generates a warning: @staabm I'm aware of this but built-in formatter creates new opportunities like do this by default if we detect we're running in GitHub Actions. |
|
All right, at the same time I added the warning you were talking about, I added the generic errors as GitHub handle them in a way. |
f8bdd6a to
f689aac
Compare
|
Thank you, I love it. Will merge it if the build passes. I'll also try to make it the default, but I want to tackle that myself. |
|
Thanks for your time with the improvements, I’m glad you like it. :) |
|
Is the same or similar possible for Gitlab? |
|
Doesn't look like so: https://twitter.com/johannpardanaud/status/1278273861088395264 There's already a |


This PR allows PHPStan to report errors on the GitHub interface when used with GitHub Actions, in pull-requests changes. We started using this formatter at PrestaShop to help our contributor to find the required changes easily (PrestaShop/php-dev-tools#24).
Note the only displayed errors are targeting a specific line of a file, generic errors (= Not file specific) are not concerned. For developers looking at the complete report in the log, the class
TableErrorFormatteris used so they can read the default view.