-
Notifications
You must be signed in to change notification settings - Fork 7
/
Makefile
81 lines (68 loc) · 2.51 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
76
77
78
79
80
81
.PHONY: test ctest covdir coverage docs linter qtest clean dep
APP_VERSION:=$(shell cat VERSION | head -1)
GIT_COMMIT:=$(shell git describe --dirty --always)
GIT_BRANCH:=$(shell git rev-parse --abbrev-ref HEAD -- | head -1)
BUILD_USER:=$(shell whoami)
BUILD_DATE:=$(shell date +"%Y-%m-%d")
BINARY:="health-check"
VERBOSE:=-v
ifdef TEST
TEST:="-run ${TEST}"
endif
all:
@echo "Version: $(APP_VERSION), Branch: $(GIT_BRANCH), Revision: $(GIT_COMMIT)"
@echo "Build on $(BUILD_DATE) by $(BUILD_USER)"
@mkdir -p bin/
@CGO_ENABLED=0 go build -o bin/$(BINARY) $(VERBOSE)
@echo "Done!"
linter:
@echo "Running lint checks"
golint cmd/coredns-healthcheck/*.go
golint pkg/health/*.go
golint pkg/engine/*.go
@echo "PASS: golint"
test: covdir linter
@go test $(VERBOSE) -coverprofile=.coverage/coverage.out ./pkg/health/*.go
@go test $(VERBOSE) -coverprofile=.coverage/coverage.out ./pkg/engine/*.go
ctest: covdir linter
@richgo version || go get -u github.com/kyoh86/richgo
@time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out ./pkg/health/*.go
@time richgo test $(VERBOSE) $(TEST) -coverprofile=.coverage/coverage.out ./pkg/engine/*.go
covdir:
@echo "Creating .coverage/ directory"
@mkdir -p .coverage
coverage:
@go tool cover -html=.coverage/coverage.out -o .coverage/coverage.html
docs:
@mkdir -p .doc
@godoc -html github.com/wjayesh/coredns-health/pkg/ > .doc/index.html
@echo "Run to serve docs:"
@echo " godoc -goroot .doc/ -html -http \":5000\""
clean:
@rm -rf .doc
@rm -rf .coverage
@rm -rf bin/
qtest:
@echo "Perform quick tests ..."
@go test -v -run TestClient ./pkg/health/*.go
@go test -v -run TestClient ./pkg/engine/*.go
@#go test -v -run TestParseInfoJsonOutput ./pkg/health/*.go
dep:
@echo "Making dependencies check ..."
@golint || go get -u golang.org/x/lint/golint
@#echo "Clean GOPATH/pkg/dep/sources/ if necessary"
@#rm -rf $GOPATH/pkg/dep/sources/https---github.com-wjayesh*
release:
@echo "Making release"
@if [ $(GIT_BRANCH) != "master" ]; then echo "cannot release to non-master branch $(GIT_BRANCH)" && false; fi
@git diff-index --quiet HEAD -- || ( echo "git directory is dirty, commit changes first" && false )
@versioned -patch
@echo "Patched version"
@git add VERSION
@git commit -m "released v`cat VERSION | head -1`"
@git tag -a v`cat VERSION | head -1` -m "v`cat VERSION | head -1`"
@git push
@git push --tags
@@echo "If necessary, run the following commands:"
@echo " git push --delete origin v$(PLUGIN_VERSION)"
@echo " git tag --delete v$(PLUGIN_VERSION)"