From df1d62158e000436598b46bc9240ac0919772698 Mon Sep 17 00:00:00 2001 From: Matt Woodward Date: Tue, 14 Nov 2023 20:45:24 +1100 Subject: [PATCH] Add stage for C/C++ sonar analysis --- .github/workflows/sonarcloud.yml | 37 ++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index b05cb8447d..bfd66fc608 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -26,3 +26,40 @@ jobs: -Dsonar.exclusions=java/** -Dsonar.verbose=true -Dsonar.c.file.suffixes=- -Dsonar.cpp.file.suffixes=- + + C: + name: C Code Coverage + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v2 + with: + submodules: recursive + fetch-depth: 0 + - name: Install sonar-scanner and build-wrapper + uses: SonarSource/sonarcloud-github-c-cpp@v2 + - name: Setup + run: | + sudo apt-get install llvm -y + - name: Build and Run Tests + env: + CC: clang + CXX: clang++ + run: | + cmake -S c -B build -DCODE_COVERAGE=ON -DCMAKE_C_FLAGS=--coverage -DCMAKE_CXX_FLAGS=--coverage && + build-wrapper-linux-x86-64 --out-dir ./bw-output cmake --build build -j4 --target ccov-all-export + - name: Run sonar-scanner + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN_C }} + run: sonar-scanner + -X + -Dsonar.organization=swift-nav + -Dsonar.projectName=libsbp-c + -Dsonar.projectKey=swift-nav_libsbp_c + -Dsonar.verbose=true + -Dsonar.login=${{ secrets.SONAR_TOKEN_C }} + -Dsonar.cfamily.threads=4 + -Dsonar.cfamily.llvm-cov.reportPath=./build/ccov/coverage.txt + -Dsonar.sources=c/src/,c/include/ + -Dsonar.tests=c/test/ + -Dsonar.cfamily.build-wrapper-output=./bw-output