Skip to content

playing with sonar on tests #2

playing with sonar on tests

playing with sonar on tests #2

Workflow file for this run

name: Sonar analysis
on:
push:
branches: [ master, '*-ci' ]
pull_request:
branches: [ master ]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- run: |
echo "Demo build"
sonar-build:
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # shallow clones should be disabled for a better relevancy of analysis
submodules: recursive
- name: Install sonar-scanner and build-wrapper
uses: SonarSource/sonarcloud-github-c-cpp@v2
- name: Set up Java 8
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 8
- name: Install dependencies
run: sudo apt-get install cmake doxygen graphviz
- name: Build zserio # TODO: download zserio compiler artifact?
env:
CMAKE_EXTRA_ARGS: "-DCMAKE_BUILD_TYPE=Release"
CMAKE_BUILD_OPTIONS: "-j4"
run: |
scripts/build.sh core cpp zserio cpp_rt-linux64-gcc && scripts/release.sh
- name: Run tests under build_wrapper
env:
CMAKE_EXTRA_ARGS: "-DCMAKE_BUILD_TYPE=Release"
CMAKE_BUILD_OPTIONS: "-j4"
run: |
build-wrapper-linux-x86-64 --out-dir build-wrapper-tests scripts/test.sh cpp-linux64-gcc
- name: Upload build-wrapper output
uses: actions/upload-artifact@v3
with:
name: "build-wrapper-tests"
path: "build-wrapper-tests"
- name: Run sonar-scanner
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
sonar-scanner --define sonar.cfamily.build-wrapper-output="build-wrapper-tests" \
--define sonar.projectKey="ndsev_zserio" \
--define sonar.organization="ndsev" \
--define sonar.sourceEncoding="UTF-8" \
--define sonar.sources="compiler/extensions/cpp/runtime/src,build/test/cpp/linux64-gcc/release" \
--define sonar.tests="test" \
--define sonar.inclusions="**/*.h,**/*.cpp" \
--define sonar.exclusions="**/CMakeFiles/**/*" \
--define sonar.scm.exclusions.disabled="true" \
--define sonar.cfamily.analysisCache.mode="fs" \
--define sonar.cfamily.analysisCache.path="sonar-cache"