From 49ec74b153291936d2969afd5fbb5a1a3f70ca05 Mon Sep 17 00:00:00 2001 From: Kamil Samigullin Date: Sat, 7 Oct 2017 20:28:49 +0300 Subject: [PATCH] fix issue #105: improve makefile --- Makefile | 78 ------------------------------------------ makes/docker.mk | 11 ++++++ makes/docker/alpine.mk | 5 +++ makes/docker/base.mk | 67 ++++++++++++++++++++++++++++++++++++ 4 files changed, 83 insertions(+), 78 deletions(-) diff --git a/Makefile b/Makefile index 3d08c8a..279dec7 100644 --- a/Makefile +++ b/Makefile @@ -14,73 +14,6 @@ check-code-quality: docker-tool-gometalinter -.PHONY: complex-bench -complex-bench: ARGS = -benchmem -complex-bench: docker-bench-1.5 -complex-bench: docker-bench-1.6 -complex-bench: docker-bench-1.7 -complex-bench: docker-bench-1.8 -complex-bench: docker-bench-1.9 -complex-bench: docker-bench-latest - -.PHONY: complex-tests -complex-tests: ARGS = -timeout=1s -complex-tests: docker-test-1.5 -complex-tests: docker-test-1.6 -complex-tests: docker-test-1.7 -complex-tests: docker-test-1.8 -complex-tests: docker-test-1.9 -complex-tests: docker-test-latest - -.PHONY: complex-tests-with-coverage -complex-tests-with-coverage: ARGS = -timeout=1s -complex-tests-with-coverage: docker-test-with-coverage-1.5 -complex-tests-with-coverage: docker-test-with-coverage-1.6 -complex-tests-with-coverage: docker-test-with-coverage-1.7 -complex-tests-with-coverage: docker-test-with-coverage-1.8 -complex-tests-with-coverage: docker-test-with-coverage-1.9 -complex-tests-with-coverage: docker-test-with-coverage-latest - - - -.PHONY: parallel-bench -parallel-bench: ARGS = -benchmem -parallel-bench: - semaphore create - semaphore add -- make docker-bench-1.5 ARGS=$(ARGS) - semaphore add -- make docker-bench-1.6 ARGS=$(ARGS) - semaphore add -- make docker-bench-1.7 ARGS=$(ARGS) - semaphore add -- make docker-bench-1.8 ARGS=$(ARGS) - semaphore add -- make docker-bench-1.9 ARGS=$(ARGS) - semaphore add -- make docker-bench-latest ARGS=$(ARGS) - semaphore wait - -.PHONY: parallel-tests -parallel-tests: ARGS = -timeout=1s -parallel-tests: - semaphore create - semaphore add -- make docker-test-1.5 ARGS=$(ARGS) - semaphore add -- make docker-test-1.6 ARGS=$(ARGS) - semaphore add -- make docker-test-1.7 ARGS=$(ARGS) - semaphore add -- make docker-test-1.8 ARGS=$(ARGS) - semaphore add -- make docker-test-1.9 ARGS=$(ARGS) - semaphore add -- make docker-test-latest ARGS=$(ARGS) - semaphore wait - -.PHONY: parallel-tests-with-coverage -parallel-tests-with-coverage: ARGS = -timeout=1s -parallel-tests-with-coverage: - semaphore create - semaphore add -- docker-test-with-coverage-1.5 ARGS=$(ARGS) - semaphore add -- docker-test-with-coverage-1.6 ARGS=$(ARGS) - semaphore add -- docker-test-with-coverage-1.7 ARGS=$(ARGS) - semaphore add -- docker-test-with-coverage-1.8 ARGS=$(ARGS) - semaphore add -- docker-test-with-coverage-1.9 ARGS=$(ARGS) - semaphore add -- docker-test-with-coverage-latest ARGS=$(ARGS) - semaphore wait - - - .PHONY: cmd-deps cmd-deps: docker run --rm \ @@ -149,17 +82,6 @@ cmd-test-2-local: -.PHONY: docker-pull -docker-pull: docker-pull-1.5 -docker-pull: docker-pull-1.6 -docker-pull: docker-pull-1.7 -docker-pull: docker-pull-1.8 -docker-pull: docker-pull-1.9 -docker-pull: docker-pull-latest -docker-pull: docker-pull-tools -docker-pull: PRUNE = --force -docker-pull: docker-clean - .PHONY: pull-github-tpl pull-github-tpl: rm -rf .github diff --git a/makes/docker.mk b/makes/docker.mk index f2cf9c9..deb31ff 100644 --- a/makes/docker.mk +++ b/makes/docker.mk @@ -12,3 +12,14 @@ include $(CID)/docker/base.mk include $(CID)/docker/clean.mk include $(CID)/docker/tools.mk include $(CID)/docker/experimental-tools.mk + +.PHONY: docker-pull +define docker_pull_tpl +docker-pull: docker-pull-$(1) +endef +docker-pull: docker-pull-tools +docker-pull: PRUNE = --force +docker-pull: docker-clean + +render_docker_pull_tpl = $(eval $(call docker_pull_tpl,$(version))) +$(foreach version,$(SUPPORTED_VERSIONS),$(render_docker_pull_tpl)) diff --git a/makes/docker/alpine.mk b/makes/docker/alpine.mk index cd912fa..11ff1a5 100644 --- a/makes/docker/alpine.mk +++ b/makes/docker/alpine.mk @@ -9,6 +9,7 @@ docker-in-$(1): docker run --rm -it \ -v '$${GOPATH}/src/$${GO_PACKAGE}':'/go/src/$${GO_PACKAGE}' \ -w '/go/src/$${GO_PACKAGE}' \ + -e GO15VENDOREXPERIMENT=1 \ golang:$(1) \ /bin/sh @@ -18,6 +19,7 @@ docker-bench-$(1): docker run --rm \ -v '$${GOPATH}/src/$${GO_PACKAGE}':'/go/src/$${GO_PACKAGE}' \ -w '/go/src/$${GO_PACKAGE}' \ + -e GO15VENDOREXPERIMENT=1 \ golang:$(1) \ /bin/sh -c '$$(PACKAGES) | xargs go test -bench=. $$(strip $$(ARGS))' @@ -27,6 +29,7 @@ docker-test-$(1): docker run --rm \ -v '$${GOPATH}/src/$${GO_PACKAGE}':'/go/src/$${GO_PACKAGE}' \ -w '/go/src/$${GO_PACKAGE}' \ + -e GO15VENDOREXPERIMENT=1 \ golang:$(1) \ /bin/sh -c '$$(PACKAGES) | xargs go test $$(strip $$(ARGS))' @@ -35,6 +38,7 @@ docker-test-check-$(1): docker run --rm \ -v '$${GOPATH}/src/$${GO_PACKAGE}':'/go/src/$${GO_PACKAGE}' \ -w '/go/src/$${GO_PACKAGE}' \ + -e GO15VENDOREXPERIMENT=1 \ golang:$(1) \ /bin/sh -c '$$(PACKAGES) | xargs go test -run=^hack $$(strip $$(ARGS))' @@ -45,6 +49,7 @@ docker-docs-$(1): -v '$${GOPATH}/src/$${GO_PACKAGE}':'/go/src/$${GO_PACKAGE}' \ -w '/go/src/$${GO_PACKAGE}' \ -p 127.0.0.1:8080:8080 \ + -e GO15VENDOREXPERIMENT=1 \ golang:$(1) \ godoc -play -http :8080 sleep 2 diff --git a/makes/docker/base.mk b/makes/docker/base.mk index 9ac90c6..0946086 100644 --- a/makes/docker/base.mk +++ b/makes/docker/base.mk @@ -1,3 +1,10 @@ +COMPLEX_BENCH_ARGS ?= -benchmem +COMPLEX_TESTS_ARGS ?= -timeout=1s +COMPLEX_TESTS_WITH_COVERAGE_ARGS ?= $(COMPLEX_TESTS_ARGS) +PARALLEL_BENCH_ARGS ?= $(COMPLEX_BENCH_ARGS) +PARALLEL_TESTS_ARGS ?= $(COMPLEX_TESTS_ARGS) +PARALLEL_TESTS_WITH_COVERAGE_ARGS ?= $(COMPLEX_TESTS_WITH_COVERAGE_ARGS) + define docker_base_tpl .PHONY: docker-pull-$(1) @@ -9,6 +16,7 @@ docker-in-$(1): docker run --rm -it \ -v '$${GOPATH}/src/$${GO_PACKAGE}':'/go/src/$${GO_PACKAGE}' \ -w '/go/src/$${GO_PACKAGE}' \ + -e GO15VENDOREXPERIMENT=1 \ golang:$(1) \ /bin/sh @@ -18,6 +26,7 @@ docker-bench-$(1): docker run --rm \ -v '$${GOPATH}/src/$${GO_PACKAGE}':'/go/src/$${GO_PACKAGE}' \ -w '/go/src/$${GO_PACKAGE}' \ + -e GO15VENDOREXPERIMENT=1 \ golang:$(1) \ /bin/sh -c '$$(PACKAGES) | xargs go get -d -t && \ $$(PACKAGES) | xargs go test -bench=. $$(strip $$(ARGS))' @@ -28,6 +37,7 @@ docker-test-$(1): docker run --rm \ -v '$${GOPATH}/src/$${GO_PACKAGE}':'/go/src/$${GO_PACKAGE}' \ -w '/go/src/$${GO_PACKAGE}' \ + -e GO15VENDOREXPERIMENT=1 \ golang:$(1) \ /bin/sh -c '$$(PACKAGES) | xargs go get -d -t && \ $$(PACKAGES) | xargs go test -race $$(strip $$(ARGS))' @@ -37,6 +47,7 @@ docker-test-check-$(1): docker run --rm \ -v '$${GOPATH}/src/$${GO_PACKAGE}':'/go/src/$${GO_PACKAGE}' \ -w '/go/src/$${GO_PACKAGE}' \ + -e GO15VENDOREXPERIMENT=1 \ golang:$(1) \ /bin/sh -c '$$(PACKAGES) | xargs go get -d -t && \ $$(PACKAGES) | xargs go test -run=^hack $$(strip $$(ARGS))' @@ -46,6 +57,7 @@ docker-test-with-coverage-$(1): docker run --rm \ -v '$${GOPATH}/src/$${GO_PACKAGE}':'/go/src/$${GO_PACKAGE}' \ -w '/go/src/$${GO_PACKAGE}' \ + -e GO15VENDOREXPERIMENT=1 \ golang:$(1) \ /bin/sh -c '$$(PACKAGES) | xargs go get -d -t; \ echo "mode: $${GO_TEST_COVERAGE_MODE}" > '$$@.out'; \ @@ -67,6 +79,7 @@ docker-docs-$(1): -v '$${GOPATH}/src/$${GO_PACKAGE}':'/go/src/$${GO_PACKAGE}' \ -w '/go/src/$${GO_PACKAGE}' \ -p 127.0.0.1:8080:8080 \ + -e GO15VENDOREXPERIMENT=1 \ golang:$(1) \ godoc -play -http :8080 sleep 2 @@ -80,3 +93,57 @@ endef render_docker_base_tpl = $(eval $(call docker_base_tpl,$(version))) $(foreach version,$(SUPPORTED_VERSIONS),$(render_docker_base_tpl)) + +.PHONY: complex-bench +complex-bench: ARGS = $(COMPLEX_BENCH_ARGS) +define complex_bench_tpl +complex-bench: docker-bench-$(1) +endef + +render_complex_bench_tpl = $(eval $(call complex_bench_tpl,$(version))) +$(foreach version,$(SUPPORTED_VERSIONS),$(render_complex_bench_tpl)) + +.PHONY: complex-tests +complex-tests: ARGS = $(COMPLEX_TESTS_ARGS) +define complex_tests_tpl +complex-tests: docker-test-$(1) +endef + +render_complex_tests_tpl = $(eval $(call complex_tests_tpl,$(version))) +$(foreach version,$(SUPPORTED_VERSIONS),$(render_complex_tests_tpl)) + +.PHONY: complex-tests-with-coverage +complex-tests-with-coverage: ARGS = $(COMPLEX_TESTS_WITH_COVERAGE_ARGS) +define complex_tests_with_coverage_tpl +complex-tests-with-coverage: docker-test-with-coverage-$(1) +endef + +render_complex_tests_with_coverage_tpl = $(eval $(call complex_tests_with_coverage_tpl,$(version))) +$(foreach version,$(SUPPORTED_VERSIONS),$(render_complex_tests_with_coverage_tpl)) + +.PHONY: parallel-bench +parallel-bench: ARGS = $(PARALLEL_BENCH_ARGS) +parallel-bench: + semaphore create + for v in $(SUPPORTED_VERSIONS); do \ + semaphore add -- make docker-bench-$$v ARGS=$(ARGS); \ + done + semaphore wait + +.PHONY: parallel-tests +parallel-tests: ARGS = $(PARALLEL_TESTS_ARGS) +parallel-tests: + semaphore create + for v in $(SUPPORTED_VERSIONS); do \ + semaphore add -- make docker-test-$$v ARGS=$(ARGS); \ + done + semaphore wait + +.PHONY: parallel-tests-with-coverage +parallel-tests-with-coverage: ARGS = $(PARALLEL_TESTS_WITH_COVERAGE_ARGS) +parallel-tests-with-coverage: + semaphore create + for v in $(SUPPORTED_VERSIONS); do \ + semaphore add -- make docker-test-with-coverage-$$v ARGS=$(ARGS); \ + done + semaphore wait