Skip to content
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

Add option to not fail on only Warnings #198

Closed
wants to merge 2 commits into from

Conversation

thebeline
Copy link
Contributor

@thebeline thebeline commented Mar 31, 2021

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 both golangci-lint and GitHub.

This PR adds the allow-warnings: true option, which, in the event that golangci-lint returns an exit code of 1, causes golangci-lint-action to check the output, and if there are no ::error notifications, return an exit code of 0, 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 with 1 on "Issues". If golangci-lint does not exit with 1, then the action assumes that it is supposed to pass, and does not modify the exit code. That is to say it either exits with 0 if golangci-lint exits with 0, or exits with N, where N is a positive exit code not equal to 1 (some other error).

The way this should be configured to exit "conditionally" is to set --issues-exit-code 1, and in severity: set your default-severity: and rules: accordingly.

This is tested and works accordingly.

@thebeline thebeline marked this pull request as draft April 3, 2021 14:51
@thebeline
Copy link
Contributor Author

Going to be replaced.

@thebeline
Copy link
Contributor Author

Replaced By: #207

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant