Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
[Console][Yaml] Linter: add Github annotations format for errors #38982
Conversation
We should probably have tests for the annotation reporter |
2d4a9d3
to
b9bf9fe
b659dbf
to
af02f3d
Thank you @ogizanagi. |
@ogizanagi Can you take care of creating the doc issue for this? I accidentally skipped it during the merge |
Github actions can write errors and warning directly in their output, which result into annotations into the Github checks. It can even provide a filename, line & col number, allowing to display the annnotations inside the PR diff directly, at the right place.
More advanced usage of annotations can be made using the API, but regarding the linters provided in Symfony components, it seems the shortcut using output is a great way to enhance the integration with Github Actions.
This PR starts by proposing these changes in the yaml linter:
github
format, which is the same as thetxt
one, except for errors and warning, for which we'll adapt the output to the Github annotations format.txt
format as default, and autodetect if the script is running in a Github action context, then usegithub
format. If it's not, we fallback totxt
as before.Once we agree on the details, we could perform the same for other linters (xliff, twig, ...)
Here is a PR using it: ogizanagi/symfony-lint-gha-demo#2
and some screenshots:
(tests to add)This was inspired by PHPStan which is already auto-adapting the output according to the CI, using https://github.com/OndraM/ci-detector