-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
76 lines (61 loc) · 1.95 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
65
66
67
68
69
70
71
72
73
74
75
76
help: ## Displays help.
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n\nTargets:\n"} /^[a-z0-9A-Z_-]+:.*?##/ { printf " \033[36m%-10s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST)
include .bingo/Variables.mk
FILES_TO_FMT ?= $(shell find . -path ./vendor -prune -o -name '*.go' -print)
FILES_TO_TEST ?= $(shell go list ./... | grep -v /vendor/)
.PHONY: all
all: go-format go-lint go-test go-bench go-build
.PHONY: install
install: $(BINGO)
$(BINGO) get
.PHONY: format
format: ## Runs all format targets.
format: go-format
.PHONY: lint
lint: ## Runs all lint targets.
lint: go-lint
.PHONY: test
test: ## Runs all test targets.
test: go-test
.PHONY: bench
bench: ## Runs all bench targets.
bench: go-bench
.PHONY: build
build: ## Runs all build targets.
build: go-build
.PHONY: go-format
go-format: ## Formats Go code including imports.
go-format: $(GOIMPORTS) $(GOFUMPT)
@echo ">> formatting Go code"
@$(GOFUMPT) -s -w $(FILES_TO_FMT)
@$(GOIMPORTS) -w $(FILES_TO_FMT)
.PHONY: go-lint
go-lint: ## Lints Go code.
go-lint: $(GOLANGCI_LINT)
@echo ">> linting Go code"
@$(GOLANGCI_LINT) run
.PHONY: go-test
go-test: ## Tests Go code.
go-test:
@echo ">> running Go tests"
@$(GO) test -race $(FILES_TO_TEST);
.PHONY: go-test-action
go-test-action:
go-test-action: $(GOTEST2ACTION)
$(GO) test -race -covermode=atomic -json $(FILES_TO_TEST) | $(GOTEST2ACTION) \
--passthrough \
--root-pkg github.com/MacroPower/go_template
.PHONY: go-bench
go-bench: ## Benchmarks Go code.
go-bench: $(BENCHSTAT)
@echo ">> running Go benchmarks"
@mkdir -p .test
@if [ -f .test/new.txt ]; then mv .test/new.txt .test/old.txt; fi
@$(GO) test -bench=. -benchmem -count=3 $(FILES_TO_TEST) | tee .test/new.txt
@$(BENCHSTAT) .test/old.txt .test/new.txt
.PHONY: go-build
go-build: ## Builds Go executables.
go-build: HOSTNAME:=$(shell hostname)
go-build: $(GORELEASER)
@echo ">> building Go executables"
HOSTNAME=$(HOSTNAME) $(GORELEASER) build --snapshot --clean