Skip to content

Commit 95e0f2a

Browse files
committed
Add SonarQube for Apache Cloudberry
1 parent 94af1a2 commit 95e0f2a

3 files changed

Lines changed: 133 additions & 2 deletions

File tree

.github/workflows/coverity.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ name: Apache Cloudberry Coverity Scan
4040

4141
on:
4242
schedule:
43-
- cron: "0 0 * * *"
43+
- cron: "0 0 * * 1"
4444
workflow_dispatch:
4545

4646
permissions:
@@ -122,4 +122,4 @@ jobs:
122122
--form file=@cov.tar.gz \
123123
--form version="Commit $GITHUB_SHA" \
124124
--form description="Build submitted via CI" \
125-
https://scan.coverity.com/builds?project=apache%2Fcloudberry
125+
https://scan.coverity.com/builds?project=apache%2Fcloudberry
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
sonar.projectKey=apache-cloudberry
2+
sonar.organization=apache
3+
4+
# This is the name and version displayed in the SonarCloud UI.
5+
sonar.projectName=Apache Cloudberry
6+
sonar.projectVersion=main
7+
8+
# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
9+
sonar.sources=../..
10+
11+
# Encoding of the source code. Default is default system encoding
12+
#sonar.sourceEncoding=UTF-8

.github/workflows/sonarqube.yml

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
# --------------------------------------------------------------------
2+
#
3+
# Licensed to the Apache Software Foundation (ASF) under one or more
4+
# contributor license agreements. See the NOTICE file distributed
5+
# with this work for additional information regarding copyright
6+
# ownership. The ASF licenses this file to You under the Apache
7+
# License, Version 2.0 (the "License"); you may not use this file
8+
# except in compliance with the License. You may obtain a copy of the
9+
# License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
16+
# implied. See the License for the specific language governing
17+
# permissions and limitations under the License.
18+
#
19+
# --------------------------------------------------------------------
20+
# GitHub Actions Workflow: Apache Cloudberry SonarQube Pipeline
21+
# --------------------------------------------------------------------
22+
# Description:
23+
#
24+
# This workflow performs scheduled SonarQube analysis for Cloudberry.
25+
#
26+
# Workflow Overview:
27+
# 1. **Check Skip**:
28+
# - workflow run currently is limited to "apache" GitHub organization
29+
#
30+
# 2. **scan Job**:
31+
# - performs scan and upload result to https://sonarcloud.io/project/overview?id=apache_cloudberry
32+
# Triggers:
33+
# - Weekly schedule
34+
# - optional manual dispatch.
35+
#
36+
# Notes:
37+
# - SONARCLOUD_TOKEN secret is provided by the ASF Infra team
38+
# --------------------------------------------------------------------
39+
name: Apache Cloudberry SonarQube Cloud Analysis
40+
41+
on:
42+
schedule:
43+
- cron: "0 0 * * 1"
44+
workflow_dispatch:
45+
46+
permissions:
47+
contents: read
48+
49+
jobs:
50+
sonarqube-analysis:
51+
runs-on: ubuntu-22.04
52+
if: ${{ github.repository_owner == 'apache' }}
53+
54+
container:
55+
image: apache/incubator-cloudberry:cbdb-build-rocky9-latest
56+
options: >-
57+
--user root
58+
-h cdw
59+
60+
steps:
61+
- name: Checkout Apache Cloudberry
62+
uses: actions/checkout@v4
63+
with:
64+
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
65+
env:
66+
BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory
67+
68+
- name: Environment Initialization
69+
run: |
70+
if ! su - gpadmin -c "/tmp/init_system.sh"; then
71+
echo "::error::Container initialization failed"
72+
exit 1
73+
fi
74+
75+
- name: Install Build Wrapper
76+
uses: SonarSource/sonarqube-scan-action/install-build-wrapper@v5
77+
78+
- name: Run Build Wrapper
79+
run: |
80+
sudo rm -rf /usr/local/cloudberry-db
81+
sudo chmod a+w /usr/local
82+
mkdir -p /usr/local/cloudberry-db/lib
83+
sudo cp /usr/local/xerces-c/lib/libxerces-c.so \
84+
/usr/local/xerces-c/lib/libxerces-c-3.3.so \
85+
/usr/local/cloudberry-db/lib
86+
sudo chown -R gpadmin:gpadmin /usr/local/cloudberry-db
87+
su - gpadmin -c "cd $WORKSPACE"
88+
export LD_LIBRARY_PATH=/usr/local/cloudberry-db/lib:LD_LIBRARY_PATH
89+
./configure --prefix=/usr/local/cloudberry-db \
90+
--disable-external-fts \
91+
--enable-gpcloud \
92+
--enable-ic-proxy \
93+
--enable-orafce \
94+
--enable-orca \
95+
--enable-pxf \
96+
--enable-tap-tests \
97+
--with-gssapi \
98+
--with-ldap \
99+
--with-libxml \
100+
--with-lz4 \
101+
--with-openssl \
102+
--with-pam \
103+
--with-perl \
104+
--with-pgport=5432 \
105+
--with-python \
106+
--with-pythonsrc-ext \
107+
--with-ssl=openssl \
108+
--with-uuid=e2fs \
109+
--with-includes=/usr/local/xerces-c/include \
110+
--with-libraries=/usr/local/cloudberry-db/lib
111+
build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} make -j$(nproc)
112+
113+
- name: SonarQube Scan
114+
uses: SonarSource/sonarqube-scan-action@v5
115+
env:
116+
SONARCLOUD_TOKEN: ${{ secrets.SONARCLOUD_TOKEN }}
117+
with:
118+
args: >
119+
--define sonar.cfamily.compile-commands="${{ env.BUILD_WRAPPER_OUT_DIR }}/compile_commands.json"

0 commit comments

Comments
 (0)