Add option to not fail on only Warnings #198
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.
There is an option to prevent
golangci-lint
from blocking a PR (by setting--issues-exit-code 0
), but there currently is no way to configure the linter to only block on errors, and not on warnings (which seems like reasonable behavior, considering the two options are differentiated and supported by bothgolangci-lint
and GitHub.This PR adds the
allow-warnings: true
option, which, in the event thatgolangci-lint
returns an exit code of1
, causesgolangci-lint-action
to check the output, and if there are no::error
notifications, return an exit code of0
, allowing the PR or Push to proceed.This allows annotating the code with warnings/suggestions that are non-blocking, but blocking in the event that there are errors.
It should be noted that this requires
golangci-lint
to be configured to exit with1
on "Issues". Ifgolangci-lint
does not exit with1
, then the action assumes that it is supposed to pass, and does not modify the exit code. That is to say it either exits with0
ifgolangci-lint
exits with0
, or exits withN
, whereN
is a positive exit code not equal to1
(some other error).The way this should be configured to exit "conditionally" is to set
--issues-exit-code 1
, and inseverity:
set yourdefault-severity:
andrules:
accordingly.This is tested and works accordingly.