forked from StarRocks/starrocks
-
Notifications
You must be signed in to change notification settings - Fork 1
666 lines (592 loc) · 20.3 KB
/
ci-pipeline.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
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
name: CI PIPELINE
on:
pull_request_target:
types:
- opened
- synchronize
branches:
- main
concurrency:
group: ${{ github.event.number }}
cancel-in-progress: true
permissions:
checks: write
actions: write
contents: write
deployments: write
discussions: write
issues: write
packages: write
pages: write
pull-requests: write
repository-projects: write
security-events: write
statuses: write
jobs:
doc-checker:
runs-on: ubuntu-latest
name: DOC FILTER
outputs:
output1: ${{ steps.doc-changes-info.outputs.doc }}
steps:
- uses: dorny/paths-filter@v2
id: changes
with:
filters: |
doc:
- 'docs/**'
- name: DOC CHECK INFO
id: doc-changes-info
run: |
echo "doc=${{ steps.changes.outputs.doc }}" >> $GITHUB_OUTPUT
add-doc-label:
needs: doc-checker
runs-on: ubuntu-latest
name: ADD DOC LABEL
if: ${{ needs.doc-checker.outputs.output1 == 'true' }}
steps:
- name: add document label
uses: actions-ecosystem/action-add-labels@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
labels: documentation
markdownlint:
runs-on: ubuntu-latest
needs: add-doc-label
steps:
- name: Check out code
uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: articulate/[email protected]
with:
config: "docs/.markdownlint.yaml"
files: 'docs/**/*.md'
ignore: node_modules
version: 0.28.1
be-checker:
runs-on: ubuntu-latest
name: BE FILTER
outputs:
output1: ${{ steps.be-changes-info.outputs.be }}
output2: ${{ steps.be-changes-info.outputs.thirdparty }}
steps:
- uses: dorny/paths-filter@v2
id: changes
with:
filters: |
be:
- 'be/**'
- 'gensrc/**'
- 'run-be-ut.sh'
- 'build.sh'
- 'thirdparty/**'
- 'docker/dockerfiles/dev-env/dev-env.Dockerfile'
thirdparty:
- 'thirdparty/**'
- 'docker/dockerfiles/dev-env/dev-env.Dockerfile'
- name: BE CHECK INFO
id: be-changes-info
run: |
echo "be=${{ steps.changes.outputs.be }}" >> $GITHUB_OUTPUT
echo "thirdparty=${{ steps.changes.outputs.thirdparty }}" >> $GITHUB_OUTPUT
clang-format:
runs-on: self-hosted
needs: be-checker
name: Clang-Format
env:
PR_NUMBER: ${{ github.event.number }}
if: ${{ needs.be-checker.outputs.output1 == 'true' }}
steps:
- name: Clean Workspace
uses: AutoModality/[email protected]
- name: Checkout Code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: BRANCH INFO
id: branch
run: |
echo ${{github.base_ref}}
echo "branch=${{github.base_ref}}" >> $GITHUB_OUTPUT
- name: Checkout PR
run: |
BRANCH=${{steps.branch.outputs.branch}}
git checkout $BRANCH;
git pull;
BRANCH_NAME="${BRANCH}-${PR_NUMBER}";
git fetch origin pull/${PR_NUMBER}/head:${BRANCH_NAME};
git checkout $BRANCH_NAME;
git checkout -b merge_pr;
git merge --squash --no-edit ${BRANCH} || (echo "Merge conflict, please check." && exit -1);
- name: Run Clang-Format
run: |
export PATH=/var/lib/llvm/bin:$PATH
bash build-support/check-format.sh
thirdparty-update:
runs-on: self-hosted
needs: [ be-checker, clang-format ]
name: Thirdparty Update
env:
PR_NUMBER: ${{ github.event.number }}
BRANCH: ${{ github.base_ref }}
outputs:
ip: ${{ steps.update-image.outputs.ip }}
instance_id: ${{ steps.update-image.outputs.instance_id }}
image_cache_id: ${{ steps.update-image.outputs.image_cache_id }}
steps:
- name: Clean Workspace
uses: AutoModality/[email protected]
- name: Checkout Code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Update Image
id: update-image
run: |
set -ex
if [[ "${{ needs.be-checker.outputs.output2 }}" == 'true' ]]; then
rm -rf ./elastic-service
cp -rf /var/lib/elastic-service ./elastic-service
cd elastic-service && git pull
./bin/elastic-cluster.sh --template ci-image --run
ip=$(grep instances_ips conf/starrocks_deploy.conf | head -n 1 | awk '{print $NF}')
instance_id=$(grep instances conf/starrocks_deploy.conf | head -n 1 | awk '{print $NF}')
echo "ip=${ip}" >> $GITHUB_OUTPUT
echo "instance_id=${instance_id}" >> $GITHUB_OUTPUT
sleep 30
sudo ssh-keygen -f "/root/.ssh/known_hosts" -R "${ip}" || true
sshpass -p ${{ secrets.PASSWORD }} scp -o StrictHostKeyChecking=no -r bin/elastic-build-thirdparty.sh root@$ip:/home/disk1/
sshpass -p ${{ secrets.PASSWORD }} ssh -o StrictHostKeyChecking=no root@$ip "cd /home/disk1; ./elastic-build-thirdparty.sh $BRANCH $PR_NUMBER"
image_cache_id=$(python3 lib/eci_imagecache.py create $BRANCH-$PR_NUMBER)
echo "image_cache_id=${image_cache_id}" >> $GITHUB_OUTPUT
fi
- name: Clean ENV
if: always()
run: |
if [[ "${{ needs.be-checker.outputs.output2 }}" == 'true' ]]; then
cd elastic-service
./bin/elastic-cluster.sh --delete
fi
be-ut:
runs-on: self-hosted
needs: [ be-checker, thirdparty-update ]
timeout-minutes: 90
name: BE UT
env:
PR_NUMBER: ${{ github.event.number }}
BRANCH: ${{ github.base_ref }}
steps:
- name: BRANCH INFO
id: branch
run: |
echo ${{github.base_ref}}
echo "branch=${{github.base_ref}}" >> $GITHUB_OUTPUT
- name: UPDATE ECI & RUN UT
id: run_ut
shell: bash
timeout-minutes: 90
run: |
set -ex
rm -rf ./elastic-service
ln -s /var/lib/elastic-service ./elastic-service
cd elastic-service && git pull
if [[ "${{ needs.be-checker.outputs.output2 }}" == 'true' ]]; then
export image_cache_id=${{ needs.thirdparty-update.outputs.image_cache_id }}
export image_tag=$BRANCH-$PR_NUMBER
fi
./bin/elastic-ut.sh --pr ${PR_NUMBER} --module be
- name: clean ECI
if: always()
run: |
echo ${{ steps.run_ut.outputs.ECI_ID }}
eci rm ${{ steps.run_ut.outputs.ECI_ID }}
- name: Upload log
uses: actions/upload-artifact@v3
if: always()
with:
name: BE UT LOG
path: ${{ steps.run_ut.outputs.RES_LOG }}
retention-days: 1
- name: Clean ENV
if: always()
run: |
rm -f ${{ steps.run_ut.outputs.RES_FILE }}
rm -f ${{ steps.run_ut.outputs.RES_LOG }}
fe-checker:
runs-on: ubuntu-latest
name: FE FILTER
outputs:
output1: ${{ steps.fe-changes-info.outputs.fe }}
steps:
- uses: dorny/paths-filter@v2
id: changes
with:
filters: |
fe:
- 'fe/**'
- 'gensrc/**'
- 'run-fe-ut.sh'
- 'java-extensions/**'
- 'build.sh'
- run: echo ${{ steps.changes.outputs.fe }}
- name: FE CHECK INFO
id: fe-changes-info
run: |
echo "fe=${{ steps.changes.outputs.fe }}" >> $GITHUB_OUTPUT
fe-codestyle-check:
runs-on: ubuntu-latest
needs: fe-checker
if: needs.fe-checker.outputs.output1 == 'true'
name: FE Code Style Check
env:
PR_NUMBER: ${{ github.event.number }}
steps:
- name: clean
run: rm -rf ${{ github.workspace }}/*
- uses: dorny/paths-filter@v2
id: java-file
name: JAVA FILE
with:
filters: |
java:
- '**.java'
- run: echo ${{ steps.java-file.outputs.java }}
- name: BRANCH INFO
id: branch
run: |
echo ${{github.base_ref}}
echo "branch=${{github.base_ref}}" >> $GITHUB_OUTPUT
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Checkout PR
run: |
BRANCH=${{steps.branch.outputs.branch}}
git config --global user.name "wanpengfei-git";
git config --global user.email "[email protected]";
git checkout $BRANCH;
git pull;
BRANCH_NAME="${BRANCH}-${PR_NUMBER}";
git fetch origin pull/${PR_NUMBER}/head:${BRANCH_NAME};
git checkout $BRANCH_NAME;
git checkout -b merge_pr;
git merge --squash --no-edit ${BRANCH} || (echo "Merge conflict, please check." && exit -1);
- name: Copy checkstyle files
if: ${{ steps.java-file.outputs.java == 'true' }}
run: |
pwd
cp fe/checkstyle* .
- name: Run java checkstyle
if: ${{ steps.java-file.outputs.java == 'true' }}
uses: dbelyaev/[email protected]
with:
workdir: "./fe"
checkstyle_config: checkstyle.xml
reporter: 'github-pr-check'
github_token: ${{ secrets.GITHUB_TOKEN }}
fail_on_error: true
level: error
fe-ut:
runs-on: [self-hosted]
needs: fe-codestyle-check
name: FE UT
env:
PR_NUMBER: ${{ github.event.number }}
steps:
- name: clean
run: |
set -x
echo ${{ github.workspace }}
rm -rf ${{ github.workspace }}/*
- name: BRANCH INFO
id: branch
run: |
echo ${{github.base_ref}}
echo "branch=${{github.base_ref}}" >> $GITHUB_OUTPUT
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Checkout PR
run: |
BRANCH=${{steps.branch.outputs.branch}}
git checkout $BRANCH;
git pull;
BRANCH_NAME="${BRANCH}-${PR_NUMBER}";
git fetch origin pull/${PR_NUMBER}/head:${BRANCH_NAME};
git checkout $BRANCH_NAME;
git checkout -b merge_pr;
git merge --squash --no-edit ${BRANCH} || (echo "Merge conflict, please check." && exit -1);
- name: UPDATE ECI & RUN UT
id: run_ut
shell: bash
timeout-minutes: 60
run: |
set -ex
rm -rf ./elastic-service
ln -s /var/lib/elastic-service ./elastic-service
cd elastic-service && git pull
./bin/elastic-ut.sh --pr ${PR_NUMBER} --module fe --branch ${{steps.branch.outputs.branch}} --build Release
- name: Clean ECI
if: always()
run: |
echo ${{ steps.run_ut.outputs.ECI_ID }}
eci rm ${{ steps.run_ut.outputs.ECI_ID }}
- name: Prepare coverage files
run: |
cd ${{ github.workspace }}/fe/fe-core
cp -rf ${{ steps.run_ut.outputs.COV_DIR }} target/
- name: Coverage Report
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ${{ github.workspace }}/fe/fe-core/target/${{ steps.run_ut.outputs.COV_FILE }}
dry_run: false
name: fe-ut
fail_ci_if_error: false
verbose: true
- name: Incremental Coverage Report
run: |
set -ex
rm -rf ./coverchecker
ln -s /var/local/env/coverchecker ./coverchecker && cd coverchecker && git pull
time_count=0
pull_status=1
export JAVA_HOME=/var/local/env/jdk1.8.0_202;
export PATH=$JAVA_HOME/bin:$PATH;
while (( $pull_status != 0 )); do
if (( $time_count == 3 )); then
exit 1
fi
timeout 180 java -jar cover-checker-console/target/cover-checker-console-1.4.0-jar-with-dependencies.jar \
--cover ${{ github.workspace }}/fe/fe-core/target/result/ --github-token ${{ secrets.PAT }} \
--repo ${{ github.repository }} --threshold 80 --github-url api.github.com --pr ${PR_NUMBER} -type jacoco
pull_status=$?
time_count=`expr $time_count + 1`
done
- name: UT Report
if: always()
uses: mikepenz/action-junit-report@v3
with:
check_name: 'FE UT Report'
detailed_summary: true
token: ${{ secrets.GITHUB_TOKEN }}
report_paths: ${{ steps.run_ut.outputs.FE_REPORT_DIR }}/*.xml
- name: Upload log
if: always()
uses: actions/upload-artifact@v3
with:
name: FE UT LOG
path: ${{ steps.run_ut.outputs.RES_LOG }}
retention-days: 1
- name: Clean ENV
if: always()
run: |
rm -rf ${{ steps.run_ut.outputs.FE_REPORT_DIR }}
rm -f ${{ steps.run_ut.outputs.RES_FILE }}
rm -f ${{ steps.run_ut.outputs.RES_LOG }}
rm -rf ${{ steps.run_ut.outputs.COV_DIR }}
build:
runs-on: self-hosted
needs: [be-checker, fe-checker, be-ut, fe-ut, thirdparty-update]
name: BUILD
env:
PR_NUMBER: ${{ github.event.number }}
BRANCH: ${{ github.base_ref }}
outputs:
build_output_tar: ${{ steps.run_build.outputs.OUTPUT_TAR }}
if: always() && (needs.be-ut.result == 'success' && needs.fe-ut.result == 'success') || (needs.be-checker.outputs.output1 != 'true' && needs.fe-ut.result == 'success') || (needs.fe-checker.outputs.output1 != 'true' && needs.be-ut.result == 'success')
steps:
- name: Clean Workspace
uses: AutoModality/[email protected]
- name: BRANCH INFO
id: branch
run: |
echo ${{github.base_ref}}
echo "branch=${{github.base_ref}}" >> $GITHUB_OUTPUT
- name: UPDATE ECI & RUN BUILD
id: run_build
shell: bash
timeout-minutes: 90
run: |
rm -rf ./elastic-service
ln -s /var/lib/elastic-service ./elastic-service
cd elastic-service && git pull
if [[ "${{ needs.be-checker.outputs.output2 }}" == 'true' ]]; then
export image_cache_id=${{ needs.thirdparty-update.outputs.image_cache_id }}
export image_tag=$BRANCH-$PR_NUMBER
fi
./bin/elastic-build.sh --pr ${PR_NUMBER}
- name: build result
run: |
echo ${{ steps.run_build.outputs.OUTPUT_TAR }}
- name: clean ECI
if: always()
run: |
echo ${{ steps.run_build.outputs.ECI_ID }}
eci rm ${{ steps.run_build.outputs.ECI_ID }}
- name: Clean ENV
if: always()
run: |
rm -f ${{ steps.run_build.outputs.RES_FILE }}
rm -f ${{ steps.run_build.outputs.RES_LOG }}
deploy:
runs-on: self-hosted
if: always() && needs.build.result == 'success'
needs: build
name: DEPLOY SR
env:
PR_NUMBER: ${{ github.event.number }}
CLUSTER_NAME: ci-admit
outputs:
fe: ${{steps.deploy_sr.outputs.fe}}
be: ${{steps.deploy_sr.outputs.be}}
deploy_conf_file: ${{steps.apply_resource.outputs.deploy_conf_file}}
steps:
- name: Clean Workspace
uses: AutoModality/[email protected]
- name: BRANCH INFO
id: branch
run: |
echo ${{github.base_ref}}
echo "branch=${{github.base_ref}}" >> $GITHUB_OUTPUT
- name: Apply for resources
id: apply_resource
run: |
set -x
rm -rf ./elastic-service
cp -rf /var/lib/elastic-service ./elastic-service
cd elastic-service && git pull
./bin/elastic-cluster.sh --template ci-admit
cp conf/starrocks_deploy.conf /var/local/env/${PR_NUMBER}-starrocks_deploy.conf
echo "deploy_conf_file=/var/local/env/${PR_NUMBER}-starrocks_deploy.conf" >> $GITHUB_OUTPUT
- name: Deploy SR
id: deploy_sr
run: |
set -x
cd elastic-service
./bin/deploy-cluster.sh -c ${CLUSTER_NAME} --output oss://starrocks-ci-release/${{steps.branch.outputs.branch}}/Release/pr/${{needs.build.outputs.build_output_tar}}
- run: |
echo "FE: ${{steps.deploy_sr.outputs.fe}}, BE: ${{steps.deploy_sr.outputs.be}}"
admit:
runs-on: self-hosted
name: ADMIT TEST
needs: deploy
if: always() && needs.deploy.result == 'success'
timeout-minutes: 40
env:
PR_NUMBER: ${{ github.event.number }}
CLUSTER_NAME: ci-admit
FE_NODE: ${{ needs.deploy.outputs.fe }}
BE_NODE: ${{ needs.deploy.outputs.be }}
steps:
- name: Clean Workspace
uses: AutoModality/[email protected]
- name: Prepare Tools
run: |
cd ${{ github.workspace }}
rm -rf .actions
mkdir -p .actions/nose-report-action
cd .actions/nose-report-action
git clone https://github.com/StarRocks/action-junit-report.git .
- name: Run Case
run: |
set -x
echo "FE: ${{needs.deploy.outputs.fe}}, BE: ${{needs.deploy.outputs.be}}"
cd ${{ github.workspace }}
rm -rf ./elastic-service
ln -s /var/lib/elastic-service ./elastic-service
cd elastic-service && git pull
cd ${{ github.workspace }}
rm -rf ./StarRocksTest && cp -rf /var/lib/StarRocksTest ./StarRocksTest
cd ./StarRocksTest && git pull
cd ${{ github.workspace }}/elastic-service
./bin/run-admit.sh
- name: Publish Test Results
uses: ./.actions/nose-report-action
if: success() || failure()
with:
check_name: 'Admit Test Results'
fail_on_failure: true
detailed_summary: true
token: ${{ secrets.GITHUB_TOKEN }}
report_paths: 'StarRocksTest/result/*.xml'
SQL-Tester:
runs-on: self-hosted
name: SQL-Tester
needs: deploy
if: always() && needs.deploy.result == 'success'
timeout-minutes: 30
env:
PR_NUMBER: ${{ github.event.number }}
CLUSTER_NAME: ci-admit
FE_NODE: ${{ needs.deploy.outputs.fe }}
BE_NODE: ${{ needs.deploy.outputs.be }}
steps:
- name: Clean Workspace
uses: AutoModality/[email protected]
- name: Checkout Code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: BRANCH INFO
id: branch
run: |
echo ${{github.base_ref}}
echo "branch=${{github.base_ref}}" >> $GITHUB_OUTPUT
- name: Checkout PR
run: |
BRANCH=${{steps.branch.outputs.branch}}
git checkout $BRANCH;
git pull;
BRANCH_NAME="${BRANCH}-${PR_NUMBER}";
git fetch origin pull/${PR_NUMBER}/head:${BRANCH_NAME};
git checkout $BRANCH_NAME;
git checkout -b merge_pr;
git merge --squash --no-edit ${BRANCH} || (echo "Merge conflict, please check." && exit -1);
- name: Prepare Tools
run: |
cd ${{ github.workspace }}
rm -rf .actions
mkdir -p .actions/nose-report-action
cd .actions/nose-report-action
git clone https://github.com/StarRocks/action-junit-report.git .
- name: Run Case (${{ needs.deploy.outputs.fe }})
run: |
cd ${{ github.workspace }}
rm -rf ./elastic-service
ln -s /var/lib/elastic-service ./elastic-service
cd elastic-service && git pull
./bin/run-sql-tester.sh
- name: UT Reports
uses: ./.actions/nose-report-action
if: success() || failure()
with:
check_name: 'SQL-Tester Results'
fail_on_failure: true
detailed_summary: true
token: ${{ secrets.GITHUB_TOKEN }}
report_paths: 'test/*.xml'
Teardown:
runs-on: self-hosted
name: Teardown
needs: [ deploy, SQL-Tester, admit ]
if: always() && needs.deploy.outputs.deploy_conf_file != ''
env:
PR_NUMBER: ${{ github.event.number }}
BRANCH: ${{ github.base_ref }}
CONF_FILE: ${{ needs.deploy.outputs.deploy_conf_file }}
steps:
- name: Backup SR Info
run: |
rm -rf ./elastic-service
cp -rf /var/lib/elastic-service ./elastic-service
cd elastic-service && git pull
./bin/backup_log_cores.sh --branch $BRANCH --pr $PR_NUMBER --build Release --conf $CONF_FILE
- name: Clean ECS
run: |
cd elastic-service
./bin/elastic-cluster.sh --delete
- name: Clean TMP
run: |
rm -f $CONF_FILE