Merge pull request #14 from sir-gon/feature/a_very_big_sum #57
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: # 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-latest | |
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: | | |
pip install gcovr | |
- name: Check Tools | |
run: | | |
make --version | |
cmake --version | |
vcpkg --version | |
gcovr --version | |
- name: Install dependencies | |
run: | | |
vcpkg integrate install | |
vcpkg install | |
- 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 | |
cmake --preset debug -B build | |
cmake --preset debug \ | |
-DCMAKE_TOOLCHAIN_FILE=/usr/local/share/vcpkg/scripts/buildsystems/vcpkg.cmake \ | |
-DCMAKE_EXPORT_COMPILE_COMMANDS=1 \ | |
build | |
build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} cmake --build build --verbose | |
# 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 |