Skip to content

Commit

Permalink
fix issue #105: improve makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilsk committed Oct 7, 2017
1 parent dfcfb59 commit 49ec74b
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 78 deletions.
78 changes: 0 additions & 78 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions makes/docker.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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))
5 changes: 5 additions & 0 deletions makes/docker/alpine.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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))'

Expand All @@ -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))'

Expand All @@ -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))'

Expand All @@ -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
Expand Down
67 changes: 67 additions & 0 deletions makes/docker/base.mk
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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

Expand All @@ -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))'
Expand All @@ -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))'
Expand All @@ -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))'
Expand All @@ -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'; \
Expand All @@ -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
Expand All @@ -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

0 comments on commit 49ec74b

Please sign in to comment.