forked from moby/libnetwork
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
149 lines (129 loc) · 4.38 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
.PHONY: all all-local build build-local clean cross cross-local check check-code check-format run-tests integration-tests check-local coveralls circle-ci-cross circle-ci-build circle-ci-check circle-ci
SHELL=/bin/bash
build_image=libnetworkbuild
dockerargs = --privileged -v $(shell pwd):/go/src/github.com/docker/libnetwork -w /go/src/github.com/docker/libnetwork
container_env = -e "INSIDECONTAINER=-incontainer=true"
docker = docker run --rm -it ${dockerargs} $$EXTRA_ARGS ${container_env} ${build_image}
ciargs = -e CIRCLECI -e "COVERALLS_TOKEN=$$COVERALLS_TOKEN" -e "INSIDECONTAINER=-incontainer=true"
cidocker = docker run ${dockerargs} ${ciargs} $$EXTRA_ARGS ${container_env} ${build_image}
CROSS_PLATFORMS = linux/amd64 linux/386 linux/arm windows/amd64
export PATH := $(CURDIR)/bin:$(PATH)
hostOS = ${shell go env GOHOSTOS}
ifeq (${hostOS}, solaris)
gnufind=gfind
gnutail=gtail
else
gnufind=find
gnutail=tail
endif
all: ${build_image}.created build check integration-tests clean
all-local: build-local check-local integration-tests-local clean
${build_image}.created:
docker build -f Dockerfile.build -t ${build_image} .
touch ${build_image}.created
build: ${build_image}.created
@echo "Building code... "
@${docker} ./wrapmake.sh build-local
@echo "Done building code"
build-local:
@mkdir -p "bin"
go build -tags experimental -o "bin/dnet" ./cmd/dnet
go build -o "bin/docker-proxy" ./cmd/proxy
clean:
@if [ -d bin ]; then \
echo "Removing dnet and proxy binaries"; \
rm -rf bin; \
fi
cross: ${build_image}.created
@mkdir -p "bin"
@for platform in ${CROSS_PLATFORMS}; do \
EXTRA_ARGS="-e GOOS=$${platform%/*} -e GOARCH=$${platform##*/}" ; \
echo "$${platform}..." ; \
${docker} make cross-local ; \
done
cross-local:
go build -o "bin/dnet-$$GOOS-$$GOARCH" ./cmd/dnet
go build -o "bin/docker-proxy-$$GOOS-$$GOARCH" ./cmd/proxy
check: ${build_image}.created
@${docker} ./wrapmake.sh check-local
check-code:
@echo "Checking code... "
test -z "$$(golint ./... | grep -Ev 'vendor|.pb.go:' | tee /dev/stderr)"
test -z "$$(go vet ./... 2>&1 > /dev/null | grep -Ev 'vendor|exit' | tee /dev/stderr)"
@echo "Done checking code"
check-format:
@echo "Checking format... "
test -z "$$(gofmt -s -l . | grep -v vendor/ | tee /dev/stderr)"
@echo "Done checking format"
run-tests:
@echo "Running tests... "
@echo "mode: count" > coverage.coverprofile
@for dir in $$( ${gnufind} . -maxdepth 10 -not -path './.git*' -not -path '*/_*' -not -path './vendor/*' -type d); do \
if [ ${hostOS} == solaris ]; then \
case "$$dir" in \
"./cmd/dnet" ) \
;& \
"./cmd/ovrouter" ) \
;& \
"./ns" ) \
;& \
"./iptables" ) \
;& \
"./ipvs" ) \
;& \
"./drivers/bridge" ) \
;& \
"./drivers/host" ) \
;& \
"./drivers/ipvlan" ) \
;& \
"./drivers/macvlan" ) \
;& \
"./drivers/overlay" ) \
;& \
"./drivers/remote" ) \
;& \
"./drivers/windows" ) \
echo "Skipping $$dir on solaris host... "; \
continue; \
;; \
* )\
echo "Entering $$dir ... "; \
;; \
esac; \
fi; \
if ls $$dir/*.go &> /dev/null; then \
pushd . &> /dev/null ; \
cd $$dir ; \
go test ${INSIDECONTAINER} -test.parallel 5 -test.v -covermode=count -coverprofile=./profile.tmp ; \
ret=$$? ;\
if [ $$ret -ne 0 ]; then exit $$ret; fi ;\
popd &> /dev/null; \
if [ -f $$dir/profile.tmp ]; then \
cat $$dir/profile.tmp | ${gnutail} -n +2 >> coverage.coverprofile ; \
rm $$dir/profile.tmp ; \
fi ; \
fi ; \
done
@echo "Done running tests"
check-local: check-format check-code run-tests
integration-tests: ./bin/dnet
@./test/integration/dnet/run-integration-tests.sh
./bin/dnet:
make build
coveralls:
-@goveralls -service circleci -coverprofile=coverage.coverprofile -repotoken $$COVERALLS_TOKEN
# CircleCI's Docker fails when cleaning up using the --rm flag
# The following targets are a workaround for this
circle-ci-cross: ${build_image}.created
@mkdir -p "bin"
@for platform in ${CROSS_PLATFORMS}; do \
EXTRA_ARGS="-e GOOS=$${platform%/*} -e GOARCH=$${platform##*/}" ; \
echo "$${platform}..." ; \
${cidocker} make cross-local ; \
done
circle-ci-check: ${build_image}.created
@${cidocker} make check-local coveralls
circle-ci-build: ${build_image}.created
@${cidocker} make build-local
circle-ci: circle-ci-build circle-ci-check circle-ci-cross integration-tests