-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Console][Yaml] Linter: add Github annotations format for errors #38982
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ogizanagi
commented
Nov 4, 2020
stof
requested changes
Nov 4, 2020
stof
reviewed
Nov 4, 2020
stof
reviewed
Nov 4, 2020
jderusse
reviewed
Nov 4, 2020
stof
requested changes
Nov 4, 2020
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably have tests for the annotation reporter
stof
reviewed
Nov 4, 2020
chalasr
reviewed
Nov 15, 2020
derrabus
reviewed
Nov 15, 2020
chalasr
approved these changes
Nov 17, 2020
jderusse
approved these changes
Nov 19, 2020
Thank you @ogizanagi. |
2 tasks
@ogizanagi Can you take care of creating the doc issue for this? I accidentally skipped it during the merge |
2 tasks
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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