Skip to content

Various Sonar Cleanup #888

Various Sonar Cleanup

Various Sonar Cleanup #888

Workflow file for this run

name: Build
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
env:
BUILD_TYPE: Debug
jobs:
build_test_analyze:
name: Ubuntu Build, Test and Analyze
runs-on: ubuntu-latest
env:
BUILD_WRAPPER_OUT_DIR: build-wrapper-output
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up Python 3.8 for gcovr
uses: actions/setup-python@v5
with:
python-version: 3.8
cache: "pip"
- name: install gcovr 5.0
run: |
pip install gcovr==5.0 # 5.1 is not supported
- name: Install sonar-scanner and build-wrapper
uses: SonarSource/sonarcloud-github-c-cpp@v2
- name: Run build-wrapper
run: |
mkdir build
cmake -S . -B build -DBUILD_EXAMPLES=ON -DBUILD_TESTING=ON -DCAN_DRIVER=SocketCAN -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }}
build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} cmake --build build/ --config ${{ env.BUILD_TYPE }}
- name: Run
working-directory: ${{github.workspace}}/build
run: ctest -C ${{ env.BUILD_TYPE }} --rerun-failed --output-on-failure
- name: Collect coverage into one XML report
run: |
gcovr --sonarqube --exclude-throw-branches > coverage.xml
- name: Run sonar-scanner
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
if: "${{ env.SONAR_TOKEN != '' }}"
run: |
sonar-scanner \
--define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}" \
--define sonar.coverageReportPaths=coverage.xml
windows_build:
name: Windows Build, Test
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }} # Check out the code of the PR head
- name: Compile
run: |
mkdir build
cmake -S . -B build -DBUILD_EXAMPLES=ON -DBUILD_TESTING=ON -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }}
cmake --build build --config ${{ env.BUILD_TYPE }}
- name: Test
run: |
cd build
ctest -C ${{ env.BUILD_TYPE }} --rerun-failed --output-on-failure
mac_os_build:
name: Mac OS Build, Test
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }} # Check out the code of the PR head
- name: Compile
run: |
mkdir build
cmake -S . -B build -DBUILD_EXAMPLES=ON -DBUILD_TESTING=ON -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }}
cmake --build build --config ${{ env.BUILD_TYPE }}
- name: Test
run: |
cd build
ctest -C ${{ env.BUILD_TYPE }} --rerun-failed --output-on-failure