-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
51 lines (39 loc) · 1.69 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
# This repo's root import path.
PKG := gitlab.com/screwyprof/golibs
## DO NOT EDIT BELLOW THIS LINE
GO_FILES = $(shell find . -name "*.go" | uniq)
GO_PACKAGES = $(shell go list ./... | tr '\n', ',')
LOCAL_PACKAGES="github.com/screwyprof/"
SHELL := bash
OK_COLOR=\033[32;01m
NO_COLOR=\033[0m
MAKE_COLOR=\033[33;01m%-20s\033[0m
all: deps fmt test ## download deps, format code, run tests
deps: ## sync go mod deps
@echo -e "$(OK_COLOR)--> Installing dev dependencies and tools$(NO_COLOR)"
go install mvdan.cc/[email protected]
go install github.com/daixiang0/[email protected]
fmt: ## format go files
@echo -e "$(OK_COLOR)--> Formatting go files$(NO_COLOR)"
@go mod tidy
@go fmt ./...
@gofumpt -l -w .
@gci write $(GO_FILES) -s standard -s default -s "prefix($(LOCAL_PACKAGES))"
lint: ## run linters for current changes
@echo -e "$(OK_COLOR)==> Linting current changes$(NO_COLOR)"
golangci-lint run ./...
test: ## run all tests
@echo -e "$(OK_COLOR)--> Running unit tests$(NO_COLOR)"
go test -v --race --count=1 -coverprofile=coverage.out ./...
coverage: test ## show test coverage report
@echo -e "$(OK_COLOR)--> Showing test coverage$(NO_COLOR)"
go tool cover -func=coverage.out
clean: ## remove build artifacts and generated files
@echo -e "$(OK_COLOR)--> Cleaning up$(NO_COLOR)"
rm -f coverage.out
help: ## show this help screen
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {sub("\\\\n",sprintf("\n%22c"," "), $$2);printf "$(MAKE_COLOR) %s\n", $$1, $$2}' $(MAKEFILE_LIST)
# To avoid unintended conflicts with file names, always add to .PHONY
# unless there is a reason not to.
# https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html
.PHONY: all deps fmt lint test coverage clean help