2019-05-31 12:26:28 +03:00
|
|
|
GOVERSION := $(shell go version | cut -d ' ' -f 3 | cut -d '.' -f 2)
|
2017-03-03 15:45:23 +03:00
|
|
|
|
2019-05-30 12:21:02 +03:00
|
|
|
.PHONY: check fmt test test-race vet test-cover-html help
|
2017-03-03 15:45:23 +03:00
|
|
|
.DEFAULT_GOAL := help
|
|
|
|
|
2019-05-30 12:21:02 +03:00
|
|
|
check: test-race fmt vet ## Run tests and linters
|
2017-03-03 15:45:23 +03:00
|
|
|
|
|
|
|
test: ## Run tests
|
|
|
|
go test ./...
|
|
|
|
|
|
|
|
test-race: ## Run tests with race detector
|
2019-05-30 12:21:02 +03:00
|
|
|
go test -v -race ./...
|
2017-03-03 15:45:23 +03:00
|
|
|
|
|
|
|
fmt: ## Run gofmt linter
|
2019-05-31 12:26:28 +03:00
|
|
|
ifeq "$(GOVERSION)" "12"
|
2017-03-03 15:45:23 +03:00
|
|
|
@for d in `go list` ; do \
|
|
|
|
if [ "`gofmt -l -s $$GOPATH/src/$$d | tee /dev/stderr`" ]; then \
|
|
|
|
echo "^ improperly formatted go files" && echo && exit 1; \
|
|
|
|
fi \
|
|
|
|
done
|
2019-05-31 12:26:28 +03:00
|
|
|
endif
|
2017-03-03 15:45:23 +03:00
|
|
|
|
|
|
|
|
|
|
|
vet: ## Run go vet linter
|
|
|
|
@if [ "`go vet | tee /dev/stderr`" ]; then \
|
|
|
|
echo "^ go vet errors!" && echo && exit 1; \
|
|
|
|
fi
|
|
|
|
|
|
|
|
test-cover-html: ## Generate test coverage report
|
|
|
|
go test -coverprofile=coverage.out -covermode=count
|
2017-03-03 21:39:13 +03:00
|
|
|
go tool cover -func=coverage.out
|
2017-03-03 15:45:23 +03:00
|
|
|
|
|
|
|
help:
|
|
|
|
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
|