Skip to content

Merge pull request #42 from sir-gon/develop #156

Merge pull request #42 from sir-gon/develop

Merge pull request #42 from sir-gon/develop #156

Workflow file for this run

---
name: SonarCloud
on: # yamllint disable-line rule:truthy
push:
branches: ["main"]
pull_request:
types: [opened, synchronize, reopened]
workflow_dispatch:
jobs:
build:
name: SonarCloud build and run sonar-scanner
runs-on: ubuntu-24.04
env:
# Directory where build-wrapper output will be placed
BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory
steps:
- uses: actions/checkout@v4
with:
# Shallow clones should be disabled for a better relevancy of analysis
fetch-depth: 0
- name: Install Tools
run: |
sudo rm /usr/lib/python3.*/EXTERNALLY-MANAGED
sudo apt-get install lcov
pip install gcovr
- name: Check Tools
run: |
make --version
cmake --version
vcpkg --version
lcov --version
gcovr --version
- name: Install dependencies
run: |
make dependencies
- name: Install sonar-scanner and build-wrapper
uses: sonarsource/sonarcloud-github-c-cpp@v3
# yamllint disable rule:line-length
- name: Run build-wrapper
run: |
export VCPKG_ROOT=/usr/local/share/vcpkg
build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} make build
# yamllint enable rule:line-length
- name: Run tests to generate coverage statistics
run: |
make coverage
- name: Collect coverage into one XML report
run: |
gcovr -e "src/tests/*" --sonarqube > coverage.xml
# yamllint disable rule:line-length
- name: Run sonar-scanner
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
sonar-scanner \
--define sonar.cfamily.compile-commands="${{ env.BUILD_WRAPPER_OUT_DIR }}/compile_commands.json" \
--define sonar.coverageReportPaths=coverage.xml
# yamllint enable rule:line-length