Skip to content

Commit 3fb0a66

Browse files
committed
Add SonarQube for Apache Cloudberry
This PR introduces the SonarQube for Apache Cloudberry as a code quality and security tool, which is similar to the Coverity. We also use the Cloudberry docker image as the running base env.
1 parent 85f2065 commit 3fb0a66

4 files changed

Lines changed: 135 additions & 3 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

.github/workflows/sonarqube.yml

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
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+
env:
60+
BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed
61+
62+
steps:
63+
- name: Checkout Apache Cloudberry
64+
uses: actions/checkout@v4
65+
with:
66+
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
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+
export LD_LIBRARY_PATH=/usr/local/cloudberry-db/lib:LD_LIBRARY_PATH
88+
./configure --prefix=/usr/local/cloudberry-db \
89+
--disable-external-fts \
90+
--enable-gpcloud \
91+
--enable-ic-proxy \
92+
--enable-orafce \
93+
--enable-orca \
94+
--enable-pxf \
95+
--enable-tap-tests \
96+
--with-gssapi \
97+
--with-ldap \
98+
--with-libxml \
99+
--with-lz4 \
100+
--with-openssl \
101+
--with-pam \
102+
--with-perl \
103+
--with-pgport=5432 \
104+
--with-python \
105+
--with-pythonsrc-ext \
106+
--with-ssl=openssl \
107+
--with-uuid=e2fs \
108+
--with-includes=/usr/local/xerces-c/include \
109+
--with-libraries=/usr/local/cloudberry-db/lib
110+
build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} make -j$(nproc)
111+
112+
- name: SonarQube Scan
113+
uses: SonarSource/sonarqube-scan-action@v5
114+
env:
115+
SONARCLOUD_TOKEN: ${{ secrets.SONARCLOUD_TOKEN }}
116+
with:
117+
args: >
118+
--define sonar.cfamily.compile-commands="${{ env.BUILD_WRAPPER_OUT_DIR }}/compile_commands.json"

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@
2323
<img alt="Coverity Scan Build Status"
2424
src="https://scan.coverity.com/projects/31473/badge.svg"/>
2525
</a>
26-
26+
<a href="https://sonarcloud.io/summary/new_code?id=apache_cloudberry">
27+
<img alt="SonarQube Cloud" src="https://sonarcloud.io/images/project_badges/sonarcloud-highlight.svg" width="100px">
28+
</a>
2729
---------
2830

2931
## Introduction

sonar-project.properties

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

0 commit comments

Comments
 (0)