-
Notifications
You must be signed in to change notification settings - Fork 55
436 lines (406 loc) · 13.3 KB
/
ci.yml
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
name: ci
on:
push:
branches:
- master
tags:
- v*
pull_request:
jobs:
setup:
runs-on: ubuntu-latest
outputs:
version-tag: ${{ steps.regex-match.outputs.match }}
steps:
- uses: actions-ecosystem/action-regex-match@v2
id: regex-match
with:
text: ${{ github.ref_name }}
regex: '^v[0-9]+(\.[0-9]+)*(-[a-zA-Z0-9-]+)?$'
- name: Print setup
run: |
echo github.ref=${{ github.ref }}
echo github.ref_name=${{ github.ref_name }}
echo github.ref_type=${{ github.ref_type }}
echo release-ref=${{ steps.regex-match.outputs.match }}
test010:
runs-on: ubuntu-latest
container:
image: cimg/go:1.19
env:
GO111MODULE: "on"
KAFKA_TOPICS_TEST_ZK_ADDR: zookeeper:2181
KAFKA_TOPICS_TEST_KAFKA_ADDR: kafka1:9092
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Go setup
uses: actions/setup-go@v3
with:
go-version: 1.19
- name: Display Go version
run: go version
- name: Run tests
run: make test
env:
KAFKA_TOPICS_TEST_ZK_ADDR: zookeeper:2181
KAFKA_TOPICS_TEST_KAFKA_ADDR: kafka1:9092
services:
zookeeper:
image: bitnami/zookeeper:latest
ports:
- "2181:2181"
env:
ALLOW_ANONYMOUS_LOGIN: yes
kafka1:
image: bitnami/kafka:0.10.2.1
ports:
- "9092:9092"
env:
KAFKA_BROKER_ID: 1
KAFKA_BROKER_RACK: zone1
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
ALLOW_PLAINTEXT_LISTENER: yes
KAFKA_ADVERTISED_HOST_NAME: kafka1
KAFKA_ADVERTISED_PORT: 9092
kafka2:
image: bitnami/kafka:0.10.2.1
ports:
- "9093:9092"
env:
KAFKA_BROKER_ID: 2
KAFKA_BROKER_RACK: zone1
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
ALLOW_PLAINTEXT_LISTENER: yes
KAFKA_ADVERTISED_HOST_NAME: kafka2
KAFKA_ADVERTISED_PORT: 9092
kafka3:
image: bitnami/kafka:0.10.2.1
ports:
- "9094:9092"
env:
KAFKA_BROKER_ID: 3
KAFKA_BROKER_RACK: zone2
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
ALLOW_PLAINTEXT_LISTENER: yes
KAFKA_ADVERTISED_HOST_NAME: kafka3
KAFKA_ADVERTISED_PORT: 9092
kafka4:
image: bitnami/kafka:0.10.2.1
ports:
- "9095:9092"
env:
KAFKA_BROKER_ID: 4
KAFKA_BROKER_RACK: zone2
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
ALLOW_PLAINTEXT_LISTENER: yes
KAFKA_ADVERTISED_HOST_NAME: kafka4
KAFKA_ADVERTISED_PORT: 9092
kafka5:
image: bitnami/kafka:0.10.2.1
ports:
- "9096:9092"
env:
KAFKA_BROKER_ID: 5
KAFKA_BROKER_RACK: zone3
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
ALLOW_PLAINTEXT_LISTENER: yes
KAFKA_ADVERTISED_HOST_NAME: kafka5
KAFKA_ADVERTISED_PORT: 9092
kafka6:
image: bitnami/kafka:0.10.2.1
ports:
- "9097:9092"
env:
KAFKA_BROKER_ID: 6
KAFKA_BROKER_RACK: zone3
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
ALLOW_PLAINTEXT_LISTENER: yes
KAFKA_ADVERTISED_HOST_NAME: kafka6
KAFKA_ADVERTISED_PORT: 9092
test270:
runs-on: ubuntu-latest
container:
image: cimg/go:1.19
env:
GO111MODULE: "on"
KAFKA_TOPICS_TEST_ZK_ADDR: zookeeper:2181
KAFKA_TOPICS_TEST_KAFKA_ADDR: kafka1:9092
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Go setup
uses: actions/setup-go@v3
with:
go-version: 1.19
- name: Display Go version
run: go version
- name: Run tests
run: make test-v2
env:
KAFKA_TOPICS_TEST_ZK_ADDR: zookeeper:2181
KAFKA_TOPICS_TEST_KAFKA_ADDR: kafka1:9092
KAFKA_TOPICS_TEST_BROKER_ADMIN_SECURITY: 1
services:
zookeeper:
image: bitnami/zookeeper:latest
ports:
- "2181:2181"
env:
ALLOW_ANONYMOUS_LOGIN: yes
kafka1:
image: bitnami/kafka:2.7.0
ports:
- "9092:9092"
env:
KAFKA_CFG_BROKER_ID: 1
KAFKA_CFG_BROKER_RACK: zone1
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
ALLOW_PLAINTEXT_LISTENER: yes
KAFKA_CFG_ADVERTISED_HOST_NAME: kafka1
KAFKA_CFG_ADVERTISED_PORT: 9092
KAFKA_CFG_AUTHORIZER_CLASS_NAME: kafka.security.authorizer.AclAuthorizer
KAFKA_CFG_ALLOW_EVERYONE_IF_NO_ACL_FOUND: true
kafka2:
image: bitnami/kafka:2.7.0
ports:
- "9093:9092"
env:
KAFKA_CFG_BROKER_ID: 2
KAFKA_CFG_BROKER_RACK: zone1
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
ALLOW_PLAINTEXT_LISTENER: yes
KAFKA_CFG_ADVERTISED_HOST_NAME: kafka2
KAFKA_CFG_ADVERTISED_PORT: 9092
KAFKA_CFG_AUTHORIZER_CLASS_NAME: kafka.security.authorizer.AclAuthorizer
KAFKA_CFG_ALLOW_EVERYONE_IF_NO_ACL_FOUND: true
kafka3:
image: bitnami/kafka:2.7.0
ports:
- "9094:9092"
env:
KAFKA_CFG_BROKER_ID: 3
KAFKA_CFG_BROKER_RACK: zone2
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
ALLOW_PLAINTEXT_LISTENER: yes
KAFKA_CFG_ADVERTISED_HOST_NAME: kafka3
KAFKA_CFG_ADVERTISED_PORT: 9092
KAFKA_CFG_AUTHORIZER_CLASS_NAME: kafka.security.authorizer.AclAuthorizer
KAFKA_CFG_ALLOW_EVERYONE_IF_NO_ACL_FOUND: true
kafka4:
image: bitnami/kafka:2.7.0
ports:
- "9095:9092"
env:
KAFKA_CFG_BROKER_ID: 4
KAFKA_CFG_BROKER_RACK: zone2
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
ALLOW_PLAINTEXT_LISTENER: yes
KAFKA_CFG_ADVERTISED_HOST_NAME: kafka4
KAFKA_CFG_ADVERTISED_PORT: 9092
KAFKA_CFG_AUTHORIZER_CLASS_NAME: kafka.security.authorizer.AclAuthorizer
KAFKA_CFG_ALLOW_EVERYONE_IF_NO_ACL_FOUND: true
kafka5:
image: bitnami/kafka:2.7.0
ports:
- "9096:9092"
env:
KAFKA_CFG_BROKER_ID: 5
KAFKA_CFG_BROKER_RACK: zone3
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
ALLOW_PLAINTEXT_LISTENER: yes
KAFKA_CFG_ADVERTISED_HOST_NAME: kafka5
KAFKA_CFG_ADVERTISED_PORT: 9092
KAFKA_CFG_AUTHORIZER_CLASS_NAME: kafka.security.authorizer.AclAuthorizer
KAFKA_CFG_ALLOW_EVERYONE_IF_NO_ACL_FOUND: true
kafka6:
image: bitnami/kafka:2.7.0
ports:
- "9097:9092"
env:
KAFKA_CFG_BROKER_ID: 6
KAFKA_CFG_BROKER_RACK: zone3
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
ALLOW_PLAINTEXT_LISTENER: yes
KAFKA_CFG_ADVERTISED_HOST_NAME: kafka6
KAFKA_CFG_ADVERTISED_PORT: 9092
KAFKA_CFG_AUTHORIZER_CLASS_NAME: kafka.security.authorizer.AclAuthorizer
KAFKA_CFG_ALLOW_EVERYONE_IF_NO_ACL_FOUND: true
test360:
runs-on: ubuntu-latest
container:
image: cimg/go:1.19
env:
GO111MODULE: "on"
KAFKA_TOPICS_TEST_ZK_ADDR: zookeeper:2181
KAFKA_TOPICS_TEST_KAFKA_ADDR: kafka1:9092
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Go setup
uses: actions/setup-go@v3
with:
go-version: 1.19
- name: Display Go version
run: go version
- name: Run tests
run: make test-v2
env:
KAFKA_TOPICS_TEST_ZK_ADDR: zookeeper:2181
KAFKA_TOPICS_TEST_KAFKA_ADDR: kafka1:9092
KAFKA_TOPICS_TEST_BROKER_ADMIN_SECURITY: 1
services:
zookeeper:
image: bitnami/zookeeper:latest
ports:
- "2181:2181"
env:
ALLOW_ANONYMOUS_LOGIN: yes
kafka1:
image: bitnami/kafka:3.6.0
ports:
- "9092:9092"
env:
KAFKA_CFG_BROKER_ID: 1
KAFKA_CFG_BROKER_RACK: zone1
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
ALLOW_PLAINTEXT_LISTENER: yes
KAFKA_CFG_ADVERTISED_HOST_NAME: kafka1
KAFKA_CFG_ADVERTISED_PORT: 9092
KAFKA_CFG_AUTHORIZER_CLASS_NAME: kafka.security.authorizer.AclAuthorizer
KAFKA_CFG_ALLOW_EVERYONE_IF_NO_ACL_FOUND: true
kafka2:
image: bitnami/kafka:3.6.0
ports:
- "9093:9092"
env:
KAFKA_CFG_BROKER_ID: 2
KAFKA_CFG_BROKER_RACK: zone1
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
ALLOW_PLAINTEXT_LISTENER: yes
KAFKA_CFG_ADVERTISED_HOST_NAME: kafka2
KAFKA_CFG_ADVERTISED_PORT: 9092
KAFKA_CFG_AUTHORIZER_CLASS_NAME: kafka.security.authorizer.AclAuthorizer
KAFKA_CFG_ALLOW_EVERYONE_IF_NO_ACL_FOUND: true
kafka3:
image: bitnami/kafka:3.6.0
ports:
- "9094:9092"
env:
KAFKA_CFG_BROKER_ID: 3
KAFKA_CFG_BROKER_RACK: zone2
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
ALLOW_PLAINTEXT_LISTENER: yes
KAFKA_CFG_ADVERTISED_HOST_NAME: kafka3
KAFKA_CFG_ADVERTISED_PORT: 9092
KAFKA_CFG_AUTHORIZER_CLASS_NAME: kafka.security.authorizer.AclAuthorizer
KAFKA_CFG_ALLOW_EVERYONE_IF_NO_ACL_FOUND: true
kafka4:
image: bitnami/kafka:3.6.0
ports:
- "9095:9092"
env:
KAFKA_CFG_BROKER_ID: 4
KAFKA_CFG_BROKER_RACK: zone2
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
ALLOW_PLAINTEXT_LISTENER: yes
KAFKA_CFG_ADVERTISED_HOST_NAME: kafka4
KAFKA_CFG_ADVERTISED_PORT: 9092
KAFKA_CFG_AUTHORIZER_CLASS_NAME: kafka.security.authorizer.AclAuthorizer
KAFKA_CFG_ALLOW_EVERYONE_IF_NO_ACL_FOUND: true
kafka5:
image: bitnami/kafka:3.6.0
ports:
- "9096:9092"
env:
KAFKA_CFG_BROKER_ID: 5
KAFKA_CFG_BROKER_RACK: zone3
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
ALLOW_PLAINTEXT_LISTENER: yes
KAFKA_CFG_ADVERTISED_HOST_NAME: kafka5
KAFKA_CFG_ADVERTISED_PORT: 9092
KAFKA_CFG_AUTHORIZER_CLASS_NAME: kafka.security.authorizer.AclAuthorizer
KAFKA_CFG_ALLOW_EVERYONE_IF_NO_ACL_FOUND: true
kafka6:
image: bitnami/kafka:3.6.0
ports:
- "9097:9092"
env:
KAFKA_CFG_BROKER_ID: 6
KAFKA_CFG_BROKER_RACK: zone3
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
ALLOW_PLAINTEXT_LISTENER: yes
KAFKA_CFG_ADVERTISED_HOST_NAME: kafka6
KAFKA_CFG_ADVERTISED_PORT: 9092
KAFKA_CFG_AUTHORIZER_CLASS_NAME: kafka.security.authorizer.AclAuthorizer
KAFKA_CFG_ALLOW_EVERYONE_IF_NO_ACL_FOUND: true
publish-ghcr:
needs: [setup, test010, test270, test360]
runs-on: ubuntu-latest
if: ${{ ( github.ref_type == 'branch' ) && (( github.ref_name == 'master' ) || ( github.ref_name == 'v0' )) }}
steps:
- uses: actions/checkout@v3
- name: setup env variables
id: vars
run: |
echo "SHORT_SHA=${GITHUB_SHA:0:8}" >> $GITHUB_ENV
- run: echo "publishing the image ghcr.io/segmentio/topicctl:${SHORT_SHA}"
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
logout: true
- run: echo "GHCR LOGIN SUCCESSFUL"
- if: ${{ github.ref_name == 'master' }}
name: Build and push image for master
run: |
docker context create buildx-build
docker buildx create --use buildx-build
docker buildx build \
-t ghcr.io/segmentio/topicctl:${SHORT_SHA} \
-t ghcr.io/segmentio/topicctl:latest \
--build-arg VERSION=${SHORT_SHA} \
--push \
.
- if: ${{ github.ref_name == 'v0' }}
name: Build and push image for v0
run: |
docker context create buildx-build
docker buildx create --use buildx-build
docker buildx build \
-t ghcr.io/segmentio/topicctl:${SHORT_SHA} \
--build-arg VERSION=${SHORT_SHA} \
--push \
.
- run: echo "GHCR PUBLISH SUCCESSFUL"
publish-dockerhub:
needs: [setup, test010, test270, test360]
environment: CICD
env:
RELEASE_TAG: ${{ needs.setup.outputs.version-tag }}
runs-on: ubuntu-latest
if: ${{ ( github.ref_type == 'tag' ) && ( needs.setup.outputs.version-tag != '') }}
steps:
- uses: actions/checkout@v3
- run: echo "publishing the release version segment/topicctl:${RELEASE_TAG}"
- name: Dockerhub login
uses: docker/login-action@v2
with:
username: ${{ vars.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
logout: true
- run: echo "DOCKERHUB LOGIN SUCCESSFUL"
- name: Build and push image
run: |
docker context create buildx-build
docker buildx create --use buildx-build
docker buildx build \
--platform=linux/amd64,linux/arm64 \
-t segment/topicctl:${RELEASE_TAG} \
-t segment/topicctl:latest \
--build-arg VERSION=${RELEASE_TAG} \
--push \
.
- run: echo "DOCKERHUB PUBLISH SUCCESSFUL"