From 04bb5ee3e8721566b2080aebcf7a27ce7c42074a Mon Sep 17 00:00:00 2001 From: Axel Menzel Date: Wed, 11 Aug 2021 01:14:16 +0200 Subject: [PATCH] code-quality: add sonar source analysis --- .github/workflows/static_code_analysis.yml | 35 ++++++++++++++++++++++ sonar-project.properties | 13 ++++++++ 2 files changed, 48 insertions(+) create mode 100644 .github/workflows/static_code_analysis.yml create mode 100644 sonar-project.properties diff --git a/.github/workflows/static_code_analysis.yml b/.github/workflows/static_code_analysis.yml new file mode 100644 index 00000000..2d166a24 --- /dev/null +++ b/.github/workflows/static_code_analysis.yml @@ -0,0 +1,35 @@ +name: Code Quality + +on: + push: + branches: + - master + pull_request: + types: [opened, synchronize, reopened] + +env: + # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) + BUILD_TYPE: Release + SONAR_SERVER_URL: "https://sonarcloud.io" + BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed + +jobs: + analyze_with_sonar_source: + if: github.repository == 'rttrorg/rttr' + runs-on: ubuntu-latest + container: rttr/docker-ci:latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + - name: Configure CMake + run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_EXAMPLES=OFF -G Ninja + - name: Run build-wrapper + run: | + build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} cmake --build ${{github.workspace}}/build + - name: Run sonar-scanner + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + run: | + sonar-scanner --debug --define sonar.host.url="${{ env.SONAR_SERVER_URL }}" --define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}" diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 00000000..9df60774 --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,13 @@ +sonar.projectKey=rttrorg_rttr +sonar.organization=rttrorg + +# This is the name and version displayed in the SonarCloud UI. +sonar.projectName=rttr +sonar.projectVersion=0.9.7 + +# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. +sonar.sources=src +sonar.exclusions=src/benchmarks/**, src/unit_tests/**, src/examples/** + +# Encoding of the source code. Default is default system encoding +sonar.sourceEncoding=UTF-8