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-lintfrom 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-lintand GitHub.This PR adds the
allow-warnings: trueoption, which, in the event thatgolangci-lintreturns an exit code of1, causesgolangci-lint-actionto check the output, and if there are no::errornotifications, 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-lintto be configured to exit with1on "Issues". Ifgolangci-lintdoes 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 with0ifgolangci-lintexits with0, or exits withN, whereNis 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.