-
Notifications
You must be signed in to change notification settings - Fork 30
/
Makefile
135 lines (113 loc) · 3.64 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
133
134
135
export GO15VENDOREXPERIMENT=1
PACKAGES=$(shell govendor list -no-status +local)
NOVENDOR=$(shell find . -path ./specs/**/*/vendor -prune -o -path ./vendor -prune -o -name '*.go' -print)
LINE_LENGTH_EXCLUDE=./cluster/machine/amazon.go \
./cluster/machine/google.go \
./cluster/cloudcfg/template.go \
./cluster/amazon/mock_client.go \
./cluster/google/mock_client_test.go \
./minion/network/link_test.go \
./minion/pb/pb.pb.go \
./api/pb/pb.pb.go \
./stitch/bindings.js.go
REPO = quilt
DOCKER = docker
SHELL := /bin/bash
all:
cd -P . && go build .
install:
cd -P . && go install .
check: format-check
govendor test +local
clean:
govendor clean -x +local
rm -f *.cov.coverprofile cluster/*.cov.coverprofile minion/*.cov.coverprofile specs/*.cov.coverprofile
rm -f *.cov.html cluster/*.cov.html minion/*.cov.html specs/*.cov.html
COV_SKIP= /api/client/mocks \
/api/pb \
/cluster/provider/mocks \
/constants \
/minion/pprofile \
/quilt-tester \
/quilt-tester/tests/10-network \
/quilt-tester/tests/15-bandwidth \
/quilt-tester/tests/20-spark \
/quilt-tester/tests/30-mean \
/quilt-tester/tests/40-stop \
/quilt-tester/tests/100-logs \
/quilt-tester/tests/75-network \
/quilt-tester/tests/pub-facing \
/quiltctl/testutils \
/scripts \
/minion/pb
COV_PKG = $(subst github.com/NetSys/quilt,,$(PACKAGES))
coverage: $(addsuffix .cov, $(filter-out $(COV_SKIP), $(COV_PKG)))
echo "" > coverage.txt
for f in $^ ; do \
cat .$$f >> coverage.txt ; \
done
%.cov:
go test -coverprofile=.$@ .$*
go tool cover -html=.$@ -o [email protected]
format: scripts/format
gofmt -w -s $(NOVENDOR)
scripts/format $(filter-out $(LINE_LENGTH_EXCLUDE),$(NOVENDOR))
scripts/format: scripts/format.go
cd scripts && go build format.go
format-check:
RESULT=`gofmt -s -l $(NOVENDOR)` && \
if [[ -n "$$RESULT" ]] ; then \
echo $$RESULT && \
exit 1 ; \
fi
lint: format
cd -P . && govendor vet +local
EXIT_CODE=0; \
for package in $(PACKAGES) ; do \
if [[ $$package != *minion/pb* && $$package != *api/pb* ]] ; then \
golint -min_confidence .25 -set_exit_status $$package || EXIT_CODE=1; \
fi \
done ; \
find . -path ./vendor -prune -o -name '*' -type f -print | xargs misspell -error || EXIT_CODE=1; \
ineffassign . || EXIT_CODE=1; \
exit $$EXIT_CODE
generate:
govendor generate +local
providers:
python3 scripts/gce-descriptions > cluster/machine/google.go
# This is what's strictly required for `make check lint` to run.
get-build-tools:
go get -v -u \
github.com/client9/misspell/cmd/misspell \
github.com/golang/lint/golint \
github.com/gordonklaus/ineffassign \
github.com/kardianos/govendor
# This additionally contains the tools needed for `go generate` to work.
go-get: get-build-tools
go get -v -u \
github.com/golang/protobuf/{proto,protoc-gen-go} \
github.com/vektra/mockery/.../
tests:
cd -P quilt-tester && \
for suite in tests/* ; do \
for f in $$suite/* ; do \
if [ $${f: -3} == ".go" ] ; then \
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o $${f%???} $$f ; \
fi \
done \
done
docker-build-quilt:
cd -P . && git show --pretty=medium --no-patch > buildinfo \
&& CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build . \
&& ${DOCKER} build -t ${REPO}/quilt .
docker-push-quilt:
${DOCKER} push ${REPO}/quilt
docker-build-tester: tests
cd -P quilt-tester \
&& CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
go build -o bin/quilt-tester . \
&& ${DOCKER} build -t ${REPO}/tester .
docker-build-ovs:
cd -P ovs && docker build -t ${REPO}/ovs .
# Include all .mk files so you can have your own local configurations
include $(wildcard *.mk)