-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
64 lines (48 loc) · 1.83 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
SOURCE_DIRS = handler leader predicate status
SOURCES := $(shell find . -name '*.go' -not -path "*/vendor/*" -not -path "*/.git/*")
.DEFAULT_GOAL := build
# ensure: ## Install or update project dependencies
# @dep ensure
build: $(SOURCES) ## Build Test
go build -i -ldflags="-s -w" ./...
lint: golangci-lint ## Run golint
@$(GOLANGCI_LINT) run
lint-fix: golangci-lint ## Run golint fix
@$(GOLANGCI_LINT) run --fix
fmt: ## Run go fmt
@gofmt -d $(SOURCES)
fmtcheck: ## Check go formatting
@gofmt -l $(SOURCES) | grep ".*\.go"; if [ "$$?" = "0" ]; then exit 1; fi
test: ## Run unit tests
@go test -race -covermode atomic -tags integration -coverprofile cover.out $(addprefix ./, $(addsuffix /... , $(SOURCE_DIRS)))
vet: ## Run go vet
@go vet $(addprefix ./, $(SOURCE_DIRS))
tidy: ## Tidy go dependencies
@go mod tidy
check-license: $(SOURCES)
@./hack/check-license.sh "$(SOURCES)"
check: tidy fmtcheck vet lint build test check-license ## Pre-flight checks before creating PR
@git diff --exit-code
clean: ## Clean up your working environment
@rm -f coverage-all.out coverage.out
golangci-lint:
ifeq (, $(shell which golangci-lint))
@{ \
set -e ;\
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin v1.29.0 ;\
}
GOLANGCI_LINT=$(shell go env GOPATH)/bin/golangci-lint
else
GOLANGCI_LINT=$(shell which golangci-lint)
endif
# generate: ## regenerate mocks
# go get github.com/vektra/mockery/.../
# @go generate ./...
help: ## Show this help screen
@echo 'Usage: make <OPTIONS> ... <TARGETS>'
@echo ''
@echo 'Available targets are:'
@echo ''
@grep -E '^[ a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
.PHONY: ensure build lint fmt fmtcheck test vet check help clean