1- .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
1+ .PHONY : all all-local build build-local clean cross cross-local vet lint misspell check check-code check-format run-tests integration-tests check-local coveralls circle-ci-cross circle-ci-build circle-ci-check circle-ci
22SHELL =/bin/bash
33build_image =libnetworkbuild
44dockerargs = --privileged -v $(shell pwd) :/go/src/github.com/docker/libnetwork -w /go/src/github.com/docker/libnetwork
@@ -7,6 +7,7 @@ docker = docker run --rm -it ${dockerargs} $$EXTRA_ARGS ${container_env} ${build
77ciargs = -e CIRCLECI -e "COVERALLS_TOKEN=$$COVERALLS_TOKEN" -e "INSIDECONTAINER=-incontainer=true"
88cidocker = docker run ${dockerargs} ${ciargs} $$EXTRA_ARGS ${container_env} ${build_image}
99CROSS_PLATFORMS = linux/amd64 linux/386 linux/arm windows/amd64
10+ PACKAGES =$(shell go list ./... | grep -v /vendor/)
1011export PATH := $(CURDIR ) /bin:$(PATH )
1112hostOS = ${shell go env GOHOSTOS}
1213ifeq (${hostOS}, solaris)
@@ -22,25 +23,31 @@ all: ${build_image}.created build check integration-tests clean
2223all-local : build-local check-local integration-tests-local clean
2324
2425${build_image}.created :
26+ @echo " 🐳 $@ "
2527 docker build -f Dockerfile.build -t ${build_image} .
2628 touch ${build_image} .created
2729
2830build : ${build_image}.created
29- @echo " Building code... "
31+ @echo " 🐳 $@ "
3032 @${docker} ./wrapmake.sh build-local
31- @echo " Done building code"
3233
3334build-local :
35+ @echo " 🐳 $@ "
3436 @mkdir -p " bin"
3537 go build -tags experimental -o " bin/dnet" ./cmd/dnet
3638 go build -o " bin/docker-proxy" ./cmd/proxy
3739
3840clean :
41+ @echo " 🐳 $@ "
3942 @if [ -d bin ]; then \
4043 echo " Removing dnet and proxy binaries" ; \
4144 rm -rf bin; \
4245 fi
4346
47+ force-clean : clean
48+ @echo " 🐳 $@ "
49+ @rm -rf ${build_image} .created
50+
4451cross : ${build_image}.created
4552 @mkdir -p " bin"
4653 @for platform in ${CROSS_PLATFORMS} ; do \
@@ -50,25 +57,19 @@ cross: ${build_image}.created
5057 done
5158
5259cross-local :
60+ @echo " 🐳 $@ "
5361 go build -o " bin/dnet-$$ GOOS-$$ GOARCH" ./cmd/dnet
5462 go build -o " bin/docker-proxy-$$ GOOS-$$ GOARCH" ./cmd/proxy
5563
5664check : ${build_image}.created
5765 @${docker} ./wrapmake.sh check-local
5866
59- check-code :
60- @echo " Checking code... "
61- test -z " $$ (golint ./... | grep -Ev 'vendor|.pb.go:' | tee /dev/stderr)"
62- test -z " $$ (go vet ./... 2>&1 > /dev/null | grep -Ev 'vendor|exit' | tee /dev/stderr)"
63- @echo " Done checking code"
67+ check-code : lint vet ineffassign
6468
65- check-format :
66- @echo " Checking format... "
67- test -z " $$ (gofmt -s -l . | grep -v vendor/ | tee /dev/stderr)"
68- @echo " Done checking format"
69+ check-format : fmt misspell
6970
7071run-tests :
71- @echo " Running tests... "
72+ @echo " 🐳 Running tests... "
7273 @echo " mode: count" > coverage.coverprofile
7374 @for dir in $$( ${gnufind} . -maxdepth 10 -not -path './.git*' -not -path '*/_*' -not -path './vendor/*' -type d ) ; do \
7475 if [ ${hostOS} == solaris ]; then \
@@ -130,6 +131,28 @@ integration-tests: ./bin/dnet
130131coveralls :
131132 -@goveralls -service circleci -coverprofile=coverage.coverprofile -repotoken $$ COVERALLS_TOKEN
132133
134+ # Depends on binaries because vet will silently fail if it can not load compiled imports
135+ vet : # # run go vet
136+ @echo " 🐳 $@ "
137+ @test -z " $$ (go vet ${PACKAGES} 2>&1 | grep -v 'constant [0-9]* not a string in call to Errorf' | egrep -v '(timestamp_test.go|duration_test.go|exit status 1)' | tee /dev/stderr)"
138+
139+ misspell :
140+ @echo " 🐳 $@ "
141+ @test -z " $$ (find . -type f | grep -v vendor/ | grep -v bin/ | grep -v .git/ | grep -v MAINTAINERS | xargs misspell | tee /dev/stderr)"
142+
143+ fmt : # # run go fmt
144+ @echo " 🐳 $@ "
145+ @test -z " $$ (gofmt -s -l . | grep -v vendor/ | grep -v " .pb.go$$ " | tee /dev/stderr)" || \
146+ (echo " 👹 please format Go code with 'gofmt -s -w'" && false)
147+
148+ lint : # # run go lint
149+ @echo " 🐳 $@ "
150+ @test -z " $$ (golint ./... | grep -v vendor/ | grep -v " .pb.go:" | grep -v " .mock.go" | tee /dev/stderr)"
151+
152+ ineffassign : # # run ineffassign
153+ @echo " 🐳 $@ "
154+ @test -z " $$ (ineffassign . | grep -v vendor/ | grep -v " .pb.go:" | grep -v " .mock.go" | tee /dev/stderr)"
155+
133156# CircleCI's Docker fails when cleaning up using the --rm flag
134157# The following targets are a workaround for this
135158circle-ci-cross : ${build_image}.created
0 commit comments