-
Notifications
You must be signed in to change notification settings - Fork 7
/
Makefile
56 lines (45 loc) · 1.63 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
VERSION := $(shell git describe --abbrev=0 --tags)
LDFLAGS := -X main.Version=$(VERSION)
.PHONY: setup
setup: ## Install all the build and lint dependencies
go get -u github.com/alecthomas/gometalinter
go get -u golang.org/x/tools/cmd/cover
gometalinter --install --update
.PHONY: test
test: ## Run all the tests
echo 'mode: atomic' > coverage.txt && go list ./... | grep -v /vendor/ | xargs -n1 -I{} sh -c 'go test -covermode=atomic -coverprofile=coverage.txt -v -race -timeout=30s {}'
.PHONY: cover
cover: test ## Run all the tests and opens the coverage report
go tool cover -html=coverage.txt
.PHONY: fmt
fmt: ## gofmt and goimports all go files
find . -name '*.go' -not -wholename './vendor/*' | while read -r file; do gofmt -w -s "$$file"; goimports -w "$$file"; done
.PHONY: lint
lint: ## Run all the linters
gometalinter --vendor --disable-all \
--enable=deadcode \
--enable=ineffassign \
--enable=gosimple \
--enable=staticcheck \
--enable=gofmt \
--enable=goimports \
--enable=misspell \
--enable=errcheck \
--enable=vet \
--enable=vetshadow \
--deadline=10m \
./...
.PHONY: ci
ci: lint test ## Run all the tests and code checks
.PHONY: build
build: ## Build a beta version
go build -v -ldflags "$(LDFLAGS)" -o ./bin/go-trace ./cmd/go-trace/
.PHONY: install
install: ## Install to $GOPATH/src
go install -v -ldflags "$(LDFLAGS)" ./cmd/...
# Absolutely awesome: http://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
.PHONY: help
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
.DEFAULT_GOAL := build
default: build