Fail the build on lint warnings

Golint by default doesn't return a non-zero exit code when lint errors
are present.  To address this, we need to pass -set_exit_status.

But it gets more complicated: because we are suppressing some lint
warnings, we cannot use -set_exit_status in the lint_quiet target.
For that, we use test -z to fail if any output passes the filter.

Eventually when we do pulumi/lumi#191, we can remove this hack.
This commit is contained in:
joeduffy 2017-06-02 09:05:28 -07:00
parent ff37f0b8f9
commit 717609a31b

View file

@ -22,13 +22,15 @@ install:
lint:
@echo "\033[0;32mLINT:\033[0m"
@golint cmd/...
@golint pkg/...
@golint -set_exit_status cmd/...
@golint -set_exit_status pkg/...
lint_quiet:
@echo "\033[0;32mLINT (quiet):\033[0m"
@echo "`golint cmd/... | grep -v "or be unexported"`"
@echo "`golint pkg/... | grep -v "or be unexported"`"
test -z "$$(golint cmd/... | grep -v 'or be unexported')"
test -z "$$(golint pkg/... | grep -v 'or be unexported')"
@echo "\033[0;33mgolint was run quietly; to run with noisy errors, run 'make lint'\033[0m"
test: