This repository has been archived by the owner on Oct 16, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
129 lines (100 loc) · 3.79 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
SELF_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
include $(SELF_DIR)/.ci/common.mk
SHELL=/bin/bash -o pipefail
auto_gen := .ci/auto-gen.sh
gopath_prefix := $(GOPATH)/src
license_dir := .ci/uber-licence
license_node_modules := $(license_dir)/node_modules
m3ninx_package := github.com/m3db/m3ninx
m3ninx_package_path := $(gopath_prefix)/$(m3ninx_package)
metalint_check := .ci/metalint.sh
metalint_config := .metalinter.json
metalint_exclude := .excludemetalint
mockgen_package := github.com/golang/mock/mockgen
mocks_output_dir := generated/mocks/mocks
mocks_rules_dir := generated/mocks
proto_output_dir := generated/proto
proto_rules_dir := generated/proto
protoc_go_package := github.com/golang/protobuf/protoc-gen-go
vendor_prefix := vendor
genny_output_dir := generated/generics/generics
genny_rules_dir := generated/generics
BUILD := $(abspath ./bin)
GO_BUILD_LDFLAGS := $(shell $(abspath ./.ci/go-build-ldflags.sh) $(m3ninx_package))
LINUX_AMD64_ENV := GOOS=linux GOARCH=amd64 CGO_ENABLED=0
include $(SELF_DIR)/generated-source-files.mk
# SERVICES := \
.PHONY: setup
setup:
mkdir -p $(BUILD)
define SERVICE_RULES
.PHONY: $(SERVICE)
$(SERVICE): setup
@echo Building $(SERVICE)
go build -ldflags '$(GO_BUILD_LDFLAGS)' -o $(BUILD)/$(SERVICE) ./services/$(SERVICE)/main/.
.PHONY: $(SERVICE)-linux-amd64
$(SERVICE)-linux-amd64:
$(LINUX_AMD64_ENV) make $(SERVICE)
endef
.PHONY: services services-linux-amd64
services: $(SERVICES)
services-linux-amd64:
$(LINUX_AMD64_ENV) make services
$(foreach SERVICE,$(SERVICES),$(eval $(SERVICE_RULES)))
$(foreach TOOL,$(TOOLS),$(eval $(TOOL_RULES)))
.PHONY: all
all: metalint test-ci-unit test-ci-integration services tools
@echo Made all successfully
.PHONY: install-license-bin
install-license-bin: install-vendor
@echo Installing node modules
git submodule update --init --recursive
[ -d $(license_node_modules) ] || (cd $(license_dir) && npm install)
.PHONY: install-mockgen
install-mockgen: install-vendor
@echo Installing mockgen
rm -rf $(gopath_prefix)/$(mockgen_package) && \
cp -r $(vendor_prefix)/$(mockgen_package) $(gopath_prefix)/$(mockgen_package) && \
go install $(mockgen_package)
.PHONY: install-proto-bin
install-proto-bin: install-vendor
@echo Installing protobuf binaries
@echo Note: the protobuf compiler v3.0.0 can be downloaded from https://github.com/google/protobuf/releases or built from source at https://github.com/google/protobuf.
go install $(m3ninx_package)/$(vendor_prefix)/$(protoc_go_package)
.PHONY: mock-gen
mock-gen: install-mockgen install-util-mockclean install-license-bin
@echo Generating mocks
PACKAGE=$(m3ninx_package) $(auto_gen) $(mocks_output_dir) $(mocks_rules_dir)
.PHONY: proto-gen
proto-gen: install-proto-bin install-license-bin
@echo Generating protobuf files
PACKAGE=$(m3ninx_package) $(auto_gen) $(proto_output_dir) $(proto_rules_dir)
.PHONY: genny-gen
genny-gen: install-generics-bin # defined in `common.mk`
@echo Generating generics
PACKAGE=$(m3ninx_package) $(auto_gen) $(genny_output_dir) $(genny_rules_dir)
.PHONY: all-gen
all-gen: mock-gen genny-gen
.PHONY: metalint
metalint: install-metalinter
@($(metalint_check) $(metalint_config) $(metalint_exclude) \
&& echo "metalinted successfully!") || (echo "metalinter failed" && exit 1)
.PHONY: test
test: test-base
gocov convert $(coverfile) | gocov report
.PHONY: test-integration
test-integration: test-base-integration
.PHONY: test-xml
test-xml: test-base-xml
.PHONY: test-html
testhtml: test-base-html
.PHONY: test-ci-unit
test-ci-unit: test-base
$(codecov_push) -f $(coverfile)
.PHONY: test-ci-integration
test-ci-integration:
INTEGRATION_TIMEOUT=4m make test-base-ci-integration
.PHONY: clean
clean:
@rm -f *.html *.xml *.out *.test
.DEFAULT_GOAL := all