-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
54 lines (44 loc) · 1.79 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
.PHONY: help default test test-run generate lint fmt
GO=go
LDFLAGS?=-s -w
default: lint
generate: install-tools
$(GO) generate ./...
test: install-tools test-run
test-run: ## Run all unit tests
ifdef package
ifdef exclude
$(eval PACKAGES = `go list ./$(package)/... | egrep -iv '$(exclude)' | xargs`)
else
$(eval PACKAGES = "./$(package)/...")
endif
else ifdef exclude
$(eval PACKAGES = `go list ./... | egrep -iv '$(exclude)' | xargs`)
else
$(eval PACKAGES = "./...")
endif
ifeq ($(filter 1,$(debug) $(RUNNER_DEBUG)),)
$(eval TEST_CMD = gotestsum --rerun-fails --format pkgname-and-test-fails --packages="${PACKAGES}" --)
$(eval TEST_OPTIONS = -p=1 -v -failfast -shuffle=on -coverprofile=profile.out -coverpkg=./... -covermode=atomic -vet=all --timeout=60m)
$(eval CMD = $(TEST_CMD) -count=1 $(TEST_OPTIONS) ${PACKAGES})
else
$(eval TEST_CMD = go test)
$(eval TEST_OPTIONS = -p=1 -v -failfast -shuffle=on -coverprofile=profile.out -coverpkg=./... -covermode=atomic -vet=all --timeout=60m)
$(eval CMD = $(TEST_CMD) -count=1 $(TEST_OPTIONS) ${PACKAGES})
endif
$(CMD)
help: ## Show the available commands
@grep -E '^[0-9a-zA-Z_-]+:.*?## .*$$' ./Makefile | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
install-tools:
go install github.com/golang/mock/[email protected]
go install mvdan.cc/gofumpt@latest
go install gotest.tools/[email protected]
go install golang.org/x/tools/cmd/goimports@latest
bash ./internal/scripts/install-golangci-lint.sh v1.61.0
.PHONY: lint
lint: fmt ## Run linters on all go files
golangci-lint run -v --timeout 5m
.PHONY: fmt
fmt: install-tools ## Formats all go files
gofumpt -l -w -extra .
find . -type f -name '*.go' -exec grep -L -E 'Code generated by .*\. DO NOT EDIT.' {} + | xargs goimports -format-only -w -local=github.com/rudderlabs