Add lint to makefile
And support for setting build tags in CI lint job. Removed the unused 'test-ci' target.
This commit is contained in:
parent
8fa1388ba3
commit
874788dd66
|
@ -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
|
||||
|
|
|
@ -12,3 +12,6 @@ issues:
|
|||
linters-settings:
|
||||
gofmt:
|
||||
simplify: false
|
||||
|
||||
run:
|
||||
timeout: 5m
|
||||
|
|
42
GNUmakefile
42
GNUmakefile
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue