2015-04-14 08:13:34 -04:00
|
|
|
.PHONY: all all-local build build-local check check-code check-format run-tests check-local install-deps coveralls circle-ci
|
2015-04-16 15:00:36 -04:00
|
|
|
SHELL=/bin/bash
|
2015-04-14 08:13:34 -04:00
|
|
|
dockerargs = --privileged -v $(shell pwd):/go/src/github.com/docker/libnetwork -w /go/src/github.com/docker/libnetwork golang:1.4
|
|
|
|
docker = docker run --rm ${dockerargs}
|
|
|
|
ciargs = -e "COVERALLS_TOKEN=$$COVERALLS_TOKEN"
|
|
|
|
cidocker = docker run ${ciargs} ${dockerargs}
|
2015-03-24 14:52:38 -04:00
|
|
|
|
|
|
|
all:
|
|
|
|
${docker} make all-local
|
|
|
|
|
|
|
|
all-local: install-deps check-local build-local
|
|
|
|
|
|
|
|
build:
|
|
|
|
${docker} make install-deps build-local
|
|
|
|
|
|
|
|
build-local:
|
|
|
|
$(shell which godep) go build ./...
|
|
|
|
|
|
|
|
check:
|
|
|
|
${docker} make install-deps check-local
|
|
|
|
|
|
|
|
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 \
|
|
|
|
$(shell which godep) go test -test.v -covermode=count -coverprofile=$$dir/profile.tmp $$dir ; \
|
2015-04-16 15:00:36 -04:00
|
|
|
if [ $$? -ne 0 ]; then exit $$?; fi ;\
|
2015-04-14 08:13:34 -04:00
|
|
|
if [ -f $$dir/profile.tmp ]; then \
|
|
|
|
cat $$dir/profile.tmp | tail -n +2 >> coverage.coverprofile ; \
|
|
|
|
rm $$dir/profile.tmp ; \
|
|
|
|
fi ; \
|
|
|
|
fi ; \
|
|
|
|
done
|
2015-04-16 15:00:36 -04:00
|
|
|
@echo "Done running tests"
|
2015-03-24 14:52:38 -04:00
|
|
|
|
|
|
|
check-local: check-format check-code run-tests
|
|
|
|
|
|
|
|
install-deps:
|
|
|
|
apt-get update && apt-get -y install iptables
|
|
|
|
go get github.com/tools/godep
|
|
|
|
go get github.com/golang/lint/golint
|
|
|
|
go get golang.org/x/tools/cmd/vet
|
|
|
|
go get golang.org/x/tools/cmd/goimports
|
2015-04-14 08:13:34 -04:00
|
|
|
go get golang.org/x/tools/cmd/cover
|
|
|
|
go get github.com/mattn/goveralls
|
|
|
|
|
|
|
|
coveralls:
|
|
|
|
@goveralls -service circleci -coverprofile=coverage.coverprofile -repotoken $$COVERALLS_TOKEN
|
|
|
|
|
|
|
|
# CircleCI's Docker fails when cleaning up using the --rm flag
|
|
|
|
# The following target is a workaround for this
|
|
|
|
|
|
|
|
circle-ci:
|
|
|
|
@${cidocker} make install-deps check-local coveralls
|
|
|
|
|