forked from softlayer/softlayer-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
75 lines (59 loc) · 1.75 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
GO_CMD=go
GO_BUILD=$(GO_CMD) build
GO_DEPS=$(GO_CMD) get -d -v
GO_DEPS_UPDATE=$(GO_DEPS) -u
GO_FMT=gofmt
GO_INSTALL=$(GO_CMD) install
GO_RUN=$(GO_CMD) run
GO_TEST=$(GO_CMD) test
TOOLS=$(GO_RUN) tools/*.go
VETARGS?=-all
PACKAGE_LIST := $$(go list ./... | grep -v '/vendor/')
.PHONY: all alpha build deps fmt fmtcheck generate install release test test_deps update_deps 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_DEPS) ./...
fmt:
@$(GO_FMT) -w `find . -name '*.go' | grep -v vendor`
fmtcheck:
@fmt_list=$$($(GO_FMT) -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:
@$(TOOLS) generate
install: fmtcheck deps
@$(GO_INSTALL) ./...
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 test_deps
@$(GO_TEST) $(PACKAGE_LIST) -timeout=30s -parallel=4
test_deps:
$(GO_DEPS) -t ./...
update_deps:
$(GO_DEPS_UPDATE) ./...
version:
@$(TOOLS) version
# vet runs the Go source code static analysis tool `vet` to find
# any common errors.
vet:
@echo "go tool vet $(VETARGS) ."
@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