forked from asteris-llc/converge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
132 lines (106 loc) · 4.34 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
NAME = $(shell awk -F\" '/^const Name/ { print $$2 }' cmd/root.go)
VERSION = $(shell awk -F\" '/^const Version/ { print $$2 }' cmd/version.go)
RPCLINT=$(shell find ./rpc -type f \( -not -iname 'root.*.go' -iname '*.go' \) )
TOLINT = $(shell find . -type f \( -not -ipath './vendor*' -not -ipath './docs_source*' -not -ipath './rpc*' -not -iname 'main.go' -iname '*.go' \) -exec dirname {} \; | sort -u)
TESTDIRS = $(shell find . -name '*_test.go' -exec dirname \{\} \; | grep -v vendor | uniq)
NONVENDOR = ${shell find . -name '*.go' | grep -v vendor}
BENCHDIRS= $(shell find . -name '*_test.go' | grep -v vendor | xargs grep '*testing.B' | cut -d: -f1 | xargs dirname | uniq)
BENCH = .
converge: $(shell find . -name '*.go') rpc/pb/root.pb.go rpc/pb/root.pb.gw.go
go build -ldflags="-s -w" .
test: converge gotest samples/*.hcl samples/errors/*.hcl blackbox/*.sh
@echo
@echo === check validity of all samples ===
./converge validate samples/*.hcl
@echo
@echo === check formatting of all samples ===
./converge fmt --check samples/*.hcl
gotest:
go test ${TESTDIRS}
license-check:
@echo "=== Missing License Files ==="
@./check_license.sh
bench:
go test -run='^$$' -bench=${BENCH} -benchmem ${BENCHDIRS}
samples/errors/*.hcl: converge
@echo
@echo === validating $@ should fail ==
./converge validate $@ || exit 0 && exit 1
blackbox/*.sh: converge
@echo
@echo === testing $@ ===
@$@
samples/%.png: samples/% converge
@echo
@echo === rendering $@ ===
./converge graph --local $< | dot -Tpng -o$@
lint:
@echo '# golint'
@for dir in ${TOLINT}; do golint $${dir}/...; done # github.com/golang/lint/golint
@for file in ${RPCLINT}; do golint $${file}; done # github.com/golang/lint/golint
@echo '# go tool vet'
@go tool vet -all -shadow ${TOLINT}
@go tool vet -all -shadow ${RPCLINT} # built in
@echo '# gosimple'
@gosimple ${TOLINT} # honnef.co/go/simple/cmd/gosimple
@gosimple ${RPCLINT} # honnef.co/go/simple/cmd/gosimple
@echo '# unconvert'
@unconvert ${TOLINT} # github.com/mdempsky/unconvert
@unconvert ${RPCLINT} # github.com/mdempsky/unconvert
@echo '# structcheck'
@structcheck ${TOLINT} # github.com/opennota/check/cmd/structcheck
@structcheck ${RPCLINT} # github.com/opennota/check/cmd/structcheck
@echo '# varcheck'
@varcheck ${TOLINT} # github.com/opennota/check/cmd/varcheck
@varcheck ${RPCLINT} # github.com/opennota/check/cmd/varcheck
@echo '# aligncheck'
@aligncheck ${TOLINT} # github.com/opennota/check/cmd/aligncheck
@aligncheck ${RPCLINT} # github.com/opennota/check/cmd/aligncheck
@echo '# gas'
@gas ${TOLINT} # github.com/HewlettPackard/gas
@gas ${RPCLINT} # github.com/HewlettPackard/gas
vendor: ${NONVENDOR}
glide install --strip-vcs --strip-vendor --update-vendored
make vendor-clean
vendor-update: ${NOVENDOR}
glide update --strip-vcs --strip-vendor --update-vendored
make vendor-clean
vendor-clean: ${NOVENDOR}
find vendor -not -name '*.go' -not -name '*.s' -not -name '*.pl' -not -name '*.c' -not -name LICENSE -not -name '*.proto' -type f -delete
xcompile: rpc/pb/root.pb.go rpc/pb/root.pb.gw.go test
@rm -rf build/
@mkdir -p build/
gox \
-ldflags="-s -w" \
-osarch="darwin/386" \
-osarch="darwin/amd64" \
-os="linux" \
-os="freebsd" \
-os="solaris" \
-output="build/$(NAME)_$(VERSION)_{{.OS}}_{{.Arch}}/$(NAME)"
package: xcompile
@mkdir -p build/tgz
for f in $(shell find build -name converge | cut -d/ -f2); do \
(cd $(shell pwd)/build/$$f && tar -zcvf ../tgz/$$f.tar.gz converge); \
echo $$f; \
done
rpc/pb/root.pb.go: rpc/pb/root.proto
protoc -I rpc/pb \
-I vendor/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
--go_out=Mgoogle/api/annotations.proto=github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis/google/api,plugins=grpc:rpc/pb \
rpc/pb/root.proto
rpc/pb/root.pb.gw.go: rpc/pb/root.proto
protoc -I rpc/pb \
-I vendor/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
--grpc-gateway_out=logtostderr=true:rpc/pb \
rpc/pb/root.proto
rpc/pb/root.swagger.json: rpc/pb/root.proto
protoc -I rpc/pb \
-I vendor/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
--swagger_out=logtostderr=true:rpc/pb \
rpc/pb/root.proto
docs: docs_source/**/*
rm -rf docs || true
$(MAKE) -C docs_source
mv docs_source/public docs
.PHONY: test gotest vendor-update vendor-clean xcompile package samples/errors/*.hcl blackbox/*.sh lint bench license-check