diff --git a/.github/workflows/sonarcube.yml b/.github/workflows/sonarcube.yml new file mode 100644 index 000000000..29d83fb4a --- /dev/null +++ b/.github/workflows/sonarcube.yml @@ -0,0 +1,40 @@ +name: Sonarcube Scan +on: + push: + branches: + - master + 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: Install Dependencies + run: | + sudo apt-get update + sudo apt-get install -y libzmq3-dev libsqlite3-dev + + - name: Install googletest + uses: Bacondish2023/setup-googletest@v1 + + - 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) 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