Merge pull request #116 from sjinks/renovate/codecov-codecov-action-5.x #293
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: SonarCloud | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
types: | |
- opened | |
- synchronize | |
- reopened | |
jobs: | |
build: | |
name: Build and analyze | |
runs-on: ubuntu-24.04 | |
env: | |
BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory | |
CXX: clang++-18 | |
steps: | |
- name: Check out code | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
fetch-depth: 0 | |
- name: Install dependencies | |
uses: ./.github/actions/install-dependencies | |
- name: Install sonar-scanner and build-wrapper | |
uses: SonarSource/sonarcloud-github-c-cpp@816b1822d71776ee0d32bc012e95024ec52ac1fc # v3.1.0 | |
- name: Install gcovr | |
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends gcovr | |
- name: Run build-wrapper | |
run: | | |
cmake -B build -DCMAKE_BUILD_TYPE=Coverage | |
build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} cmake --build build | |
- name: Run tests | |
run: ctest --test-dir build --output-on-failure | |
- name: Generate coverage | |
run: gcovr -f src --exclude-noncode-lines --exclude-throw-branches --exclude-unreachable-branches --sonarqube coverage-sonarqube.xml --lcov coverage-lcov.xml --gcov-executable 'llvm-cov-17 gcov' | |
- 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 }}" --define sonar.coverageReportPaths=coverage-sonarqube.xml | |
- name: Upload coverage reports to Codecov | |
uses: codecov/codecov-action@015f24e6818733317a2da2edd6290ab26238649a # v5.0.7 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
file: coverage-lcov.xml |