-
Notifications
You must be signed in to change notification settings - Fork 45
485 lines (420 loc) · 21.1 KB
/
jenkins-dsl-downstream.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
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
# This workflow will build a Java project with Maven
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
name: Jenkins DSL
on:
pull_request:
paths:
- "dsl/**"
- '.github/workflows/jenkins-dsl-downstream.yml'
jobs:
#############################################################################
# Kogito
#############################################################################
getKogitoDslDownstreamMatrix:
concurrency:
group: ${{ github.repository.name }}-dsl_kogito_downstream_matrix-${{ github.head_ref }}
cancel-in-progress: true
runs-on: ubuntu-latest
name: Get Kogito DSL downstream projects
outputs:
matrix: ${{ steps.setmatrix.outputs.repositories }}
steps:
- name: Setup env
run: |
mkdir -p "${HOME}/.local/bin"
echo "${HOME}/.local/bin" >> $GITHUB_PATH
mkdir -p branch_config_repo
- name: Install yq
run: |
wget https://github.com/mikefarah/yq/releases/download/v4.25.1/yq_linux_amd64.tar.gz -O - | tar xz && ls -al && mv yq_linux_amd64 "${HOME}/.local/bin/yq"
yq --version
- name: Checkout Main Config repo from main branch
uses: actions/checkout@v3
with:
repository: apache/incubator-kie-kogito-pipelines
ref: main
path: main_config_repo
- name: Retrieve branch config file information
working-directory: main_config_repo
run: |
if [ -f '.ci/jenkins/config/main.yaml' ]; then main_config_path='.ci/jenkins/config/main.yaml'; else main_config_path='dsl/config/main.yaml'; fi # temporary for the main config change
branch_config_name=${{ github.base_ref }}
set +e
branch_config="$(yq ".git.branches[] | select(.name == \"${branch_config_name}\")" ${main_config_path})"
echo "Found branch config ${branch_config}"
if [ -z "${branch_config}" ]; then
echo "Unknown branch config name ${branch_config_name}"
echo "BRANCH_CONFIG_UNKNOWN=true" >> $GITHUB_ENV
else
branch_config_file_ref="$(yq -e ".git.branches[] | select(.name == \"${branch_config_name}\") | .seed.config_file.git.branch" ${main_config_path})"
if [ $? != 0 ]; then
branch_config_file_ref="${branch_config_name}"
fi
branch_config_file_git_repository="$(yq -e ".git.branches[] | select(.name == \"${branch_config_name}\") | .seed.config_file.git.repository" ${main_config_path})"
if [ $? != 0 ]; then
branch_config_file_git_repository=$(yq '.seed.config_file.git.repository' ${main_config_path});
fi
branch_config_file_git_author="$(yq -e ".git.branches[] | select(.name == \"${branch_config_name}\") | .seed.config_file.git.author.name" ${main_config_path})"
if [ $? != 0 ]; then
branch_config_file_git_author=$(yq '.seed.config_file.git.author.name' ${main_config_path});
fi
branch_config_file_path="$(yq -e ".git.branches[] | select(.name == \"${branch_config_name}\") | .seed.config_file.path" ${main_config_path})"
if [ $? != 0 ]; then
branch_config_file_path=$(yq '.seed.config_file.path' ${main_config_path});
fi
echo "Use branch config branch ${branch_config_file_ref}"
echo "Use branch config file repo ${branch_config_file_git_repository}"
echo "Use branch config file author ${branch_config_file_git_author}"
echo "Use branch config file path ${branch_config_file_path}"
echo "BRANCH_CONFIG_GIT_REPOSITORY=${branch_config_file_git_repository}" >> $GITHUB_ENV
echo "BRANCH_CONFIG_GIT_AUTHOR=${branch_config_file_git_author}" >> $GITHUB_ENV
echo "BRANCH_CONFIG_GIT_BRANCH=${branch_config_file_ref}" >> $GITHUB_ENV
echo "BRANCH_CONFIG_PATH=${branch_config_file_path}" >> $GITHUB_ENV
fi
- name: Verify branch config
run: |
if [ "${{ env.BRANCH_CONFIG_UNKNOWN }}" = "true" ]; then
if [ "${{ github.base_ref }}" = "main" ]; then
echo "main branch is not existing as config branch... Please verify your main config for Kogito"
exit 1
else
echo "${{ github.base_ref }} branch is not existing as config branch... Ignoring"
fi
fi
- name: Checkout branch config repo
if: ${{ env.BRANCH_CONFIG_UNKNOWN != 'true' }}
uses: actions/checkout@v3
with:
repository: ${{ env.BRANCH_CONFIG_GIT_AUTHOR }}/${{ env.BRANCH_CONFIG_GIT_REPOSITORY }}
ref: ${{ env.BRANCH_CONFIG_GIT_BRANCH }}
path: branch_config_repo
- name: Set Downstream projects matrix
id: setmatrix
working-directory: branch_config_repo
run: |
matrixArray=''
defaultAuthor=${{ github.event.pull_request.head.user.login }}
if [ "${{ env.BRANCH_CONFIG_UNKNOWN }}" != "true" ]; then
matrixArray=$(yq '.repositories[].name' ${{ env.BRANCH_CONFIG_PATH }}) # Creates array of all repositories
fi
fullArray=()
for repo in ${matrixArray};
do
echo $repo
author="$(yq '.repositories[] | select(.name == "${repo}") | .author.name' ${{ env.BRANCH_CONFIG_PATH }})"
if [ -z $author ]; then
author=${defaultAuthor}
fi
fullArray+=("${author}/${repo}")
done
fullArray+=("") # Trick so that the latest repository is also taken
echo "${fullArray[@]}"
# Start Generate Json String
echo "${fullArray[@]}" | \
jq --slurp --raw-input 'split(" ")[:-1]' | \
jq "{\"repository\": .[] }" | \
jq -sc "{ \"include\": . }" > tmp
cat ./tmp
# End Generate Json String
echo "repositories=$(cat ./tmp)" >> $GITHUB_OUTPUT # Use this as jq @sh wasn't cooperating
runKogitoDownstreamDslTests:
concurrency:
group: ${{ github.repository.name }}-dsl_kogito_downstream_${{ matrix.repository }}_tests-${{ github.head_ref }}
cancel-in-progress: true
runs-on: ubuntu-latest
needs: getKogitoDslDownstreamMatrix
strategy:
matrix: ${{fromJson(needs.getKogitoDslDownstreamMatrix.outputs.matrix)}}
fail-fast: false
name: Kogito DSL Downstream tests - ${{ matrix.repository }}
steps:
- name: Setup default branch
run: |
echo 'BASE_BRANCH=${{ github.base_ref }}' >> $GITHUB_ENV
- name: DSL tests
uses: kiegroup/kie-ci/.ci/actions/dsl-tests@main
with:
project: kogito
repository: ${{ matrix.repository }}
main-config-file-repo: apache/incubator-kie-kogito-pipelines
main-config-file-path: .ci/jenkins/config/main.yaml
branch-config-file-repo: apache/incubator-kie-kogito-pipelines
base-branch: ${{ env.BASE_BRANCH }}
#############################################################################
# Optaplanner
#############################################################################
getOptaPlannerDslDownstreamMatrix:
concurrency:
group: ${{ github.repository.name }}-dsl_optaplanner_downstream_matrix-${{ github.head_ref }}
cancel-in-progress: true
runs-on: ubuntu-latest
name: Get OptaPlanner DSL downstream projects
outputs:
matrix: ${{ steps.setmatrix.outputs.repositories }}
branch_config_git_repository: ${{ steps.setbranchconfig.outputs.branch_config_git_repository }}
branch_config_git_author: ${{ steps.setbranchconfig.outputs.branch_config_git_author }}
branch_config_git_branch: ${{ steps.setbranchconfig.outputs.branch_config_git_branch }}
branch_config_path: ${{ steps.setbranchconfig.outputs.branch_config_path }}
steps:
- name: Setup env
run: |
mkdir -p "${HOME}/.local/bin"
echo "${HOME}/.local/bin" >> $GITHUB_PATH
mkdir -p branch_config_repo
- name: Install yq
run: |
wget https://github.com/mikefarah/yq/releases/download/v4.25.1/yq_linux_amd64.tar.gz -O - | tar xz && ls -al && mv yq_linux_amd64 "${HOME}/.local/bin/yq"
yq --version
- name: Checkout Main Config repo from main branch
uses: actions/checkout@v3
with:
repository: apache/incubator-kie-optaplanner
ref: main
path: main_config_repo
- name: Retrieve branch config file information
working-directory: main_config_repo
run: |
main_config_path='.ci/jenkins/config/main.yaml'
branch_config_name=${{ github.base_ref }}
set +e
branch_config="$(yq ".git.branches[] | select(.name == \"${branch_config_name}\")" ${main_config_path})"
echo "Found branch config ${branch_config}"
if [ -z "${branch_config}" ]; then
echo "Unknown branch config name ${branch_config_name}"
echo "BRANCH_CONFIG_UNKNOWN=true" >> $GITHUB_ENV
else
branch_config_file_ref="$(yq -e ".git.branches[] | select(.name == \"${branch_config_name}\") | .seed.config_file.git.branch" ${main_config_path})"
if [ $? != 0 ]; then
branch_config_file_ref="${branch_config_name}"
fi
branch_config_file_git_repository="$(yq -e ".git.branches[] | select(.name == \"${branch_config_name}\") | .seed.config_file.git.repository" ${main_config_path})"
if [ $? != 0 ]; then
branch_config_file_git_repository=$(yq '.seed.config_file.git.repository' ${main_config_path});
fi
branch_config_file_git_author="$(yq -e ".git.branches[] | select(.name == \"${branch_config_name}\") | .seed.config_file.git.author.name" ${main_config_path})"
if [ $? != 0 ]; then
branch_config_file_git_author=$(yq '.seed.config_file.git.author.name' ${main_config_path});
fi
branch_config_file_path="$(yq -e ".git.branches[] | select(.name == \"${branch_config_name}\") | .seed.config_file.path" ${main_config_path})"
if [ $? != 0 ]; then
branch_config_file_path=$(yq '.seed.config_file.path' ${main_config_path});
fi
echo "Use branch config branch ${branch_config_file_ref}"
echo "Use branch config file repo ${branch_config_file_git_repository}"
echo "Use branch config file author ${branch_config_file_git_author}"
echo "Use branch config file path ${branch_config_file_path}"
echo "BRANCH_CONFIG_GIT_REPOSITORY=${branch_config_file_git_repository}" >> $GITHUB_ENV
echo "BRANCH_CONFIG_GIT_AUTHOR=${branch_config_file_git_author}" >> $GITHUB_ENV
echo "BRANCH_CONFIG_GIT_BRANCH=${branch_config_file_ref}" >> $GITHUB_ENV
echo "BRANCH_CONFIG_PATH=${branch_config_file_path}" >> $GITHUB_ENV
fi
- name: Verify branch config
run: |
if [ "${{ env.BRANCH_CONFIG_UNKNOWN }}" = "true" ]; then
if [ "${{ github.base_ref }}" = "main" ]; then
echo "main branch is not existing as config branch... Please verify your main config for Kogito"
exit 1
else
echo "${{ github.base_ref }} branch is not existing as config branch... Ignoring"
fi
fi
- name: Checkout branch config repo
if: ${{ env.BRANCH_CONFIG_UNKNOWN != 'true' }}
uses: actions/checkout@v3
with:
repository: ${{ env.BRANCH_CONFIG_GIT_AUTHOR }}/${{ env.BRANCH_CONFIG_GIT_REPOSITORY }}
ref: ${{ env.BRANCH_CONFIG_GIT_BRANCH }}
path: branch_config_repo
- name: Set Downstream projects matrix
id: setmatrix
working-directory: branch_config_repo
run: |
matrixArray=''
defaultAuthor=${{ github.event.pull_request.head.user.login }}
if [ "${{ env.BRANCH_CONFIG_UNKNOWN }}" != "true" ]; then
matrixArray=$(yq '.repositories[].name' ${{ env.BRANCH_CONFIG_PATH }}) # Creates array of all repositories
fi
fullArray=()
for repo in ${matrixArray};
do
echo $repo
author="$(yq '.repositories[] | select(.name == "${repo}") | .author.name' ${{ env.BRANCH_CONFIG_PATH }})"
if [ -z $author ]; then
author=${defaultAuthor}
fi
fullArray+=("${author}/${repo}")
done
fullArray+=("") # Trick so that the latest repository is also taken
echo "${fullArray[@]}"
# Start Generate Json String
echo "${fullArray[@]}" | \
jq --slurp --raw-input 'split(" ")[:-1]' | \
jq "{\"repository\": .[] }" | \
jq -sc "{ \"include\": . }" > tmp
cat ./tmp
# End Generate Json String
echo "repositories=$(cat ./tmp)" >> $GITHUB_OUTPUT # Use this as jq @sh wasn't cooperating
runOtaPlannerDownstreamDslTests:
runs-on: ubuntu-latest
needs: getOptaPlannerDslDownstreamMatrix
strategy:
matrix: ${{fromJson(needs.getOptaPlannerDslDownstreamMatrix.outputs.matrix)}}
fail-fast: false
concurrency:
group: ${{ github.repository.name }}-dsl_optaplanner_downstream_${{ matrix.repository }}_tests-${{ github.head_ref }}
cancel-in-progress: true
name: OptaPlanner DSL Downstream tests - ${{ matrix.repository }}
steps:
- name: Setup default base branch
run: |
echo 'BASE_BRANCH=${{ github.base_ref }}' >> $GITHUB_ENV
- name: Setup correct base branch for optaplanner-quickstarts
if: github.base_ref == 'main' && matrix.repository == 'incubator-kie-optaplanner-quickstarts'
run: |
echo 'BASE_BRANCH=development' >> $GITHUB_ENV
- name: DSL tests
uses: kiegroup/kie-ci/.ci/actions/dsl-tests@main
with:
project: optaplanner
repository: ${{ matrix.repository }}
main-config-file-repo: apache/incubator-kie-optaplanner
main-config-file-path: .ci/jenkins/config/main.yaml
branch-config-file-repo: apache/incubator-kie-optaplanner
base-branch: ${{ env.BASE_BRANCH }}
#############################################################################
# Drools
#############################################################################
getDroolsDslDownstreamMatrix:
concurrency:
group: ${{ github.repository.name }}-dsl_drools_downstream_matrix-${{ github.head_ref }}
cancel-in-progress: true
runs-on: ubuntu-latest
name: Get Drools DSL downstream projects
outputs:
matrix: ${{ steps.setmatrix.outputs.repositories }}
branch_config_git_repository: ${{ steps.setbranchconfig.outputs.branch_config_git_repository }}
branch_config_git_author: ${{ steps.setbranchconfig.outputs.branch_config_git_author }}
branch_config_git_branch: ${{ steps.setbranchconfig.outputs.branch_config_git_branch }}
branch_config_path: ${{ steps.setbranchconfig.outputs.branch_config_path }}
steps:
- name: Setup env
run: |
mkdir -p "${HOME}/.local/bin"
echo "${HOME}/.local/bin" >> $GITHUB_PATH
mkdir -p branch_config_repo
- name: Install yq
run: |
wget https://github.com/mikefarah/yq/releases/download/v4.25.1/yq_linux_amd64.tar.gz -O - | tar xz && ls -al && mv yq_linux_amd64 "${HOME}/.local/bin/yq"
yq --version
- name: Checkout Main Config repo from main branch
uses: actions/checkout@v3
with:
repository: apache/incubator-kie-drools
ref: main
path: main_config_repo
- name: Retrieve branch config file information
working-directory: main_config_repo
run: |
main_config_path='.ci/jenkins/config/main.yaml'
branch_config_name=${{ github.base_ref }}
set +e
branch_config="$(yq ".git.branches[] | select(.name == \"${branch_config_name}\")" ${main_config_path})"
echo "Found branch config ${branch_config}"
if [ -z "${branch_config}" ]; then
echo "Unknown branch config name ${branch_config_name}"
echo "BRANCH_CONFIG_UNKNOWN=true" >> $GITHUB_ENV
else
branch_config_file_ref="$(yq -e ".git.branches[] | select(.name == \"${branch_config_name}\") | .seed.config_file.git.branch" ${main_config_path})"
if [ $? != 0 ]; then
branch_config_file_ref="${branch_config_name}"
fi
branch_config_file_git_repository="$(yq -e ".git.branches[] | select(.name == \"${branch_config_name}\") | .seed.config_file.git.repository" ${main_config_path})"
if [ $? != 0 ]; then
branch_config_file_git_repository=$(yq '.seed.config_file.git.repository' ${main_config_path});
fi
branch_config_file_git_author="$(yq -e ".git.branches[] | select(.name == \"${branch_config_name}\") | .seed.config_file.git.author.name" ${main_config_path})"
if [ $? != 0 ]; then
branch_config_file_git_author=$(yq '.seed.config_file.git.author.name' ${main_config_path});
fi
branch_config_file_path="$(yq -e ".git.branches[] | select(.name == \"${branch_config_name}\") | .seed.config_file.path" ${main_config_path})"
if [ $? != 0 ]; then
branch_config_file_path=$(yq '.seed.config_file.path' ${main_config_path});
fi
echo "Use branch config branch ${branch_config_file_ref}"
echo "Use branch config file repo ${branch_config_file_git_repository}"
echo "Use branch config file author ${branch_config_file_git_author}"
echo "Use branch config file path ${branch_config_file_path}"
echo "BRANCH_CONFIG_GIT_REPOSITORY=${branch_config_file_git_repository}" >> $GITHUB_ENV
echo "BRANCH_CONFIG_GIT_AUTHOR=${branch_config_file_git_author}" >> $GITHUB_ENV
echo "BRANCH_CONFIG_GIT_BRANCH=${branch_config_file_ref}" >> $GITHUB_ENV
echo "BRANCH_CONFIG_PATH=${branch_config_file_path}" >> $GITHUB_ENV
fi
- name: Verify branch config
run: |
if [ "${{ env.BRANCH_CONFIG_UNKNOWN }}" = "true" ]; then
if [ "${{ github.base_ref }}" = "main" ]; then
echo "main branch is not existing as config branch... Please verify your main config for Kogito"
exit 1
else
echo "${{ github.base_ref }} branch is not existing as config branch... Ignoring"
fi
fi
- name: Checkout branch config repo
if: ${{ env.BRANCH_CONFIG_UNKNOWN != 'true' }}
uses: actions/checkout@v3
with:
repository: ${{ env.BRANCH_CONFIG_GIT_AUTHOR }}/${{ env.BRANCH_CONFIG_GIT_REPOSITORY }}
ref: ${{ env.BRANCH_CONFIG_GIT_BRANCH }}
path: branch_config_repo
- name: Set Downstream projects matrix
id: setmatrix
working-directory: branch_config_repo
run: |
matrixArray=''
defaultAuthor=${{ github.event.pull_request.head.user.login }}
if [ "${{ env.BRANCH_CONFIG_UNKNOWN }}" != "true" ]; then
matrixArray=$(yq '.repositories[].name' ${{ env.BRANCH_CONFIG_PATH }}) # Creates array of all repositories
fi
fullArray=()
for repo in ${matrixArray};
do
echo $repo
author="$(yq '.repositories[] | select(.name == "${repo}") | .author.name' ${{ env.BRANCH_CONFIG_PATH }})"
if [ -z $author ]; then
author=${defaultAuthor}
fi
fullArray+=("${author}/${repo}")
done
fullArray+=("") # Trick so that the latest repository is also taken
echo "${fullArray[@]}"
# Start Generate Json String
echo "${fullArray[@]}" | \
jq --slurp --raw-input 'split(" ")[:-1]' | \
jq "{\"repository\": .[] }" | \
jq -sc "{ \"include\": . }" > tmp
cat ./tmp
# End Generate Json String
echo "repositories=$(cat ./tmp)" >> $GITHUB_OUTPUT # Use this as jq @sh wasn't cooperating
runDroolsDownstreamDslTests:
runs-on: ubuntu-latest
needs: getDroolsDslDownstreamMatrix
strategy:
matrix: ${{fromJson(needs.getDroolsDslDownstreamMatrix.outputs.matrix)}}
fail-fast: false
concurrency:
group: ${{ github.repository.name }}-dsl_drools_downstream_${{ matrix.repository }}_tests-${{ github.head_ref }}
cancel-in-progress: true
name: Drools DSL Downstream tests - ${{ matrix.repository }}
steps:
- name: Setup default base branch
run: |
echo 'BASE_BRANCH=${{ github.base_ref }}' >> $GITHUB_ENV
- name: DSL tests
uses: kiegroup/kie-ci/.ci/actions/dsl-tests@main
with:
project: drools
repository: ${{ matrix.repository }}
main-config-file-repo: apache/incubator-kie-drools
main-config-file-path: .ci/jenkins/config/main.yaml
branch-config-file-repo: apache/incubator-kie-drools
base-branch: ${{ env.BASE_BRANCH }}