This repository has been archived by the owner on Jun 11, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathMakefile
197 lines (141 loc) · 5.72 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
################################################################################
##
## Knative-Kafka Makefile
##
################################################################################
# Project Directories
BUILD_ROOT:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
BUILD_DIR:=$(BUILD_ROOT)/build
CHANNEL_BUILD_DIR=$(BUILD_DIR)/channel
COMMON_BUILD_DIR=$(BUILD_DIR)/common
CONTROLLER_BUILD_DIR=$(BUILD_DIR)/controller
DISPATCHER_BUILD_DIR=$(BUILD_DIR)/dispatcher
# Flag Controlling Whether To Run Tests Inside Docker Builds Or Not
BUILD_TESTS:=true
# Application Docker Path
APP_PATH=eu.gcr.io/kyma-project/incubator
# Application Docker Container Version
APP_VERSION=latest
# Application Docker Container Names
CHANNEL_APP_NAME='knative-kafka-channel'
CONTROLLER_APP_NAME='kafka-channel-controller'
DISPATCHER_APP_NAME='knative-kafka-dispatcher'
# Application Docker Container Tags
CHANNEL_APP_TAG=$(CHANNEL_APP_NAME):$(APP_VERSION)
CONTROLLER_APP_TAG=$(CONTROLLER_APP_NAME):$(APP_VERSION)
DISPATCHER_APP_TAG=$(DISPATCHER_APP_NAME):$(APP_VERSION)
#
# Clean Build Images
#
clean-channel:
@echo 'Cleaning Channel Build'
rm -f $(CHANNEL_BUILD_DIR)/coverage.out $(CHANNEL_BUILD_DIR)/$(CHANNEL_APP_NAME)
clean-common:
@echo 'Cleaning Common Build'
rm -f $(COMMON_BUILD_DIR)/coverage.out
clean-controller:
@echo 'Cleaning Controller Build'
rm -f $(CONTROLLER_BUILD_DIR)/coverage.out $(DISPATCHER_BUILD_DIR)/$(DISPATCHER_APP_NAME)
clean-dispatcher:
@echo 'Cleaning Dispatcher Build'
rm -f $(DISPATCHER_BUILD_DIR)/coverage.out $(DISPATCHER_BUILD_DIR)/$(DISPATCHER_APP_NAME)
clean-all: clean-channel clean-common clean-controller clean-dispatcher
.PHONY: clean-channel clean-common clean-controller clean-dispatcher clean-all
#
# Dep / Fmt / Vet / Lint
#
dep:
@echo 'Ensuring Dependencies'
cd $(BUILD_ROOT); dep ensure -v
format:
@echo 'Formatting Go Source'
go fmt ./...
vet:
@echo 'Vetting Packages'
go vet -v ./cmd/...
go vet -v ./pkg/...
lint:
@echo 'Linting Packages'
golint ./cmd/...
golint ./pkg/...
.PHONY: dep format vet lint
#
# Testing
#
test-channel:
@echo 'Testing Channel'
mkdir -p $(CHANNEL_BUILD_DIR)
cd $(BUILD_ROOT); go test -v ./pkg/channel/... -coverprofile ${CHANNEL_BUILD_DIR}/coverage.out
cd $(BUILD_ROOT); go tool cover -func=${CHANNEL_BUILD_DIR}/coverage.out
test-common:
@echo 'Testing Common'
mkdir -p $(COMMON_BUILD_DIR)
cd $(BUILD_ROOT); go test -v ./pkg/common/... -coverprofile ${COMMON_BUILD_DIR}/coverage.out
cd $(BUILD_ROOT); go tool cover -func=${COMMON_BUILD_DIR}/coverage.out
test-controller:
@echo 'Testing Controller'
mkdir -p $(CONTROLLER_BUILD_DIR)
cd $(BUILD_ROOT); go test -v ./pkg/controller/... -coverprofile ${CONTROLLER_BUILD_DIR}/coverage.out
cd $(BUILD_ROOT); go tool cover -func=${CONTROLLER_BUILD_DIR}/coverage.out
test-dispatcher:
@echo 'Testing Dispatcher'
mkdir -p $(DISPATCHER_BUILD_DIR)
cd $(BUILD_ROOT); go test -v ./pkg/dispatcher/... -coverprofile ${DISPATCHER_BUILD_DIR}/coverage.out
cd $(BUILD_ROOT); go tool cover -func=${DISPATCHER_BUILD_DIR}/coverage.out
test-all: test-channel test-common test-controller test-dispatcher
.PHONY: test-channel test-common test-controller test-dispatcher test-all
#
# Build The Native Golang Binaries (Meant For Use In Docker)
#
build-native-channel: clean-channel
@echo 'Building Channel (Native)'
mkdir -p $(CHANNEL_BUILD_DIR);
cd $(BUILD_ROOT)/cmd/channel; go build -o $(CHANNEL_BUILD_DIR)/$(CHANNEL_APP_NAME)
build-native-controller: clean-controller
@echo 'Building Controller (Native)'
mkdir -p $(CONTROLLER_BUILD_DIR);
cd $(BUILD_ROOT)/cmd/controller; go build -o $(CONTROLLER_BUILD_DIR)/$(CONTROLLER_APP_NAME)
build-native-dispatcher: clean-dispatcher
@echo 'Building Dispatcher (Native)'
mkdir -p $(DISPATCHER_BUILD_DIR);
cd $(BUILD_ROOT)/cmd/dispatcher; go build -o $(DISPATCHER_BUILD_DIR)/$(DISPATCHER_APP_NAME)
build-native-all: build-native-channel build-native-controller build-native-dispatcher
.PHONY: build-native-channel build-native-controller build-native-dispatcher build-native-all
#
# Build Docker Containers
#
docker-build-channel:
@echo 'Building Channel Docker Container'
docker build --rm -t $(CHANNEL_APP_TAG) --build-arg RUN_TESTS=${BUILD_TESTS} -f $(CHANNEL_BUILD_DIR)/Dockerfile .
docker tag $(CHANNEL_APP_TAG) $(APP_PATH)/$(CHANNEL_APP_TAG)
docker-build-controller:
@echo 'Building Controller Docker Container'
docker build --rm -t $(CONTROLLER_APP_TAG) --build-arg RUN_TESTS=${BUILD_TESTS} -f $(CONTROLLER_BUILD_DIR)/Dockerfile .
docker tag $(CONTROLLER_APP_TAG) $(APP_PATH)/$(CONTROLLER_APP_TAG)
docker-build-dispatcher:
@echo 'Building Dispatcher Docker Container'
docker build --rm -t $(DISPATCHER_APP_TAG) --build-arg RUN_TESTS=${BUILD_TESTS} -f $(DISPATCHER_BUILD_DIR)/Dockerfile .
docker tag $(DISPATCHER_APP_TAG) $(APP_PATH)/$(DISPATCHER_APP_TAG)
docker-build-all: docker-build-channel docker-build-controller docker-build-dispatcher
.PHONY: docker-build-channel docker-build-controller docker-build-dispatcher docker-build-all
#
# Push Docker Containers
#
docker-push-channel: docker-build-channel
@echo 'Pushing Channel Docker Container'
docker push $(APP_PATH)/$(CHANNEL_APP_TAG)
docker-push-controller: docker-build-controller
@echo 'Pushing Controller Docker Container'
docker push $(APP_PATH)/$(CONTROLLER_APP_TAG)
docker-push-dispatcher: docker-build-dispatcher
@echo 'Pushing Dispatcher Docker Container'
docker push $(APP_PATH)/$(DISPATCHER_APP_TAG)
docker-push-all: docker-push-channel docker-push-controller docker-push-dispatcher
.PHONY: docker-push-channel docker-push-controller docker-push-dispatcher docker-push-all
#
# Support Prow Targets
#
ci-master: docker-push-all
ci-release: docker-push-all
ci-pr: docker-build-all
.PHONY: ci-master ci-release ci-pr