-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
88 lines (76 loc) · 2.17 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
GOCMD=go
GOBUILD = $(GOCMD) build
GOCLEAN = $(GOCMD) clean
GOTEST = $(GOCMD) test
GOGET = $(GOCMD) get
GOTOOL = $(GOCMD) tool
GOBASE := $(shell pwd)
GOBIN := $(GOBASE)/bin
DOCKER := $(GOBASE)/tools/test
# name of executable.
BINARY = pipeline
BINDIR = bin
.DEFAULT_GOAL := all
include skeleton/pipeline.mk
## Removes containers, images, binaries and cache
clean: clean-containers
@echo " > Cleaning binaries and cache"
@-rm -f $(GOBIN)/$(PROJECTNAME)/$(BINARY)
@$(GOCLEAN)
clean-containers:
@echo " > Cleaning containers"
@cd $(DOCKER) && docker-compose down --rmi all --volumes --remove-orphans 2>/dev/null
stop-containers:
@echo " > Stopping containers"
@cd $(DOCKER) && docker-compose down --volumes 2>/dev/null
start-containers: stop-containers
@echo " > Starting containers"
@cd $(DOCKER) && docker-compose up -d
## Alias for integration-test
testall: build integration-test
## Integration test with Kafka and Zookeper
.PHONY: integration-test
integration-test:
@echo " > Setting up Zookeeper and Kafka. Docker required."
@$(MAKE) start-containers
@echo " > Starting integration tests"
$(GOTEST) -v -coverpkg=./... -tags=integration $(COVER_PROFILE) ./...
@$(MAKE) stop-containers
## Default target. Builds and executes unit tests
.PHONY: all
all: build test
.DEFAULT:
@$(MAKE) help
## This help message
.PHONY: help
help:
@printf "\nUsage:\n";
@awk '{ \
if ($$0 ~ /^.PHONY: [a-zA-Z\-\_0-9]+$$/) { \
helpCommand = substr($$0, index($$0, ":") + 2); \
if (helpMessage) { \
printf "\033[36m%-20s\033[0m %s\n", \
helpCommand, helpMessage; \
helpMessage = ""; \
} \
} else if ($$0 ~ /^[a-zA-Z\-\_0-9.]+:/) { \
helpCommand = substr($$0, 0, index($$0, ":")); \
if (helpMessage) { \
printf "\033[36m%-20s\033[0m %s\n", \
helpCommand, helpMessage; \
helpMessage = ""; \
} \
} else if ($$0 ~ /^##/) { \
if (helpMessage) { \
helpMessage = helpMessage"\n "substr($$0, 3); \
} else { \
helpMessage = substr($$0, 3); \
} \
} else { \
if (helpMessage) { \
print "\n "helpMessage"\n" \
} \
helpMessage = ""; \
} \
}' \
$(MAKEFILE_LIST)