2015-05-20 15:28:58 -04:00
|
|
|
.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
|
2015-04-16 15:00:36 -04:00
|
|
|
SHELL=/bin/bash
|
2015-10-16 14:33:08 -04:00
|
|
|
build_image=libnetworkbuild
|
2015-05-11 11:02:25 -04:00
|
|
|
dockerargs = --privileged -v $(shell pwd):/go/src/github.com/docker/libnetwork -w /go/src/github.com/docker/libnetwork
|
2015-05-12 19:39:30 -04:00
|
|
|
container_env = -e "INSIDECONTAINER=-incontainer=true"
|
2015-05-20 15:28:58 -04:00
|
|
|
docker = docker run --rm -it ${dockerargs} $$EXTRA_ARGS ${container_env} ${build_image}
|
2016-01-05 14:35:53 -05:00
|
|
|
ciargs = -e CIRCLECI -e "COVERALLS_TOKEN=$$COVERALLS_TOKEN" -e "INSIDECONTAINER=-incontainer=true"
|
2016-04-21 14:20:01 -04:00
|
|
|
cidocker = docker run ${dockerargs} ${ciargs} $$EXTRA_ARGS ${container_env} ${build_image}
|
|
|
|
CROSS_PLATFORMS = linux/amd64 linux/386 linux/arm windows/amd64
|
2016-06-09 07:31:24 -04:00
|
|
|
export PATH := $(CURDIR)/bin:$(PATH)
|
2016-05-20 16:23:53 -04:00
|
|
|
hostOS = ${shell go env GOHOSTOS}
|
|
|
|
ifeq (${hostOS}, solaris)
|
|
|
|
gnufind=gfind
|
|
|
|
gnutail=gtail
|
|
|
|
else
|
|
|
|
gnufind=find
|
|
|
|
gnutail=tail
|
|
|
|
endif
|
2015-03-24 14:52:38 -04:00
|
|
|
|
2015-05-20 15:28:58 -04:00
|
|
|
all: ${build_image}.created build check integration-tests clean
|
|
|
|
|
|
|
|
all-local: build-local check-local integration-tests-local clean
|
|
|
|
|
2016-01-05 18:55:27 -05:00
|
|
|
${build_image}.created:
|
|
|
|
docker build -f Dockerfile.build -t ${build_image} .
|
|
|
|
touch ${build_image}.created
|
|
|
|
|
2015-05-11 11:02:25 -04:00
|
|
|
build: ${build_image}.created
|
2015-09-08 22:26:54 -04:00
|
|
|
@echo "Building code... "
|
|
|
|
@${docker} ./wrapmake.sh build-local
|
|
|
|
@echo "Done building code"
|
2015-03-24 14:52:38 -04:00
|
|
|
|
|
|
|
build-local:
|
2015-05-20 15:28:58 -04:00
|
|
|
@mkdir -p "bin"
|
2017-01-11 03:21:56 -05:00
|
|
|
go build -tags experimental -o "bin/dnet" ./cmd/dnet
|
|
|
|
go build -o "bin/docker-proxy" ./cmd/proxy
|
2015-05-20 15:28:58 -04:00
|
|
|
|
|
|
|
clean:
|
|
|
|
@if [ -d bin ]; then \
|
2016-06-09 07:31:24 -04:00
|
|
|
echo "Removing dnet and proxy binaries"; \
|
2015-05-20 15:28:58 -04:00
|
|
|
rm -rf bin; \
|
|
|
|
fi
|
|
|
|
|
|
|
|
cross: ${build_image}.created
|
|
|
|
@mkdir -p "bin"
|
|
|
|
@for platform in ${CROSS_PLATFORMS}; do \
|
2016-01-05 18:55:27 -05:00
|
|
|
EXTRA_ARGS="-e GOOS=$${platform%/*} -e GOARCH=$${platform##*/}" ; \
|
2015-05-20 15:28:58 -04:00
|
|
|
echo "$${platform}..." ; \
|
2016-01-05 18:55:27 -05:00
|
|
|
${docker} make cross-local ; \
|
2015-05-20 15:28:58 -04:00
|
|
|
done
|
|
|
|
|
|
|
|
cross-local:
|
2017-01-11 03:21:56 -05:00
|
|
|
go build -o "bin/dnet-$$GOOS-$$GOARCH" ./cmd/dnet
|
|
|
|
go build -o "bin/docker-proxy-$$GOOS-$$GOARCH" ./cmd/proxy
|
2015-03-24 14:52:38 -04:00
|
|
|
|
2015-05-11 11:02:25 -04:00
|
|
|
check: ${build_image}.created
|
2015-09-08 22:26:54 -04:00
|
|
|
@${docker} ./wrapmake.sh check-local
|
2015-03-24 14:52:38 -04:00
|
|
|
|
|
|
|
check-code:
|
2015-04-16 15:00:36 -04:00
|
|
|
@echo "Checking code... "
|
2017-01-11 03:21:56 -05:00
|
|
|
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)"
|
2015-04-16 15:00:36 -04:00
|
|
|
@echo "Done checking code"
|
2015-03-24 14:52:38 -04:00
|
|
|
|
|
|
|
check-format:
|
2015-04-16 15:00:36 -04:00
|
|
|
@echo "Checking format... "
|
2017-01-11 03:21:56 -05:00
|
|
|
test -z "$$(gofmt -s -l . | grep -v vendor/ | tee /dev/stderr)"
|
2015-04-16 15:00:36 -04:00
|
|
|
@echo "Done checking format"
|
2015-03-24 14:52:38 -04:00
|
|
|
|
|
|
|
run-tests:
|
2015-04-16 15:00:36 -04:00
|
|
|
@echo "Running tests... "
|
|
|
|
@echo "mode: count" > coverage.coverprofile
|
2017-01-11 03:21:56 -05:00
|
|
|
@for dir in $$( ${gnufind} . -maxdepth 10 -not -path './.git*' -not -path '*/_*' -not -path './vendor/*' -type d); do \
|
2016-05-20 16:23:53 -04:00
|
|
|
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; \
|
2015-04-14 08:13:34 -04:00
|
|
|
if ls $$dir/*.go &> /dev/null; then \
|
2015-05-12 19:39:30 -04:00
|
|
|
pushd . &> /dev/null ; \
|
|
|
|
cd $$dir ; \
|
2017-01-11 03:21:56 -05:00
|
|
|
go test ${INSIDECONTAINER} -test.parallel 5 -test.v -covermode=count -coverprofile=./profile.tmp ; \
|
2015-05-19 13:19:50 -04:00
|
|
|
ret=$$? ;\
|
|
|
|
if [ $$ret -ne 0 ]; then exit $$ret; fi ;\
|
2015-05-12 19:39:30 -04:00
|
|
|
popd &> /dev/null; \
|
2015-09-02 00:48:09 -04:00
|
|
|
if [ -f $$dir/profile.tmp ]; then \
|
2016-05-20 16:23:53 -04:00
|
|
|
cat $$dir/profile.tmp | ${gnutail} -n +2 >> coverage.coverprofile ; \
|
2015-04-14 08:13:34 -04:00
|
|
|
rm $$dir/profile.tmp ; \
|
2015-09-02 00:48:09 -04:00
|
|
|
fi ; \
|
|
|
|
fi ; \
|
2015-04-14 08:13:34 -04:00
|
|
|
done
|
2015-04-16 15:00:36 -04:00
|
|
|
@echo "Done running tests"
|
2015-03-24 14:52:38 -04:00
|
|
|
|
2015-05-20 15:28:58 -04:00
|
|
|
check-local: check-format check-code run-tests
|
|
|
|
|
|
|
|
integration-tests: ./bin/dnet
|
|
|
|
@./test/integration/dnet/run-integration-tests.sh
|
2015-03-24 14:52:38 -04:00
|
|
|
|
2015-05-20 15:28:58 -04:00
|
|
|
./bin/dnet:
|
|
|
|
make build
|
2015-04-14 08:13:34 -04:00
|
|
|
|
|
|
|
coveralls:
|
2015-05-05 19:49:41 -04:00
|
|
|
-@goveralls -service circleci -coverprofile=coverage.coverprofile -repotoken $$COVERALLS_TOKEN
|
2015-04-14 08:13:34 -04:00
|
|
|
|
|
|
|
# CircleCI's Docker fails when cleaning up using the --rm flag
|
2015-05-20 15:28:58 -04:00
|
|
|
# The following targets are a workaround for this
|
|
|
|
circle-ci-cross: ${build_image}.created
|
|
|
|
@mkdir -p "bin"
|
|
|
|
@for platform in ${CROSS_PLATFORMS}; do \
|
2016-01-05 18:55:27 -05:00
|
|
|
EXTRA_ARGS="-e GOOS=$${platform%/*} -e GOARCH=$${platform##*/}" ; \
|
2015-05-20 15:28:58 -04:00
|
|
|
echo "$${platform}..." ; \
|
2016-01-05 18:55:27 -05:00
|
|
|
${cidocker} make cross-local ; \
|
2015-05-20 15:28:58 -04:00
|
|
|
done
|
|
|
|
|
|
|
|
circle-ci-check: ${build_image}.created
|
|
|
|
@${cidocker} make check-local coveralls
|
2015-04-14 08:13:34 -04:00
|
|
|
|
2015-05-20 15:28:58 -04:00
|
|
|
circle-ci-build: ${build_image}.created
|
|
|
|
@${cidocker} make build-local
|
2015-08-17 04:07:43 -04:00
|
|
|
|
2016-06-09 07:31:24 -04:00
|
|
|
circle-ci: circle-ci-build circle-ci-check circle-ci-cross integration-tests
|