-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathMakefile
More file actions
92 lines (76 loc) · 2.49 KB
/
Makefile
File metadata and controls
92 lines (76 loc) · 2.49 KB
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
89
90
91
92
# This Makefile is meant to be used by people that do not usually work
# with Go source code. If you know what GOPATH is then you probably
# don't need to bother with make.
PHONY += all docker test clean
CURDIR := $(shell pwd)
GOBIN := $(shell pwd)/build/bin
TARGETS := $(sort $(notdir $(wildcard ./cmd/*)))
PHONY += $(TARGETS)
all: $(TARGETS)
.SECONDEXPANSION:
$(TARGETS): $(addprefix $(GOBIN)/,$$@)
$(GOBIN):
@mkdir -p $@
$(GOBIN)/%: $(GOBIN) FORCE
@go build -v -o $@ ./cmd/$(notdir $@)
@echo "Done building."
@echo "Run \"$(subst $(CURDIR),.,$@)\" to launch $(notdir $@)."
coverage.txt:
@touch $@
test: coverage.txt FORCE
@for d in `go list ./... | grep -v vendor | grep -v mock`; do \
go test -v -coverprofile=profile.out -covermode=atomic $$d; \
if [ $$? -eq 0 ]; then \
echo "\033[32mPASS\033[0m:\t$$d"; \
if [ -f profile.out ]; then \
cat profile.out >> coverage.txt; \
rm profile.out; \
fi \
else \
echo "\033[31mFAIL\033[0m:\t$$d"; \
exit -1; \
fi \
done;
# .proto files
PROTOS := \
health/*.proto
PROTOC_INCLUDES := \
-I$(CURDIR)/vendor/github.com/golang/protobuf/ptypes \
-I$(CURDIR)/vendor/github.com/golang/protobuf/ptypes/any \
-I$(CURDIR)/vendor/github.com/golang/protobuf/ptypes/struct \
-I$(CURDIR)/vendor/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
-I$(GOPATH)/src
grpc: FORCE
@protoc $(PROTOC_INCLUDES) \
--gofast_out=plugins=grpc:$(GOPATH)/src $(addprefix $(CURDIR)/,$(PROTOS))
@protoc $(PROTOC_INCLUDES) \
--grpc-gateway_out=logtostderr=true:$(GOPATH)/src $(addprefix $(CURDIR)/,$(PROTOS))
deps:
docker pull mysql:5.7
docker pull postgres:9.6
docker pull quay.io/coreos/etcd:v3.5.0
docker pull amazon/dynamodb-local:latest
docker pull rabbitmq:3.13-management
docker pull redis:6-alpine
docker pull vault:1.0.3
clean:
rm -fr $(GOBIN)/*
PHONY: help
help:
@echo 'Generic targets:'
@echo ' all - Build all targets marked with [*]'
@echo '* health - Build health client'
@echo ''
@echo 'Protobuf targets:'
@echo ' grpc - Generate gRPC go bindings from .proto files'
@echo ''
@echo 'Test targets:'
@echo ' test - Run all unit tests'
@echo ''
@echo 'Cleaning targets:'
@echo ' clean - Remove built executables'
@echo ''
@echo 'Execute "make" or "make all" to build all targets marked with [*] '
@echo 'For further info see the ./README.md file'
.PHONY: FORCE
FORCE: