-
Notifications
You must be signed in to change notification settings - Fork 42
/
Makefile
59 lines (43 loc) · 1.71 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
SOURCES := $(shell find . -name '*.go' -not -path "*/vendor/*" -not -path "*/.git/*")
.DEFAULT_GOAL := build
# bingo manages consistent tooling versions for things like kind, kustomize, etc.
include .bingo/Variables.mk
build: $(SOURCES) ## Build Test
go build -ldflags="-s -w" ./...
lint: $(GOLANGCI_LINT) ## Run golangci-lint
@$(GOLANGCI_LINT) run
lint-fix: $(GOLANGCI_LINT) ## Run golangci lint to automatically perform fixes
@$(GOLANGCI_LINT) run --fix
fmt: ## Run go fmt
@go fmt ./...
fmtcheck: ## Check go formatting
@gofmt -l $(SOURCES) | grep ".*\.go"; if [ "$$?" = "0" ]; then exit 1; fi
test: ## Run unit tests
@go test -race -covermode atomic -coverprofile cover.out ./...
vet: ## Run go vet
@go vet ./...
tidy: ## Tidy go dependencies
@go mod tidy
.PHONY: bingo-upgrade
bingo-upgrade: $(BINGO) #EXHELP Upgrade tools
@for pkg in $$($(BINGO) list | awk '{ print $$1 }' | tail -n +3); do \
echo "Upgrading $$pkg to latest..."; \
$(BINGO) get "$$pkg@latest"; \
done
check-license: $(SOURCES) ## Check license headers
@./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 cover.out
# 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: build lint lint-fix fmt fmtcheck test vet tidy check-license check clean golangci-lint help