This repository has been archived by the owner on Oct 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 65
376 lines (361 loc) · 14.7 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
name: CI
on:
push:
pull_request:
jobs:
build-java:
# Do not run this job for pull requests where both branches are from the same repo.
# Jobs that depend on this one will be skipped too.
# This prevents duplicate CI runs for our own pull requests, whilst preserving the ability to
# run the CI for each branch push to a fork, and for each pull request originating from a fork.
if: github.event_name == 'push' || github.event.pull_request.head.repo.id != github.event.pull_request.base.repo.id
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: '17'
- name: Cache Maven packages
uses: actions/[email protected]
with:
path: ~/.m2
key: maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
maven-
- name: Build and test with Maven
run: mvn --batch-mode package
- name: Generate unit test reports
if: failure()
run: mvn --batch-mode surefire-report:report-only
- name: Upload unit-test-results
if: always()
uses: actions/upload-artifact@v3
with:
name: unit-test-results
path: "**/target/surefire-reports/TEST-*.xml"
- name: Upload alerting-storm jar
uses: actions/upload-artifact@v3
with:
name: alerting-storm
path: alerting/alerting-storm/target/alerting-storm-*.jar
- name: Upload enriching-storm jar
uses: actions/upload-artifact@v3
with:
name: enriching-storm
path: enriching/enriching-storm/target/enriching-storm-*.jar
- name: Upload parsing-storm jar
uses: actions/upload-artifact@v3
with:
name: parsing-storm
path: parsing/parsing-storm/target/parsing-storm-*.jar
- name: Upload config-editor-rest jar
uses: actions/upload-artifact@v3
with:
name: config-editor-rest
path: config-editor/config-editor-rest/target/config-editor-rest-*.jar
- name: Upload responding-stream jar
uses: actions/upload-artifact@v3
with:
name: responding-stream
path: responding/responding-stream/target/responding-stream-*.jar
- name: Upload storm-topology-manager jar
uses: actions/upload-artifact@v3
with:
name: storm-topology-manager
path: deployment/storm-topology-manager/target/storm-topology-manager-*.jar
- name: Upload siembol-monitoring jar
uses: actions/upload-artifact@v3
with:
name: siembol-monitoring
path: deployment/siembol-monitoring/target/siembol-monitoring-*.jar
build-docker-storm:
runs-on: ubuntu-latest
needs: build-java
strategy:
matrix:
component: [alerting-storm, enriching-storm, parsing-storm]
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Download jar
uses: actions/download-artifact@v3
with:
name: ${{ matrix.component }}
path: deployment/docker
- name: Get component info
id: info
run: |
[xml]$xml = Get-Content ./*/${{ matrix.component}}/pom.xml
echo "::set-output name=version::$($xml.project.parent.version)"
echo "::set-output name=class::$($xml.project.build.plugins.plugin.executions.execution.configuration.transformers.transformer.mainClass)"
shell: pwsh
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Generate Docker metadata
id: meta
uses: docker/[email protected]
with:
images: gresearchdev/siembol-${{ matrix.component }}
flavor: |
latest=${{ github.ref == 'refs/heads/main' && !endsWith(steps.info.outputs.version, '-SNAPSHOT') }}
# We use raw because our release process is not done on tag push (yet)
tags: |
type=raw,value=${{ steps.info.outputs.version }}
type=raw,value=snapshot,enable=${{ github.ref == 'refs/heads/main' && endsWith(steps.info.outputs.version, '-SNAPSHOT') }}
labels: |
org.opencontainers.image.title=siembol-${{ matrix.component }}
- name: Build and export Docker image
uses: docker/build-push-action@v3
with:
context: deployment/docker
file: deployment/docker/Dockerfile.storm
build-args: |
JAR=${{ matrix.component }}-${{ steps.info.outputs.version }}.jar
CLASS=${{ steps.info.outputs.class }}
pull: true
outputs: type=docker,dest=image.tar
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# Only run this step for main and hotfix branches.
- name: Upload Docker image
if: github.event_name == 'push' && !github.event.repository.fork && ( github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/hotfix/') )
uses: actions/upload-artifact@v3
with:
name: docker-${{ matrix.component }}
path: image.tar
build-docker-java:
runs-on: ubuntu-latest
needs: build-java
strategy:
matrix:
component: [config-editor-rest, responding-stream, storm-topology-manager, siembol-monitoring]
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Download jar
uses: actions/download-artifact@v3
with:
name: ${{ matrix.component }}
path: deployment/docker/${{ matrix.component }}
- name: Copy config defaults
run: |
cp config/${{ matrix.component}}/application.properties deployment/docker/${{ matrix.component}}/
if [ "${{ matrix.component}}" == "config-editor-rest" ]
then
mkdir deployment/docker/config-editor-rest/ui-config
cp config/config-editor-rest/*.json deployment/docker/config-editor-rest/ui-config/
fi
if [ "${{ matrix.component }}" == "storm-topology-manager" ]
then
cp config/storm-topology-manager/storm-submit.yaml deployment/docker/${{ matrix.component }}/
fi
- name: Get component info
id: info
run: |
[xml]$xml = Get-Content ./*/${{ matrix.component}}/pom.xml
echo "::set-output name=version::$($xml.project.parent.version)"
shell: pwsh
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Generate Docker metadata
id: meta
uses: docker/[email protected]
with:
images: gresearchdev/siembol-${{ matrix.component }}
flavor: |
latest=${{ github.ref == 'refs/heads/main' && !endsWith(steps.info.outputs.version, '-SNAPSHOT') }}
# We use raw because our release process is not done on tag push (yet)
tags: |
type=raw,value=${{ steps.info.outputs.version }}
type=raw,value=snapshot,enable=${{ github.ref == 'refs/heads/main' && endsWith(steps.info.outputs.version, '-SNAPSHOT') }}
labels: |
org.opencontainers.image.title=siembol-${{ matrix.component }}
- name: Build and export Docker image
uses: docker/build-push-action@v3
with:
context: deployment/docker
file: deployment/docker/Dockerfile.java
build-args: |
APP=${{ matrix.component}}
VERSION=${{ steps.info.outputs.version }}
pull: true
outputs: type=docker,dest=image.tar
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# Only run this step for main and hotfix branches.
- name: Upload Docker image
if: github.event_name == 'push' && !github.event.repository.fork && ( github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/hotfix/') )
uses: actions/upload-artifact@v3
with:
name: docker-${{ matrix.component }}
path: image.tar
build-js-config-editor-ui:
# Do not run this job for pull requests where both branches are from the same repo.
# Jobs that depend on this one will be skipped too.
# This prevents duplicate CI runs for our own pull requests, whilst preserving the ability to
# run the CI for each branch push to a fork, and for each pull request originating from a fork.
if: github.event_name == 'push' || github.event.pull_request.head.repo.id != github.event.pull_request.base.repo.id
runs-on: ubuntu-latest
defaults:
run:
working-directory: config-editor/config-editor-ui
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node.js 16.x
uses: actions/setup-node@v3
with:
node-version: 16.x
cache: npm
cache-dependency-path: config-editor/config-editor-ui/package-lock.json
- name: Install NPM packages
run: npm ci --legacy-peer-deps
- name: Testing
run: npm run test-ci
- name: Generate build-info.json
run: |
jq "{appName: \"Config Editor UI\", appVersion: .version, angularVersion: .dependencies[\"@angular/core\"], buildDate: \"$(date -u +%Y%m%d-%H:%M:%S)\", siembolCompileTimeVersion: .siembolCompileTimeVersion}" package.json > src/assets/build-info.json
- name: Build
run: npm run build-prod
- name: Copy config defaults
run: cp -r ../../config/config-editor-ui dist/config
- name: Uploading dist
uses: actions/upload-artifact@v3
with:
name: config-editor-ui
path: config-editor/config-editor-ui/dist
build-docker-config-editor-ui:
runs-on: ubuntu-latest
needs: build-js-config-editor-ui
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Download dist
uses: actions/download-artifact@v3
with:
name: config-editor-ui
path: deployment/docker/config-editor-ui
- name: Get version
id: info
run: echo "::set-output name=version::$(jq -r .appVersion deployment/docker/config-editor-ui/assets/build-info.json)"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Generate Docker metadata
id: meta
uses: docker/[email protected]
with:
images: gresearchdev/siembol-config-editor-ui
flavor: |
latest=${{ github.ref == 'refs/heads/main' && !endsWith(steps.info.outputs.version, '-dev') }}
# We use raw because our release process is not done on tag push (yet)
tags: |
type=raw,value=${{ steps.info.outputs.version }}
type=raw,value=snapshot,enable=${{ github.ref == 'refs/heads/main' && endsWith(steps.info.outputs.version, '-dev') }}
labels: |
org.opencontainers.image.title=siembol-config-editor-ui
- name: Build and export Docker image
uses: docker/build-push-action@v3
with:
context: deployment/docker
file: deployment/docker/Dockerfile.config-editor-ui
pull: true
outputs: type=docker,dest=image.tar
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# Only run this step for main and hotfix branches.
- name: Upload Docker image
if: github.event_name == 'push' && !github.event.repository.fork && ( github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/hotfix/') )
uses: actions/upload-artifact@v3
with:
name: docker-config-editor-ui
path: image.tar
release-version:
# Only run this job for main and hotfix branches.
# Jobs that depend on this one will be skipped too.
if: github.event_name == 'push' && !github.event.repository.fork && ( github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/hotfix/') )
runs-on: ubuntu-latest
needs: build-java
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Get release version
id: version
run: |
version=$(grep --max-count=1 "<version>" pom.xml | sed -E "s/.*>(.+)<.*/\1/")
echo "::set-output name=version::$version"
shell: bash
release:
runs-on: ubuntu-latest
needs: release-version
environment: release
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Cache Maven packages
uses: actions/[email protected]
with:
path: |
~/.m2
!~/.m2/settings.xml
key: maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
maven-
- name: Set up Maven Central Repository
uses: actions/setup-java@c3ac5dd0ed8db40fedb61c32fbe677e6b355e94c
with:
java-version: '17'
distribution: 'adopt'
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE
- name: Release artifacts
run: mvn --batch-mode deploy -DskipTests
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSWORD }}
release-docker:
# Only run this job for main and hotfix branches.
# Jobs that depend on this one will be skipped too.
if: github.event_name == 'push' && !github.event.repository.fork && ( github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/hotfix/') )
runs-on: ubuntu-latest
needs: [build-docker-storm, build-docker-java, build-docker-config-editor-ui]
environment: release
strategy:
matrix:
component: [alerting-storm, enriching-storm, parsing-storm, config-editor-rest, responding-stream, storm-topology-manager, config-editor-ui, siembol-monitoring]
fail-fast: false
steps:
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Download Docker image
uses: actions/download-artifact@v3
with:
name: docker-${{ matrix.component }}
- name: Load Docker image
run: docker load --input image.tar
- name: Publish Docker image
run: docker push --all-tags gresearchdev/siembol-${{ matrix.component }}
event_file:
name: "Event File"
needs: build-java
if: always() && needs.build-java.result != 'skipped'
runs-on: ubuntu-latest
steps:
- name: Upload
uses: actions/upload-artifact@v3
with:
name: Event File
path: ${{ github.event_path }}