Skip to content

Add SonarQube for Apache Cloudberry#1004

Merged
tuhaihe merged 1 commit intoapache:mainfrom
tuhaihe:sonarqube
Apr 22, 2025
Merged

Add SonarQube for Apache Cloudberry#1004
tuhaihe merged 1 commit intoapache:mainfrom
tuhaihe:sonarqube

Conversation

@tuhaihe
Copy link
Copy Markdown
Member

@tuhaihe tuhaihe commented Mar 25, 2025

Fixes #ISSUE_Number

What does this PR do?

Type of Change

  • Bug fix (non-breaking change)
  • New feature (non-breaking change)
  • Breaking change (fix or feature with breaking changes)
  • Documentation update

Breaking Changes

Test Plan

  • Unit tests added/updated
  • Integration tests added/updated
  • Passed make installcheck
  • Passed make -C src/test installcheck-cbdb-parallel

Impact

Performance:

User-facing changes:

Dependencies:

Checklist

Additional Context

CI Skip Instructions


@tuhaihe tuhaihe changed the title [WIP] Add SonarQube for Apache Cloudberry Add SonarQube for Apache Cloudberry Mar 25, 2025
@tuhaihe
Copy link
Copy Markdown
Member Author

tuhaihe commented Mar 25, 2025

Now waiting for the ASF infra team to help create a new account at sonarcloud and enable the sonarcloud secrets for this repo.

Related issues:

@tuhaihe tuhaihe force-pushed the sonarqube branch 2 times, most recently from 8bbcdbe to b5289ac Compare March 28, 2025 10:03
@tuhaihe
Copy link
Copy Markdown
Member Author

tuhaihe commented Mar 28, 2025

Now waiting for the ASF infra team to help create a new account at sonarcloud and enable the sonarcloud secrets for this repo.

Related issues:

They have been set up.

I did one test in my own repo, it can run well before the getting token: https://github.com/tuhaihe/cloudberrydb/actions/runs/14056552786/job/39357194543. So, we can merge this PR to see if the workflow is running on the main branch.

@tuhaihe
Copy link
Copy Markdown
Member Author

tuhaihe commented Mar 28, 2025

Hi @chipitsine, could you help take a look at this PR? Thanks!

The following is the base configuration suggested from the sonarqube:

name: SonarQube
on:
  push:
    branches:
      - main
  pull_request:
    types: [opened, synchronize, reopened]
jobs:
  build:
    name: Build and analyze
    runs-on: ubuntu-latest
    env:
      BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0  # Shallow clones should be disabled for a better relevancy of analysis
      - name: Install Build Wrapper
        uses: SonarSource/sonarqube-scan-action/install-build-wrapper@v5
      - name: Run Build Wrapper
        run: |
          build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} <insert_your_clean_build_command>
      - name: SonarQube Scan
        uses: SonarSource/sonarqube-scan-action@v5
        env:
          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
        with:
          args: >
            --define sonar.cfamily.compile-commands="${{ env.BUILD_WRAPPER_OUT_DIR }}/compile_commands.json"

I customized the code for Cloudberry. FYI.

@chipitsine
Copy link
Copy Markdown
Contributor

I'll try native docker image (as it was done in coverity scan)

@tuhaihe
Copy link
Copy Markdown
Member Author

tuhaihe commented Apr 7, 2025

Hi @chipitsine Just bumping this to check the test progress. If any questions, feel free to let me know.

@chipitsine
Copy link
Copy Markdown
Contributor

well, I only had idea to test using the same docker build image.
hope to find time this week

@chipitsine
Copy link
Copy Markdown
Contributor

I did build by myself, I created pipeline from scratch and apparently I ended with very similar pipeline.
let's use it as starting point.

Sonar also suggests scanning on PRs, but current scan takes ~1.5 hours, I'm not sure we want that now._

@tuhaihe
Copy link
Copy Markdown
Member Author

tuhaihe commented Apr 7, 2025

I did build by myself, I created pipeline from scratch and apparently I ended with very similar pipeline.

let's use it as starting point.

Sonar also suggests scanning on PRs, but current scan takes ~1.5 hours, I'm not sure we want that now._

Thanks @chipitsine for your test. Yes, we can enable the testing only on the main branch weekly for now, otherwise it takes too much time.

@tuhaihe
Copy link
Copy Markdown
Member Author

tuhaihe commented Apr 9, 2025

@tuhaihe
Copy link
Copy Markdown
Member Author

tuhaihe commented Apr 15, 2025

Add PAX support in the latest commit fbf10cb, same to the PR #1050.

Comment thread .github/workflows/sonarqube.yml Outdated
Comment thread .github/workflows/sonarqube.yml
@tuhaihe
Copy link
Copy Markdown
Member Author

tuhaihe commented Apr 16, 2025

If we use git submodule update --init in the build steps, it will cause the following error:

fatal: detected dubious ownership in repository at '/__w/cloudberry/cloudberry'
To add an exception for this directory, call:

	git config --global --add safe.directory /__w/cloudberry/cloudberry
Error: Process completed with exit code 128.

So change the way of loading the submodules with submodules: true.

@tuhaihe
Copy link
Copy Markdown
Member Author

tuhaihe commented Apr 17, 2025

@tuhaihe tuhaihe force-pushed the sonarqube branch 2 times, most recently from b11dbda to 0f0bd28 Compare April 22, 2025 06:51
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.
Copy link
Copy Markdown
Contributor

@jiaqizho jiaqizho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tuhaihe tuhaihe merged commit 112667c into apache:main Apr 22, 2025
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants