-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathMakefile
65 lines (50 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
57
58
59
60
61
62
63
64
65
TOOLS=go run ./tools
VETARGS?=-all
COVERPROFILE=coverage.out
PACKAGE_LIST := $$(go list ./... | grep -v '/vendor/')
.PHONY: all alpha build deps fmt fmtcheck generate release test coverage version vet
all: build
alpha:
@$(TOOLS) version --bump patch --prerelease alpha
git add sl/version.go
git commit -m "Bump version"
git push
build: fmtcheck vet deps
go build ./...
deps:
go mod vendor
fmt:
gofmt -w `find . -name '*.go' | grep -v vendor`
fmtcheck:
@fmt_list=$$(gofmt -e -l `find . -name '*.go' | grep -v vendor`) && \
[ -z $${fmt_list} ] || \
(echo "gofmt needs to be run on the following files:" \
&& echo "$${fmt_list}" && \
echo "You can run 'make fmt' to format code" && false)
generate:
go run ./tools generate
release: build
@NEW_VERSION=$$($(TOOLS) version --bump patch) && \
git add sl/version.go && \
git commit -m "Cut release $${NEW_VERSION}" && \
git tag $${NEW_VERSION} && \
git push && \
git push origin $${NEW_VERSION}
test: fmtcheck vet deps
go test $(PACKAGE_LIST) -timeout=30s
coverage:
@echo "Running unit tests. Cover profile saved to $(COVERPROFILE) ...\n"
go test $(PACKAGE_LIST) -timeout=30s -coverprofile=$(COVERPROFILE)
@echo "\nBuilding function coverage report...\n"
go tool cover -func=$(COVERPROFILE)
version:
@$(TOOLS) version
# vet runs the Go source code static analysis tool `vet` to find
# any common errors.
vet:
@go vet $(VETARGS) $$(go list ./... | grep -v datatypes) ; 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