2015-09-08 22:26:54 -04:00
|
|
|
.PHONY: all all-local build build-local check check-code check-format run-tests check-local integration-tests install-deps coveralls circle-ci
|
2015-04-16 15:00:36 -04:00
|
|
|
SHELL=/bin/bash
|
2015-05-11 11:02:25 -04:00
|
|
|
build_image=libnetwork-build
|
|
|
|
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-09-02 00:48:09 -04:00
|
|
|
docker = docker run --rm -it ${dockerargs} ${container_env} ${build_image}
|
2015-05-12 19:39:30 -04:00
|
|
|
ciargs = -e "COVERALLS_TOKEN=$$COVERALLS_TOKEN" -e "INSIDECONTAINER=-incontainer=true"
|
2015-05-11 11:02:25 -04:00
|
|
|
cidocker = docker run ${ciargs} ${dockerargs} golang:1.4
|
2015-03-24 14:52:38 -04:00
|
|
|
|
2015-09-08 22:26:54 -04:00
|
|
|
all: ${build_image}.created build check integration-tests
|
|
|
|
|
|
|
|
integration-tests:
|
|
|
|
@if [ ! -d ./integration-tmp ]; then \
|
|
|
|
mkdir -p ./integration-tmp; \
|
|
|
|
git clone https://github.com/sstephenson/bats.git ./integration-tmp/bats; \
|
|
|
|
./integration-tmp/bats/install.sh ./integration-tmp; \
|
|
|
|
fi
|
|
|
|
@./integration-tmp/bin/bats ./test/integration/dnet
|
2015-03-24 14:52:38 -04:00
|
|
|
|
2015-05-11 11:02:25 -04:00
|
|
|
all-local: check-local build-local
|
2015-03-24 14:52:38 -04:00
|
|
|
|
2015-05-11 11:02:25 -04:00
|
|
|
${build_image}.created:
|
|
|
|
docker run --name=libnetworkbuild -v $(shell pwd):/go/src/github.com/docker/libnetwork -w /go/src/github.com/docker/libnetwork golang:1.4 make install-deps
|
|
|
|
docker commit libnetworkbuild ${build_image}
|
|
|
|
docker rm libnetworkbuild
|
|
|
|
touch ${build_image}.created
|
|
|
|
|
|
|
|
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-09-16 01:22:28 -04:00
|
|
|
@$(shell which godep) go build ./...
|
2015-09-08 22:26:54 -04:00
|
|
|
@$(shell which godep) go build -o ./cmd/dnet/dnet ./cmd/dnet
|
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... "
|
2015-03-24 14:52:38 -04:00
|
|
|
test -z "$$(golint ./... | tee /dev/stderr)"
|
|
|
|
go vet ./...
|
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... "
|
2015-04-14 08:13:34 -04:00
|
|
|
test -z "$$(goimports -l . | grep -v Godeps/_workspace/src/ | 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
|
|
|
|
@for dir in $$(find . -maxdepth 10 -not -path './.git*' -not -path '*/_*' -type d); do \
|
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 ; \
|
|
|
|
$(shell which godep) go test ${INSIDECONTAINER} -test.parallel 3 -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 \
|
|
|
|
cat $$dir/profile.tmp | tail -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-09-02 00:48:09 -04:00
|
|
|
check-local: check-format check-code run-tests
|
2015-03-24 14:52:38 -04:00
|
|
|
|
|
|
|
install-deps:
|
|
|
|
apt-get update && apt-get -y install iptables
|
2015-07-01 00:57:39 -04:00
|
|
|
git clone https://github.com/golang/tools /go/src/golang.org/x/tools
|
|
|
|
go install golang.org/x/tools/cmd/vet
|
|
|
|
go install golang.org/x/tools/cmd/goimports
|
|
|
|
go install golang.org/x/tools/cmd/cover
|
2015-03-24 14:52:38 -04:00
|
|
|
go get github.com/tools/godep
|
|
|
|
go get github.com/golang/lint/golint
|
2015-04-14 08:13:34 -04:00
|
|
|
go get github.com/mattn/goveralls
|
|
|
|
|
|
|
|
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
|
|
|
|
# The following target is a workaround for this
|
|
|
|
|
|
|
|
circle-ci:
|
2015-09-08 22:26:54 -04:00
|
|
|
@${cidocker} make install-deps build-local check-local coveralls
|
|
|
|
make integration-tests
|