Migrate to octokit handling of Annotations #207
Closed
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.
This does a bunch... But also, not that much. In summary, it switches to using the
json
output ofgolangci-lint
and handling the formatting and reporting to GitHub inside of the action. This allows for a more flexibility in how the lint issues are handled than simply passing the text output to the Action Log (which is allgolangci-lint
would be able to do). With this approach, the action can resolve a number of issues, and is in a better position to resolve a few more. The active changes in this PR are:Allows verbose reporting of Issues in Run Terminal/Log, regardless of event type
Resolves: github action log output doesn't print the affected file name & line #119
Additionally adds support for Severity Failure levels via
--failure-level
(defaults to 'notice' [all])Replaces: Add option to not fail on only Warnings #198
Resolves Discussion: Change staticcheck severity to warning golangci-lint#1853
Adds suggested fixes to Annotation Raw Details
Partially Resolves: Ability to make suggested changes on a PR #35
Prepares foundation for supporting Comments
Related: Support comments instead of annotations #5
Adds mapping for common Issue Severities to GitHub Severities (Code climate | Checkstyle | GitHub)
This avoids a potential issue of having a severity that is not supported by GitHub configured, which, in it's current implementation,
golangci-lint
would just echo, and would not behave as expected in the Action.Adds handling of 'Ignore' Issue Severity (removes from Issue List)
Adds support for Multi-Line Annotations
Adds support for Character Range Annotations
Note on Severity Levels and
ignore
: Failure is determined bygolangci-lint
exiting with a non-zero code and the Issues List containing at least one Issue with a Severity Level equal to or greater than the setting of--failure-level
. This defaults tonotice
, and can be one ofnotice
,warning
, orfailure
.Ignore is stripped from the Issues list, and therefore is neither reported to the Log, or grounds for
failure
(a run that reports only Issues of severity levelignore
will not fail, even ifgolangci-lint
exits with1
). It is not possible to set thefailure-level
toignore
either. Additionally, it is not possible to not fail on a severity level offailure
.With that in mind, this offers a few options on Conditional Failure:
ignore
, and you will not see it or fail on it.notice
orwarning
, and set--failure-level
to the next severity up.Consideration: I set the default
--failure-level
tonotice
because, in the current implementation, any Lint Issue can cause a Failure, and I didn't want to change the behavior too much (that being said, handling ofignore
already changes this behavior, but that seemed expected). However, it would make the most sense, semantically, to have the default--failure-level
set towarning
. What are your thoughts?As you can see, if the Action has access to the full output, there is a lot that can be done fairly quickly.
With regards to Comments (#5): There is a bit of work that would need to be done to fully do this, but this sets the stage fairly nicely.