From d5de26eb07eafc8714d080ac1a612eccc49d3f55 Mon Sep 17 00:00:00 2001 From: Andrew Shkrob Date: Mon, 28 Aug 2023 23:58:55 +0200 Subject: [PATCH] [ci] configure sonar cloud Signed-off-by: Andrew Shkrob --- .github/workflows/sonar_cloud.yaml | 70 ++++++++++++++++++++++++++++++ sonar-project.properties | 13 ++++++ 2 files changed, 83 insertions(+) create mode 100644 .github/workflows/sonar_cloud.yaml create mode 100644 sonar-project.properties diff --git a/.github/workflows/sonar_cloud.yaml b/.github/workflows/sonar_cloud.yaml new file mode 100644 index 0000000000000..049bafde262d4 --- /dev/null +++ b/.github/workflows/sonar_cloud.yaml @@ -0,0 +1,70 @@ +name: SonarCloud +on: + push: + branches: + - master + pull_request: + types: [opened, synchronize, reopened] +jobs: + build: + name: Build and analyze + runs-on: ubuntu-22.04 + env: + BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed + steps: + - name: Free disk space by removing .NET, Android and Haskell + shell: bash + run: | + sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc + + - name: Checkout sources + uses: actions/checkout@v3 + with: + fetch-depth: 100 # enough to get all commits for the current day + + - name: Parallel submodules checkout + shell: bash + run: git submodule update --depth 1 --init --recursive --jobs=$(($(nproc) * 20)) + + - name: Install sonar-scanner and build-wrapper + uses: SonarSource/sonarcloud-github-c-cpp@v2 + + - name: Install build tools and dependencies + shell: bash + run: | + sudo apt update -y + sudo apt install -y \ + ninja-build \ + libgl1-mesa-dev \ + libglvnd-dev \ + qt6-base-dev \ + libqt6svg6-dev + + - name: Configure + shell: bash + run: ./configure.sh + + - name: Configure ccache + uses: hendrikmuhs/ccache-action@v1.2 + + - name: CMake + shell: bash + env: + CC: clang-14 + CXX: clang++-14 + CMAKE_C_COMPILER_LAUNCHER: ccache + CMAKE_CXX_COMPILER_LAUNCHER: ccache + # -g1 should slightly reduce build time. + run: | + cmake . -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS=-g1 -DCMAKE_CXX_FLAGS=-g1 + + - name: Run build-wrapper + run: | + build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} ninja -C build/ + + - name: Run sonar-scanner + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + run: | + sonar-scanner --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 0000000000000..a405ed9e8cbb2 --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,13 @@ +sonar.projectKey=AndrewShkrob_organicmaps +sonar.organization=andrei-shkrob + +# This is the name and version displayed in the SonarCloud UI. +sonar.projectName=organicmaps +sonar.projectVersion=1.0 + + +sonar.sources=base/,coding/,cppjansson/,descriptions/,drape/,drape_frontend/,editor/,feature_list/,ge0/,generator/,geometry/,indexer/,kml/,map/,mapshot/,openlr/,platform/,poly_borders/,qt/,qt_tstfrm/,routing/,routing_common/,search/,shaders/,skin_generator/,software_renderer/,std/,storage/,topography_generator/,track_analyzing/,track_generator/,tracking/,traffic/,transit/ +sonar.exclusions=3party/**,android/**,cmake/**,data/**,docs/**,iphone/**,packaging/**,pyhelpers/**,testing/**,xcode/** + +# Encoding of the source code. Default is default system encoding +#sonar.sourceEncoding=UTF-8 \ No newline at end of file