Merge pull request #7496 from hashicorp/dnephin/add-lint-to-makefile

Add lint to makefile
This commit is contained in:
Daniel Nephin 2020-03-26 10:48:21 -04:00 committed by GitHub
commit 2026ea77cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 35 deletions

View File

@ -37,6 +37,8 @@ jobs:
lint:
docker:
- image: *GOLANG_IMAGE
environment:
GOTAGS: "" # No tags for OSS but there are for enterprise
steps:
- checkout
- run:
@ -48,7 +50,7 @@ jobs:
- run:
name: lint
command: &lintcmd |
golangci-lint run -v --concurrency 2
golangci-lint run --build-tags="$GOTAGS" -v --concurrency 2
- run:
name: lint api
working_directory: api

View File

@ -12,3 +12,6 @@ issues:
linters-settings:
gofmt:
simplify: false
run:
timeout: 5m

View File

@ -213,7 +213,7 @@ cov: other-consul dev-build
rm -f coverage.{sdk,api}.part
go tool cover -html=coverage.out
test: other-consul dev-build vet test-internal
test: other-consul dev-build lint test-internal
go-mod-tidy:
@echo "--> Running go mod tidy"
@ -261,21 +261,7 @@ test-internal:
test-race:
$(MAKE) GOTEST_FLAGS=-race
# Run tests with config for CI so `make test` can still be local-dev friendly.
test-ci: other-consul dev-build vet
@ if ! GOTEST_FLAGS="-short -timeout 8m -p 3 -parallel 4" make test-internal; then \
echo " ============"; \
echo " Retrying 1/2"; \
echo " ============"; \
if ! GOTEST_FLAGS="-timeout 9m -p 1 -parallel 1" make test-internal; then \
echo " ============"; \
echo " Retrying 2/2"; \
echo " ============"; \
GOTEST_FLAGS="-timeout 9m -p 1 -parallel 1" make test-internal; \
fi \
fi
test-flake: other-consul vet
test-flake: other-consul lint
@$(SHELL) $(CURDIR)/build-support/scripts/test-flake.sh --pkg "$(FLAKE_PKG)" --test "$(FLAKE_TEST)" --cpus "$(FLAKE_CPUS)" --n "$(FLAKE_N)"
test-docker: linux go-build-image
@ -313,23 +299,11 @@ other-consul:
exit 1 ; \
fi
format:
@echo "--> Running go fmt"
@go fmt ./...
@cd api && go fmt ./... | sed 's@^@api/@'
@cd sdk && go fmt ./... | sed 's@^@sdk/@'
vet:
@echo "--> Running go vet"
@go vet -tags '$(GOTAGS)' ./... && \
(cd api && go vet -tags '$(GOTAGS)' ./...) && \
(cd sdk && go vet -tags '$(GOTAGS)' ./...); if [ $$? -ne 0 ]; then \
echo ""; \
echo "Vet found suspicious constructs. Please check the reported constructs"; \
echo "and fix them if necessary before submitting the code for review."; \
exit 1; \
fi
lint:
@echo "--> Running go golangci-lint"
@golangci-lint run --build-tags '$(GOTAGS)' && \
(cd api && golangci-lint run --build-tags '$(GOTAGS)') && \
(cd sdk && golangci-lint run --build-tags '$(GOTAGS)')
# If you've run "make ui" manually then this will get called for you. This is
# also run as part of the release build script when it verifies that there are no
@ -408,6 +382,6 @@ proto: $(PROTOGOFILES) $(PROTOGOBINFILES)
@$(SHELL) $(CURDIR)/build-support/scripts/proto-gen.sh --grpc --import-replace "$<"
.PHONY: all ci bin dev dist cov test test-ci test-internal cover format vet ui static-assets tools
.PHONY: all ci bin dev dist cov test test-flake test-internal cover lint ui static-assets tools
.PHONY: docker-images go-build-image ui-build-image static-assets-docker consul-docker ui-docker
.PHONY: version proto proto-rebuild proto-delete test-envoy-integ