forked from apache/cloudberry
-
Notifications
You must be signed in to change notification settings - Fork 0
1700 lines (1461 loc) · 62.1 KB
/
build-cloudberry.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
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# --------------------------------------------------------------------
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to You under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of the
# License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied. See the License for the specific language governing
# permissions and limitations under the License.
#
# --------------------------------------------------------------------
# GitHub Actions Workflow: Apache Cloudberry Build Pipeline
# --------------------------------------------------------------------
# Description:
#
# This workflow builds, tests, and packages Apache Cloudberry on
# Rocky Linux 9. It ensures artifact integrity, performs installation
# tests, validates key operations, and provides detailed test reports,
# including handling for ignored test cases.
#
# Workflow Overview:
# 1. **Check Skip**:
# - Dynamically determines if the workflow should run based on CI skip flags.
# - Evaluates the following fields for skip flags:
# - **Pull Request Events**: PR title and PR body.
# - **Push Events**: Commit message of the head commit.
# - Supports the following skip patterns (case-insensitive):
# - `[skip ci]`
# - `[ci skip]`
# - `[no ci]`
# - **Example Usage**:
# - Add `[skip ci]` to a commit message, PR title, or body to skip the workflow.
#
# 2. **Build Job**:
# - Configures and builds Apache Cloudberry.
# - Supports debug build configuration via ENABLE_DEBUG flag.
# - Runs unit tests and verifies build artifacts.
# - Creates RPM packages (regular or debug), source tarballs, and logs.
# - **Key Artifacts**: RPM package, source tarball, build logs.
#
# 3. **RPM Install Test Job**:
# - Verifies RPM integrity and installs Cloudberry.
# - Validates successful installation.
# - **Key Artifacts**: Installation logs, verification results.
#
# 4. **Test Job (Matrix)**:
# - Executes a test matrix to validate different scenarios.
# - Creates a demo cluster and runs installcheck tests.
# - Parses and reports test results, including failed and ignored tests.
# - Detects and analyzes any core dumps generated during tests.
# - **Key Features**:
# - Regression diffs are displayed if found, aiding quick debugging.
# - Both failed and ignored test names are logged and reported.
# - Core dumps are analyzed using GDB for stack traces.
# - **Key Artifacts**: Test logs, regression files, test summaries, core analyses.
#
# 5. **Report Job**:
# - Aggregates job results into a final report.
# - Sends failure notifications if any step fails.
#
# Execution Environment:
# - **Runs On**: ubuntu-22.04 with Rocky Linux 9 containers.
# - **Resource Requirements**:
# - Disk: Minimum 20GB free space.
# - Memory: Minimum 8GB RAM.
# - CPU: Recommended 4+ cores.
#
# Triggers:
# - Push to `main` branch.
# - Pull requests to `main` branch.
# - Manual workflow dispatch.
#
# Container Images:
# - **Build**: `apache/incubator-cloudberry:cbdb-build-rocky9-latest`
# - **Test**: `apache/incubator-cloudberry:cbdb-test-rocky9-latest`
#
# Artifacts:
# - RPM Package (retention: ${{ env.LOG_RETENTION_DAYS }} days).
# - Source Tarball (retention: ${{ env.LOG_RETENTION_DAYS }} days).
# - Logs and Test Results (retention: ${{ env.LOG_RETENTION_DAYS }} days).
# - Regression Diffs (retention: ${{ env.LOG_RETENTION_DAYS }} days).
# - Core Dump Analyses (retention: ${{ env.LOG_RETENTION_DAYS }} days).
#
# Notes:
# - Supports concurrent job execution.
# - Includes robust skip logic for pull requests and pushes.
# - Handles ignored test cases, ensuring results are comprehensive.
# - Provides detailed logs and error handling for failed and ignored tests.
# - Analyzes core dumps generated during test execution.
# - Supports debug builds with preserved symbols.
# --------------------------------------------------------------------
name: Apache Cloudberry Build
on:
push:
branches: [main]
pull_request:
branches: [main]
types: [opened, synchronize, reopened, edited]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
# Note: Step details, logs, and artifacts require users to be logged into GitHub
# even for public repositories. This is a GitHub security feature and cannot
# be overridden by permissions.
permissions:
# READ permissions allow viewing repository contents
contents: read # Required for checking out code and reading repository files
# READ permissions for packages (Container registry, etc)
packages: read # Allows reading from GitHub package registry
# WRITE permissions for actions includes read access to:
# - Workflow runs
# - Artifacts (requires GitHub login)
# - Logs (requires GitHub login)
actions: write
# READ permissions for checks API:
# - Step details visibility (requires GitHub login)
# - Check run status and details
checks: read
# READ permissions for pull request metadata:
# - PR status
# - Associated checks
# - Review states
pull-requests: read
env:
LOG_RETENTION_DAYS: 7
ENABLE_DEBUG: false
jobs:
## ======================================================================
## Job: check-skip
## ======================================================================
check-skip:
runs-on: ubuntu-22.04
outputs:
should_skip: ${{ steps.skip-check.outputs.should_skip }}
steps:
- id: skip-check
shell: bash
env:
EVENT_NAME: ${{ github.event_name }}
PR_TITLE: ${{ github.event.pull_request.title || '' }}
PR_BODY: ${{ github.event.pull_request.body || '' }}
run: |
# Default to not skipping
echo "should_skip=false" >> "$GITHUB_OUTPUT"
# Apply skip logic only for pull_request events
if [[ "$EVENT_NAME" == "pull_request" ]]; then
# Combine PR title and body for skip check
MESSAGE="${PR_TITLE}\n${PR_BODY}"
# Escape special characters using printf %s
ESCAPED_MESSAGE=$(printf "%s" "$MESSAGE")
echo "Checking PR title and body (escaped): $ESCAPED_MESSAGE"
# Check for skip patterns
if echo -e "$ESCAPED_MESSAGE" | grep -qEi '\[skip[ -]ci\]|\[ci[ -]skip\]|\[no[ -]ci\]'; then
echo "should_skip=true" >> "$GITHUB_OUTPUT"
fi
else
echo "Skip logic is not applied for $EVENT_NAME events."
fi
- name: Report Skip Status
if: steps.skip-check.outputs.should_skip == 'true'
run: |
echo "CI Skip flag detected in PR - skipping all checks."
exit 0
## ======================================================================
## Job: build
## ======================================================================
build:
name: Build Apache Cloudberry
env:
JOB_TYPE: build
needs: check-skip
runs-on: ubuntu-22.04
timeout-minutes: 120
outputs:
build_timestamp: ${{ steps.set_timestamp.outputs.timestamp }}
container:
image: apache/incubator-cloudberry:cbdb-build-rocky9-latest
options: >-
--user root
-h cdw
steps:
- name: Skip Check
if: needs.check-skip.outputs.should_skip == 'true'
run: |
echo "Build skipped via CI skip flag" >> "$GITHUB_STEP_SUMMARY"
exit 0
- name: Set build timestamp
if: needs.check-skip.outputs.should_skip != 'true'
id: set_timestamp # Add an ID to reference this step
run: |
timestamp=$(date +'%Y%m%d_%H%M%S')
echo "timestamp=$timestamp" | tee -a "$GITHUB_OUTPUT" # Use GITHUB_OUTPUT for job outputs
echo "BUILD_TIMESTAMP=$timestamp" | tee -a "$GITHUB_ENV" # Also set as environment variable
- name: Checkout Apache Cloudberry
if: needs.check-skip.outputs.should_skip != 'true'
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Checkout CI Build/Test Scripts
if: needs.check-skip.outputs.should_skip != 'true'
uses: actions/checkout@v4
with:
repository: apache/cloudberry-devops-release
ref: main
path: cloudberry-devops-release
fetch-depth: 1
- name: Move cloudberry-devops-release directory
if: needs.check-skip.outputs.should_skip != 'true'
run: |
set -eo pipefail
if ! mv "${GITHUB_WORKSPACE}"/cloudberry-devops-release "${GITHUB_WORKSPACE}"/..; then
echo "::error::Container initialization failed"
exit 1
fi
- name: Cloudberry Environment Initialization
if: needs.check-skip.outputs.should_skip != 'true'
env:
LOGS_DIR: build-logs
run: |
set -eo pipefail
if ! su - gpadmin -c "/tmp/init_system.sh"; then
echo "::error::Container initialization failed"
exit 1
fi
mkdir -p "${LOGS_DIR}/details"
chown -R gpadmin:gpadmin .
chmod -R 755 .
chmod 777 "${LOGS_DIR}"
df -kh /
rm -rf /__t/*
df -kh /
df -h | tee -a "${LOGS_DIR}/details/disk-usage.log"
free -h | tee -a "${LOGS_DIR}/details/memory-usage.log"
{
echo "=== Environment Information ==="
uname -a
df -h
free -h
env
} | tee -a "${LOGS_DIR}/details/environment.log"
echo "SRC_DIR=${GITHUB_WORKSPACE}" | tee -a "$GITHUB_ENV"
- name: Generate Build Job Summary Start
if: needs.check-skip.outputs.should_skip != 'true'
run: |
{
echo "# Build Job Summary"
echo "## Environment"
echo "- Start Time: $(date -u +'%Y-%m-%d %H:%M:%S UTC')"
echo "- ENABLE_DEBUG: ${{ env.ENABLE_DEBUG }}"
echo "- OS Version: $(cat /etc/redhat-release)"
echo "- GCC Version: $(gcc --version | head -n1)"
} >> "$GITHUB_STEP_SUMMARY"
- name: Run Apache Cloudberry configure script
if: needs.check-skip.outputs.should_skip != 'true'
env:
SRC_DIR: ${{ github.workspace }}
run: |
set -eo pipefail
chmod +x "${SRC_DIR}"/../cloudberry-devops-release/build_automation/cloudberry/scripts/configure-cloudberry.sh
if ! time su - gpadmin -c "cd ${SRC_DIR} && SRC_DIR=${SRC_DIR} ENABLE_DEBUG=${{ env.ENABLE_DEBUG }} ${SRC_DIR}/../cloudberry-devops-release/build_automation/cloudberry/scripts/configure-cloudberry.sh"; then
echo "::error::Configure script failed"
exit 1
fi
- name: Run Apache Cloudberry build script
if: needs.check-skip.outputs.should_skip != 'true'
env:
SRC_DIR: ${{ github.workspace }}
run: |
set -eo pipefail
chmod +x "${SRC_DIR}"/../cloudberry-devops-release/build_automation/cloudberry/scripts/build-cloudberry.sh
if ! time su - gpadmin -c "cd ${SRC_DIR} && SRC_DIR=${SRC_DIR} ${SRC_DIR}/../cloudberry-devops-release/build_automation/cloudberry/scripts/build-cloudberry.sh"; then
echo "::error::Build script failed"
exit 1
fi
- name: Verify build artifacts
if: needs.check-skip.outputs.should_skip != 'true'
run: |
set -eo pipefail
echo "Verifying build artifacts..."
{
echo "=== Build Artifacts Verification ==="
echo "Timestamp: $(date -u)"
if [ ! -d "/usr/local/cloudberry-db" ]; then
echo "::error::Build artifacts directory not found"
exit 1
fi
# Verify critical binaries
critical_binaries=(
"/usr/local/cloudberry-db/bin/postgres"
"/usr/local/cloudberry-db/bin/psql"
)
echo "Checking critical binaries..."
for binary in "${critical_binaries[@]}"; do
if [ ! -f "$binary" ]; then
echo "::error::Critical binary missing: $binary"
exit 1
fi
if [ ! -x "$binary" ]; then
echo "::error::Binary not executable: $binary"
exit 1
fi
echo "Binary verified: $binary"
ls -l "$binary"
done
# Test binary execution
echo "Testing binary execution..."
if ! /usr/local/cloudberry-db/bin/postgres --version; then
echo "::error::postgres binary verification failed"
exit 1
fi
if ! /usr/local/cloudberry-db/bin/psql --version; then
echo "::error::psql binary verification failed"
exit 1
fi
echo "All build artifacts verified successfully"
} 2>&1 | tee -a build-logs/details/build-verification.log
- name: Create Source tarball, create RPM and verify artifacts
if: needs.check-skip.outputs.should_skip != 'true'
env:
CBDB_VERSION: 99.0.0
BUILD_NUMBER: 1
SRC_DIR: ${{ github.workspace }}
run: |
set -eo pipefail
{
echo "=== Artifact Creation Log ==="
echo "Timestamp: $(date -u)"
# Create source tarball
echo "Creating source tarball..."
tar czf "${SRC_DIR}"/../apache-cloudberry-incubating-src.tgz -C "${SRC_DIR}"/.. ./cloudberry
mv "${SRC_DIR}"/../apache-cloudberry-incubating-src.tgz "${SRC_DIR}"
# Verify tarball contents
echo "Verifying source tarball contents..."
if ! tar tzf "${SRC_DIR}"/apache-cloudberry-incubating-src.tgz > /dev/null; then
echo "::error::Source tarball verification failed"
exit 1
fi
# Create RPM
echo "Creating RPM package..."
rpmdev-setuptree
ln -s "${SRC_DIR}"/../cloudberry-devops-release/packaging/rpm/el/SPECS/apache-cloudberry-db-incubating.spec "${HOME}"/rpmbuild/SPECS/apache-cloudberry-db-incubating.spec
cp "${SRC_DIR}"/LICENSE /usr/local/cloudberry-db
DEBUG_RPMBUILD_OPT=""
DEBUG_IDENTIFIER=""
if [ "${{ env.ENABLE_DEBUG }}" = "true" ]; then
DEBUG_RPMBUILD_OPT="--with-debug"
DEBUG_IDENTIFIER=".debug"
fi
"${SRC_DIR}"/../cloudberry-devops-release/scripts/build-rpm.sh --version "${CBDB_VERSION}" --release "${BUILD_NUMBER}" "${DEBUG_RPMBUILD_OPT}"
# Get OS version and move RPM
os_version=$(grep -oP '(?<=^VERSION_ID=")[0-9]' /etc/os-release)
RPM_FILE="${HOME}"/rpmbuild/RPMS/x86_64/apache-cloudberry-db-incubating-"${CBDB_VERSION}"-"${BUILD_NUMBER}""${DEBUG_IDENTIFIER}".el"${os_version}".x86_64.rpm
cp "${RPM_FILE}" "${SRC_DIR}"
# Get package information
echo "Package Information:"
rpm -qip "${RPM_FILE}"
# Verify critical files in RPM
echo "Verifying critical files in RPM..."
for binary in "bin/postgres" "bin/psql"; do
if ! rpm -qlp "${RPM_FILE}" | grep -q "${binary}$"; then
echo "::error::Critical binary '${binary}' not found in RPM"
exit 1
fi
done
# Record checksums
echo "Calculating checksums..."
sha256sum "${RPM_FILE}" | tee -a build-logs/details/checksums.log
sha256sum "${SRC_DIR}"/apache-cloudberry-incubating-src.tgz | tee -a build-logs/details/checksums.log
echo "Artifacts created and verified successfully"
} 2>&1 | tee -a build-logs/details/artifact-creation.log
- name: Run Apache Cloudberry unittest script
if: needs.check-skip.outputs.should_skip != 'true'
env:
SRC_DIR: ${{ github.workspace }}
run: |
set -eo pipefail
chmod +x "${SRC_DIR}"/../cloudberry-devops-release/build_automation/cloudberry/scripts/unittest-cloudberry.sh
if ! time su - gpadmin -c "cd ${SRC_DIR} && SRC_DIR=${SRC_DIR} ${SRC_DIR}/../cloudberry-devops-release/build_automation/cloudberry/scripts/unittest-cloudberry.sh"; then
echo "::error::Unittest script failed"
exit 1
fi
- name: Generate Build Job Summary End
if: always()
run: |
{
echo "## Build Results"
echo "- End Time: $(date -u +'%Y-%m-%d %H:%M:%S UTC')"
} >> "$GITHUB_STEP_SUMMARY"
- name: Upload build logs
if: needs.check-skip.outputs.should_skip != 'true'
uses: actions/upload-artifact@v4
with:
name: build-logs-${{ env.BUILD_TIMESTAMP }}
path: |
build-logs/
retention-days: ${{ env.LOG_RETENTION_DAYS }}
- name: Upload Cloudberry RPM build artifacts
if: needs.check-skip.outputs.should_skip != 'true'
uses: actions/upload-artifact@v4
with:
name: apache-cloudberry-db-incubating-rpm-build-artifacts
retention-days: ${{ env.LOG_RETENTION_DAYS }}
if-no-files-found: error
path: |
*.rpm
- name: Upload Cloudberry source build artifacts
if: needs.check-skip.outputs.should_skip != 'true'
uses: actions/upload-artifact@v4
with:
name: apache-cloudberry-db-incubating-source-build-artifacts
retention-days: ${{ env.LOG_RETENTION_DAYS }}
if-no-files-found: error
path: |
apache-cloudberry-incubating-src.tgz
## ======================================================================
## Job: rpm-install-test
## ======================================================================
rpm-install-test:
name: RPM Install Test Apache Cloudberry
needs: [check-skip, build]
runs-on: ubuntu-22.04
timeout-minutes: 120
container:
image: apache/incubator-cloudberry:cbdb-test-rocky9-latest
options: >-
--user root
-h cdw
steps:
- name: Skip Check
if: needs.check-skip.outputs.should_skip == 'true'
run: |
echo "RPM install test skipped via CI skip flag" >> "$GITHUB_STEP_SUMMARY"
exit 0
- name: Download Cloudberry RPM build artifacts
if: needs.check-skip.outputs.should_skip != 'true'
uses: actions/download-artifact@v4
with:
name: apache-cloudberry-db-incubating-rpm-build-artifacts
path: ${{ github.workspace }}/rpm_build_artifacts
merge-multiple: false
- name: Cloudberry Environment Initialization
if: needs.check-skip.outputs.should_skip != 'true'
env:
LOGS_DIR: install-logs
run: |
set -eo pipefail
if ! su - gpadmin -c "/tmp/init_system.sh"; then
echo "::error::Container initialization failed"
exit 1
fi
mkdir -p "${LOGS_DIR}/details"
chown -R gpadmin:gpadmin .
chmod -R 755 .
chmod 777 "${LOGS_DIR}"
df -kh /
rm -rf /__t/*
df -kh /
df -h | tee -a "${LOGS_DIR}/details/disk-usage.log"
free -h | tee -a "${LOGS_DIR}/details/memory-usage.log"
{
echo "=== Environment Information ==="
uname -a
df -h
free -h
env
} | tee -a "${LOGS_DIR}/details/environment.log"
echo "SRC_DIR=${GITHUB_WORKSPACE}" | tee -a "$GITHUB_ENV"
- name: Verify RPM artifacts
if: needs.check-skip.outputs.should_skip != 'true'
id: verify-artifacts
run: |
set -eo pipefail
RPM_FILE=$(ls "${GITHUB_WORKSPACE}"/rpm_build_artifacts/apache-cloudberry-db-incubating*.rpm)
if [ ! -f "${RPM_FILE}" ]; then
echo "::error::RPM file not found"
exit 1
fi
echo "rpm_file=${RPM_FILE}" >> "$GITHUB_OUTPUT"
echo "Verifying RPM artifacts..."
{
echo "=== RPM Verification Summary ==="
echo "Timestamp: $(date -u)"
echo "RPM File: ${RPM_FILE}"
# Get RPM metadata and verify contents
echo "Package Information:"
rpm -qip "${RPM_FILE}"
# Get key RPM attributes for verification
RPM_VERSION=$(rpm -qp --queryformat "%{VERSION}" "${RPM_FILE}")
RPM_RELEASE=$(rpm -qp --queryformat "%{RELEASE}" "${RPM_FILE}")
echo "version=${RPM_VERSION}" >> "$GITHUB_OUTPUT"
echo "release=${RPM_RELEASE}" >> "$GITHUB_OUTPUT"
# Verify expected binaries are in the RPM
echo "Verifying critical files in RPM..."
for binary in "bin/postgres" "bin/psql"; do
if ! rpm -qlp "${RPM_FILE}" | grep -q "${binary}$"; then
echo "::error::Critical binary '${binary}' not found in RPM"
exit 1
fi
done
echo "RPM Details:"
echo "- Version: ${RPM_VERSION}"
echo "- Release: ${RPM_RELEASE}"
# Calculate and store checksum
echo "Checksum:"
sha256sum "${RPM_FILE}"
} 2>&1 | tee -a install-logs/details/rpm-verification.log
- name: Install Cloudberry RPM
if: success() && needs.check-skip.outputs.should_skip != 'true'
env:
RPM_FILE: ${{ steps.verify-artifacts.outputs.rpm_file }}
RPM_VERSION: ${{ steps.verify-artifacts.outputs.version }}
RPM_RELEASE: ${{ steps.verify-artifacts.outputs.release }}
run: |
set -eo pipefail
if [ -z "${RPM_FILE}" ]; then
echo "::error::RPM_FILE environment variable is not set"
exit 1
fi
{
echo "=== RPM Installation Log ==="
echo "Timestamp: $(date -u)"
echo "RPM File: ${RPM_FILE}"
echo "Version: ${RPM_VERSION}"
echo "Release: ${RPM_RELEASE}"
# Clean install location
rm -rf /usr/local/cloudberry-db
# Install RPM
echo "Starting installation..."
if ! time dnf install -y "${RPM_FILE}"; then
echo "::error::RPM installation failed"
exit 1
fi
echo "Installation completed successfully"
rpm -qi apache-cloudberry-db-incubating
echo "Installed files:"
rpm -ql apache-cloudberry-db-incubating
} 2>&1 | tee -a install-logs/details/rpm-installation.log
- name: Upload install logs
if: needs.check-skip.outputs.should_skip != 'true'
uses: actions/upload-artifact@v4
with:
name: install-logs-${{ needs.build.outputs.build_timestamp }}
path: |
install-logs/
retention-days: ${{ env.LOG_RETENTION_DAYS }}
- name: Generate Install Test Job Summary End
if: always()
shell: bash {0}
run: |
{
echo "# Installed Package Summary"
echo "\`\`\`"
rpm -qi apache-cloudberry-db-incubating
echo "\`\`\`"
} >> "$GITHUB_STEP_SUMMARY" || true
## ======================================================================
## Job: test
## ======================================================================
# WARNING: When adding new pg_settings key/value pairs:
# 1. Add the new setting with empty string ("") in all matrix entries
# 2. Update the "Run Tests" step to check and apply the new setting
# 3. Example: pg_settings.new_setting must be added to ALL matrix entries
test:
name: ${{ matrix.test }}
needs: [check-skip, build]
runs-on: ubuntu-22.04
timeout-minutes: 120
# actionlint-allow matrix[*].pg_settings
strategy:
fail-fast: false # Continue with other tests if one fails
matrix:
include:
- test: ic-good-opt-off
make_configs:
- src/test/regress:installcheck-good
num_primary_mirror_pairs: 3
enable_cgroups: false
enable_core_check: true
pg_settings:
optimizer: "off"
- test: ic-good-opt-on
make_configs:
- src/test/regress:installcheck-good
num_primary_mirror_pairs: 3
enable_cgroups: false
enable_core_check: true
pg_settings:
optimizer: "on"
- test: ic-expandshrink
make_configs:
- src/test/isolation2:installcheck-expandshrink
num_primary_mirror_pairs: 3
enable_cgroups: false
enable_core_check: true
pg_settings:
optimizer: ""
- test: ic-singlenode
make_configs:
- src/test/isolation:installcheck-singlenode
- src/test/singlenode_regress:installcheck-singlenode
- src/test/singlenode_isolation2:installcheck-singlenode
num_primary_mirror_pairs: 0
enable_cgroups: false
enable_core_check: true
pg_settings:
optimizer: ""
- test: ic-resgroup-v2
make_configs:
- src/test/isolation2:installcheck-resgroup-v2
num_primary_mirror_pairs: 3
enable_cgroups: true
enable_core_check: true
pg_settings:
optimizer: ""
- test: ic-contrib
make_configs:
- contrib/auto_explain:installcheck
- contrib/citext:installcheck
- contrib/btree_gin:installcheck
- contrib/file_fdw:installcheck
- contrib/formatter_fixedwidth:installcheck
- contrib/extprotocol:installcheck
- contrib/dblink:installcheck
- contrib/pg_trgm:installcheck
- contrib/indexscan:installcheck
- contrib/hstore:installcheck
- contrib/pgcrypto:installcheck
- contrib/tablefunc:installcheck
- contrib/passwordcheck:installcheck
- contrib/sslinfo:installcheck
num_primary_mirror_pairs: 3
enable_cgroups: false
enable_core_check: true
pg_settings:
optimizer: ""
- test: ic-gpcontrib
make_configs:
- gpcontrib/orafce:installcheck
- gpcontrib/pxf_fdw:installcheck
- gpcontrib/zstd:installcheck
- gpcontrib/gp_sparse_vector:installcheck
- gpcontrib/gp_toolkit:installcheck
num_primary_mirror_pairs: 3
enable_cgroups: false
enable_core_check: true
pg_settings:
optimizer: ""
- test: ic-fixme
make_configs:
- src/test/regress:installcheck-fixme
num_primary_mirror_pairs: 3
enable_cgroups: false
enable_core_check: false
pg_settings:
optimizer: ""
- test: ic-isolation2
make_configs:
- src/test/isolation2:installcheck-isolation2
num_primary_mirror_pairs: 3
enable_cgroups: true
enable_core_check: true
pg_settings:
optimizer: ""
- test: ic-isolation2-crash
make_configs:
- src/test/isolation2:installcheck-isolation2-crash
num_primary_mirror_pairs: 3
enable_cgroups: true
enable_core_check: false
pg_settings:
optimizer: ""
- test: ic-parallel-retrieve-cursor
make_configs:
- src/test/isolation2:installcheck-parallel-retrieve-cursor
num_primary_mirror_pairs: 3
enable_cgroups: true
enable_core_check: true
pg_settings:
optimizer: ""
container:
image: apache/incubator-cloudberry:cbdb-build-rocky9-latest
options: >-
--privileged
--user root
--hostname cdw
--shm-size=2gb
--ulimit core=-1
--cgroupns=host
-v /sys/fs/cgroup:/sys/fs/cgroup:rw
steps:
- name: Skip Check
if: needs.check-skip.outputs.should_skip == 'true'
run: |
echo "Test ${{ matrix.test }} skipped via CI skip flag" >> "$GITHUB_STEP_SUMMARY"
exit 0
- name: Use timestamp from previous job
if: needs.check-skip.outputs.should_skip != 'true'
run: |
echo "Timestamp from output: ${{ needs.build.outputs.build_timestamp }}"
- name: Checkout CI Build/Test Scripts
if: needs.check-skip.outputs.should_skip != 'true'
uses: actions/checkout@v4
with:
repository: apache/cloudberry-devops-release
ref: main
path: cloudberry-devops-release
fetch-depth: 1
- name: Move cloudberry-devops-release directory
if: needs.check-skip.outputs.should_skip != 'true'
run: |
set -eo pipefail
if ! mv "${GITHUB_WORKSPACE}"/cloudberry-devops-release "${GITHUB_WORKSPACE}"/..; then
echo "::error::Container initialization failed"
exit 1
fi
- name: Cloudberry Environment Initialization
env:
LOGS_DIR: build-logs
run: |
set -eo pipefail
if ! su - gpadmin -c "/tmp/init_system.sh"; then
echo "::error::Container initialization failed"
exit 1
fi
mkdir -p "${LOGS_DIR}/details"
chown -R gpadmin:gpadmin .
chmod -R 755 .
chmod 777 "${LOGS_DIR}"
df -kh /
rm -rf /__t/*
df -kh /
df -h | tee -a "${LOGS_DIR}/details/disk-usage.log"
free -h | tee -a "${LOGS_DIR}/details/memory-usage.log"
{
echo "=== Environment Information ==="
uname -a
df -h
free -h
env
} | tee -a "${LOGS_DIR}/details/environment.log"
echo "SRC_DIR=${GITHUB_WORKSPACE}" | tee -a "$GITHUB_ENV"
- name: Setup cgroups
if: needs.check-skip.outputs.should_skip != 'true'
shell: bash
run: |
set -uxo pipefail
if [ "${{ matrix.enable_cgroups }}" = "true" ]; then
echo "Current mounts:"
mount | grep cgroup
CGROUP_BASEDIR=/sys/fs/cgroup
# 1. Basic setup with permissions
sudo chmod -R 777 ${CGROUP_BASEDIR}/
sudo mkdir -p ${CGROUP_BASEDIR}/gpdb
sudo chmod -R 777 ${CGROUP_BASEDIR}/gpdb
sudo chown -R gpadmin:gpadmin ${CGROUP_BASEDIR}/gpdb
# 2. Enable controllers
sudo bash -c "echo '+cpu +cpuset +memory +io' > ${CGROUP_BASEDIR}/cgroup.subtree_control" || true
sudo bash -c "echo '+cpu +cpuset +memory +io' > ${CGROUP_BASEDIR}/gpdb/cgroup.subtree_control" || true
# 3. CPU settings
sudo bash -c "echo 'max 100000' > ${CGROUP_BASEDIR}/gpdb/cpu.max" || true
sudo bash -c "echo '100' > ${CGROUP_BASEDIR}/gpdb/cpu.weight" || true
sudo bash -c "echo '0' > ${CGROUP_BASEDIR}/gpdb/cpu.weight.nice" || true
sudo bash -c "echo 0-$(( $(nproc) - 1 )) > ${CGROUP_BASEDIR}/gpdb/cpuset.cpus" || true
sudo bash -c "echo '0' > ${CGROUP_BASEDIR}/gpdb/cpuset.mems" || true
# 4. Memory settings
sudo bash -c "echo 'max' > ${CGROUP_BASEDIR}/gpdb/memory.max" || true
sudo bash -c "echo '0' > ${CGROUP_BASEDIR}/gpdb/memory.min" || true
sudo bash -c "echo 'max' > ${CGROUP_BASEDIR}/gpdb/memory.high" || true
# 5. IO settings
echo "Available block devices:"
lsblk
sudo bash -c "
if [ -f \${CGROUP_BASEDIR}/gpdb/io.stat ]; then
echo 'Detected IO devices:'
cat \${CGROUP_BASEDIR}/gpdb/io.stat
fi
echo '' > \${CGROUP_BASEDIR}/gpdb/io.max || true
"
# 6. Fix permissions again after all writes
sudo chmod -R 777 ${CGROUP_BASEDIR}/gpdb
sudo chown -R gpadmin:gpadmin ${CGROUP_BASEDIR}/gpdb
# 7. Check required files
echo "Checking required files:"
required_files=(
"cgroup.procs"
"cpu.max"
"cpu.pressure"
"cpu.weight"
"cpu.weight.nice"
"cpu.stat"
"cpuset.cpus"
"cpuset.mems"
"cpuset.cpus.effective"
"cpuset.mems.effective"
"memory.current"
"io.max"
)
for file in "${required_files[@]}"; do
if [ -f "${CGROUP_BASEDIR}/gpdb/$file" ]; then
echo "✓ $file exists"
ls -l "${CGROUP_BASEDIR}/gpdb/$file"
else
echo "✗ $file missing"
fi
done
# 8. Test subdirectory creation
echo "Testing subdirectory creation..."
sudo -u gpadmin bash -c "
TEST_DIR=\${CGROUP_BASEDIR}/gpdb/test6448
if mkdir -p \$TEST_DIR; then
echo 'Created test directory'
sudo chmod -R 777 \$TEST_DIR
if echo \$\$ > \$TEST_DIR/cgroup.procs; then
echo 'Successfully wrote to cgroup.procs'
cat \$TEST_DIR/cgroup.procs
# Move processes back to parent before cleanup
echo \$\$ > \${CGROUP_BASEDIR}/gpdb/cgroup.procs
else
echo 'Failed to write to cgroup.procs'
ls -la \$TEST_DIR/cgroup.procs
fi
ls -la \$TEST_DIR/
rmdir \$TEST_DIR || {
echo 'Moving all processes to parent before cleanup'
cat \$TEST_DIR/cgroup.procs | while read pid; do
echo \$pid > \${CGROUP_BASEDIR}/gpdb/cgroup.procs 2>/dev/null || true
done
rmdir \$TEST_DIR
}
else
echo 'Failed to create test directory'
fi
"
# 9. Verify setup as gpadmin user
echo "Testing cgroup access as gpadmin..."
sudo -u gpadmin bash -c "
echo 'Checking mounts...'
mount | grep cgroup
echo 'Checking /proc/self/mounts...'
cat /proc/self/mounts | grep cgroup
if ! grep -q cgroup2 /proc/self/mounts; then
echo 'ERROR: cgroup2 mount NOT visible to gpadmin'
exit 1
fi
echo 'SUCCESS: cgroup2 mount visible to gpadmin'
if ! [ -w ${CGROUP_BASEDIR}/gpdb ]; then
echo 'ERROR: gpadmin cannot write to gpdb cgroup'
exit 1
fi
echo 'SUCCESS: gpadmin can write to gpdb cgroup'
echo 'Verifying key files content:'
echo 'cpu.max:'
cat ${CGROUP_BASEDIR}/gpdb/cpu.max || echo 'Failed to read cpu.max'
echo 'cpuset.cpus:'
cat ${CGROUP_BASEDIR}/gpdb/cpuset.cpus || echo 'Failed to read cpuset.cpus'