|
@@ -1,27 +1,24 @@
|
|
-.PHONY: all all-local build build-local clean cross cross-local gosimple 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
|
|
|
|
|
|
+.PHONY: all all-local build build-local clean cross cross-local gosimple vet lint misspell check check-local check-code check-format unit-tests
|
|
SHELL=/bin/bash
|
|
SHELL=/bin/bash
|
|
|
|
+dockerbuildargs ?= - < Dockerfile.build
|
|
|
|
+dockerargs ?= --privileged -v $(shell pwd):/go/src/github.com/docker/libnetwork -w /go/src/github.com/docker/libnetwork
|
|
build_image=libnetworkbuild
|
|
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"
|
|
container_env = -e "INSIDECONTAINER=-incontainer=true"
|
|
docker = docker run --rm -it ${dockerargs} $$EXTRA_ARGS ${container_env} ${build_image}
|
|
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
|
|
CROSS_PLATFORMS = linux/amd64 linux/386 linux/arm windows/amd64
|
|
PACKAGES=$(shell go list ./... | grep -v /vendor/)
|
|
PACKAGES=$(shell go list ./... | grep -v /vendor/)
|
|
export PATH := $(CURDIR)/bin:$(PATH)
|
|
export PATH := $(CURDIR)/bin:$(PATH)
|
|
|
|
|
|
-all: ${build_image}.created build check integration-tests clean
|
|
|
|
|
|
+all: build check clean
|
|
|
|
|
|
-all-local: build-local check-local integration-tests-local clean
|
|
|
|
|
|
+all-local: build-local check-local clean
|
|
|
|
|
|
-${build_image}.created:
|
|
|
|
- @echo "🐳 $@"
|
|
|
|
- docker build -f Dockerfile.build -t ${build_image} .
|
|
|
|
- touch ${build_image}.created
|
|
|
|
|
|
+builder:
|
|
|
|
+ docker build -t ${build_image} ${dockerbuildargs}
|
|
|
|
|
|
-build: ${build_image}.created
|
|
|
|
|
|
+build: builder
|
|
@echo "🐳 $@"
|
|
@echo "🐳 $@"
|
|
- @${docker} ./wrapmake.sh build-local
|
|
|
|
|
|
+ @${docker} make build-local
|
|
|
|
|
|
build-local:
|
|
build-local:
|
|
@echo "🐳 $@"
|
|
@echo "🐳 $@"
|
|
@@ -47,15 +44,11 @@ push-images: build-images
|
|
clean:
|
|
clean:
|
|
@echo "🐳 $@"
|
|
@echo "🐳 $@"
|
|
@if [ -d bin ]; then \
|
|
@if [ -d bin ]; then \
|
|
- echo "Removing dnet and proxy binaries"; \
|
|
|
|
|
|
+ echo "Removing binaries"; \
|
|
rm -rf bin; \
|
|
rm -rf bin; \
|
|
fi
|
|
fi
|
|
|
|
|
|
-force-clean: clean
|
|
|
|
- @echo "🐳 $@"
|
|
|
|
- @rm -rf ${build_image}.created
|
|
|
|
-
|
|
|
|
-cross: ${build_image}.created
|
|
|
|
|
|
+cross: builder
|
|
@mkdir -p "bin"
|
|
@mkdir -p "bin"
|
|
@for platform in ${CROSS_PLATFORMS}; do \
|
|
@for platform in ${CROSS_PLATFORMS}; do \
|
|
EXTRA_ARGS="-e GOOS=$${platform%/*} -e GOARCH=$${platform##*/}" ; \
|
|
EXTRA_ARGS="-e GOOS=$${platform%/*} -e GOARCH=$${platform##*/}" ; \
|
|
@@ -68,16 +61,22 @@ cross-local:
|
|
go build -o "bin/dnet-$$GOOS-$$GOARCH" ./cmd/dnet
|
|
go build -o "bin/dnet-$$GOOS-$$GOARCH" ./cmd/dnet
|
|
go build -o "bin/docker-proxy-$$GOOS-$$GOARCH" ./cmd/proxy
|
|
go build -o "bin/docker-proxy-$$GOOS-$$GOARCH" ./cmd/proxy
|
|
|
|
|
|
-check: ${build_image}.created
|
|
|
|
- @${docker} ./wrapmake.sh check-local
|
|
|
|
|
|
+check: builder
|
|
|
|
+ @${docker} make check-local
|
|
|
|
+
|
|
|
|
+check-local: check-code check-format
|
|
|
|
|
|
check-code: lint gosimple vet ineffassign
|
|
check-code: lint gosimple vet ineffassign
|
|
|
|
|
|
check-format: fmt misspell
|
|
check-format: fmt misspell
|
|
|
|
|
|
-run-tests:
|
|
|
|
|
|
+unit-tests: builder
|
|
|
|
+ ${docker} make unit-tests-local
|
|
|
|
+
|
|
|
|
+unit-tests-local:
|
|
@echo "🐳 Running tests... "
|
|
@echo "🐳 Running tests... "
|
|
@echo "mode: count" > coverage.coverprofile
|
|
@echo "mode: count" > coverage.coverprofile
|
|
|
|
+ @go build -o "bin/docker-proxy" ./cmd/proxy
|
|
@for dir in $$( find . -maxdepth 10 -not -path './.git*' -not -path '*/_*' -not -path './vendor/*' -type d); do \
|
|
@for dir in $$( find . -maxdepth 10 -not -path './.git*' -not -path '*/_*' -not -path './vendor/*' -type d); do \
|
|
if ls $$dir/*.go &> /dev/null; then \
|
|
if ls $$dir/*.go &> /dev/null; then \
|
|
pushd . &> /dev/null ; \
|
|
pushd . &> /dev/null ; \
|
|
@@ -94,17 +93,6 @@ run-tests:
|
|
done
|
|
done
|
|
@echo "Done running tests"
|
|
@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
|
|
|
|
-
|
|
|
|
# Depends on binaries because vet will silently fail if it can not load compiled imports
|
|
# Depends on binaries because vet will silently fail if it can not load compiled imports
|
|
vet: ## run go vet
|
|
vet: ## run go vet
|
|
@echo "🐳 $@"
|
|
@echo "🐳 $@"
|
|
@@ -112,7 +100,7 @@ vet: ## run go vet
|
|
|
|
|
|
misspell:
|
|
misspell:
|
|
@echo "🐳 $@"
|
|
@echo "🐳 $@"
|
|
- @test -z "$$(find . -type f | grep -v vendor/ | grep -v bin/ | grep -v .git/ | grep -v MAINTAINERS | xargs misspell | tee /dev/stderr)"
|
|
|
|
|
|
+ @test -z "$$(find . -type f | grep -v vendor/ | grep "\.go\|\.md" | xargs misspell -error | tee /dev/stderr)"
|
|
|
|
|
|
fmt: ## run go fmt
|
|
fmt: ## run go fmt
|
|
@echo "🐳 $@"
|
|
@echo "🐳 $@"
|
|
@@ -131,23 +119,5 @@ gosimple: ## run gosimple
|
|
@echo "🐳 $@"
|
|
@echo "🐳 $@"
|
|
@test -z "$$(gosimple . | grep -v vendor/ | grep -v ".pb.go:" | grep -v ".mock.go" | tee /dev/stderr)"
|
|
@test -z "$$(gosimple . | grep -v vendor/ | grep -v ".pb.go:" | grep -v ".mock.go" | tee /dev/stderr)"
|
|
|
|
|
|
-# 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
|
|
|
|
-
|
|
|
|
-shell: ${build_image}.created
|
|
|
|
|
|
+shell: builder
|
|
@${docker} ${SHELL}
|
|
@${docker} ${SHELL}
|