-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
73 lines (60 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
TEST?=$$(go list ./... | grep -v '/vendor/')
VETARGS?=-all
GOFMT_FILES?=$$(find . -name '*.go' | grep -v vendor)
REV?=$$(git rev-parse --short HEAD)
BRANCH?=$$(git rev-parse --abbrev-ref HEAD)
VERSION?="0.0.0"
default: version fmt lint vet test
# Git commands
commit:
@git add .
-@git rm $(git ls-files --others --deleted --exclude-standard)
@git commit
push:
@git push origin ${BRANCH}
version:
@echo "SOFTWARE VERSION"
@echo "\tbranch:\t\t" ${BRANCH}
@echo "\trevision:\t" ${REV}
@echo "\tversion:\t" ${VERSION}
ci: tools build
@echo "CI BUILD..."
tools:
@echo "GO TOOLS installation..."
@go get -u github.com/kardianos/govendor
@go get -u golang.org/x/tools/cmd/cover
@go get -u github.com/golang/lint/golint
build: version test
@echo "GO BUILD..."
@go build -ldflags "-X main.Build=${VERSION} -X main.Revision=${REV} -X main.Branch=${BRANCH}" -v -o golang-tutorial .
lint:
@echo "GO LINT..."
@golint
test: fmt generate lint vet
@echo "GO TEST..."
@go test $(TEST) $(TESTARGS) -timeout=30s -parallel=4 -bench=. -benchmem -cover
cover:
@echo "GO TOOL COVER..."
@go tool cover 2>/dev/null; if [ $$? -eq 3 ]; then \
go get -u golang.org/x/tools/cmd/cover; \
fi
@go test $(TEST) -coverprofile=coverage.out
@go tool cover -html=coverage.out
@rm coverage.out
generate:
@echo "GO GENERATE..."
@go generate $(go list ./... | grep -v /vendor/)
# vet runs the Go source code static analysis tool `vet` to find
# any common errors.
vet:
@echo "GO VET..."
@go tool vet $(VETARGS) $$(ls -d */ | grep -v vendor) ; if [ $$? -eq 1 ]; then \
echo ""; \
echo "Vet found suspicious constructs. Please check the reported constructs"; \
echo "and fix them if necessary before submitting the code for review."; \
exit 1; \
fi
fmt:
@echo "GO FMT..."
@gofmt -w $(GOFMT_FILES)
.PHONY: tools default