From 32f85dd3d5963526d9cd708a751f14a616615162 Mon Sep 17 00:00:00 2001 From: Davide Faconti Date: Tue, 18 Feb 2025 14:08:47 +0100 Subject: [PATCH 1/5] add workflow for sonarcube --- .github/workflows/sonarcube.yml | 31 +++++++++++++++++++++++++++++++ CMakeLists.txt | 3 +++ 2 files changed, 34 insertions(+) create mode 100644 .github/workflows/sonarcube.yml diff --git a/.github/workflows/sonarcube.yml b/.github/workflows/sonarcube.yml new file mode 100644 index 000000000..c3e3d08cf --- /dev/null +++ b/.github/workflows/sonarcube.yml @@ -0,0 +1,31 @@ +name: Build +on: + push: + branches: + - main + pull_request: + types: [opened, synchronize, reopened] +jobs: + build: + name: Build + 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@v4 + - name: Run Build Wrapper + run: | + mkdir build + cmake -S . -B build + build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} cmake --build build/ --config Release + - name: SonarQube Scan + uses: SonarSource/sonarqube-scan-action@v4 + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} # Put the name of your token here + with: + args: > + --define sonar.cfamily.compile-commands="${{ env.BUILD_WRAPPER_OUT_DIR }}/compile_commands.json" diff --git a/CMakeLists.txt b/CMakeLists.txt index 722e102b7..54451c6a9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,6 +22,9 @@ else() add_definitions(-Wpedantic -fno-omit-frame-pointer) endif() +# create compile_commands.json +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + #---- project configuration ---- option(BTCPP_SHARED_LIBS "Build shared libraries" ON) From ecb086ea3a7b1604e13c37c8349eca94d21b2d30 Mon Sep 17 00:00:00 2001 From: Davide Faconti Date: Tue, 18 Feb 2025 14:10:36 +0100 Subject: [PATCH 2/5] add sonar-project file --- sonar-project.properties | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 sonar-project.properties diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 000000000..6e0eb2293 --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,13 @@ +sonar.projectKey=BehaviorTree_BehaviorTree.CPP +sonar.organization=behaviortree + +# This is the name and version displayed in the SonarCloud UI. +#sonar.projectName=BehaviorTree.CPP +#sonar.projectVersion=1.0 + + +# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. +#sonar.sources=. + +# Encoding of the source code. Default is default system encoding +#sonar.sourceEncoding=UTF-8 From a03c8932ca360af33e7972c4e542f725b3cee5a6 Mon Sep 17 00:00:00 2001 From: Davide Faconti Date: Tue, 18 Feb 2025 14:15:10 +0100 Subject: [PATCH 3/5] fix --- .github/workflows/sonarcube.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/sonarcube.yml b/.github/workflows/sonarcube.yml index c3e3d08cf..cb73cf9f0 100644 --- a/.github/workflows/sonarcube.yml +++ b/.github/workflows/sonarcube.yml @@ -17,10 +17,16 @@ jobs: 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@v4 + + - name: Install Dependencies + run: | + sudo apt-get update + sudo apt-get install -y libzmq3-dev libsqlite3-dev + - name: Run Build Wrapper run: | mkdir build - cmake -S . -B build + cmake -S . -B build -DBTCPP_UNIT_TESTS=OFF build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} cmake --build build/ --config Release - name: SonarQube Scan uses: SonarSource/sonarqube-scan-action@v4 From 14fb183a59aa505d794b1355689dd47cc855069c Mon Sep 17 00:00:00 2001 From: Davide Faconti Date: Tue, 18 Feb 2025 14:30:07 +0100 Subject: [PATCH 4/5] add unit tests --- .github/workflows/sonarcube.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/sonarcube.yml b/.github/workflows/sonarcube.yml index cb73cf9f0..b729aaa1b 100644 --- a/.github/workflows/sonarcube.yml +++ b/.github/workflows/sonarcube.yml @@ -1,8 +1,8 @@ -name: Build +name: Sonarcube Scan on: push: branches: - - main + - master pull_request: types: [opened, synchronize, reopened] jobs: @@ -23,10 +23,15 @@ jobs: sudo apt-get update sudo apt-get install -y libzmq3-dev libsqlite3-dev + - name: Install googletest + uses: Bacondish2023/setup-googletest@v1 + with: + tag: 'release-1.14.0' + - name: Run Build Wrapper run: | mkdir build - cmake -S . -B build -DBTCPP_UNIT_TESTS=OFF + cmake -S . -B build build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} cmake --build build/ --config Release - name: SonarQube Scan uses: SonarSource/sonarqube-scan-action@v4 From 4123231591920bee9e0a58eb12dae731d9a56fa6 Mon Sep 17 00:00:00 2001 From: Davide Faconti Date: Tue, 18 Feb 2025 14:33:47 +0100 Subject: [PATCH 5/5] try fix --- .github/workflows/sonarcube.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/sonarcube.yml b/.github/workflows/sonarcube.yml index b729aaa1b..29d83fb4a 100644 --- a/.github/workflows/sonarcube.yml +++ b/.github/workflows/sonarcube.yml @@ -25,8 +25,6 @@ jobs: - name: Install googletest uses: Bacondish2023/setup-googletest@v1 - with: - tag: 'release-1.14.0' - name: Run Build Wrapper run: |