59 lines
2.2 KiB
YAML
59 lines
2.2 KiB
YAML
name: Sonar Cloud
|
|
|
|
on:
|
|
push:
|
|
branches: [ master ]
|
|
paths-ignore:
|
|
- 'Docs/**'
|
|
- '**.md'
|
|
pull_request:
|
|
branches: [ master ]
|
|
paths-ignore:
|
|
- 'Docs/**'
|
|
- '**.md'
|
|
|
|
jobs:
|
|
check-secret:
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
sonar-token: ${{ steps.sonar-token.outputs.defined }}
|
|
steps:
|
|
- id: sonar-token
|
|
if: ${{ env.SONAR_TOKEN != '' }}
|
|
run: echo "defined=true" >> $GITHUB_OUTPUT
|
|
env:
|
|
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
|
|
|
build:
|
|
name: Build
|
|
needs: [check-secret]
|
|
if: needs.check-secret.outputs.sonar-token == 'true'
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed
|
|
CLANG_VERSION: 18
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
with:
|
|
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
|
|
- name: Install build-wrapper
|
|
uses: SonarSource/sonarqube-scan-action/install-build-wrapper@v7
|
|
- name: Configure CMake
|
|
working-directory: ${{github.workspace}}/Build
|
|
run: ./cmake_linux_clang_gcc.sh ReleaseCoverage clang++-${{ env.CLANG_VERSION }}
|
|
- name: Run build-wrapper
|
|
run: build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} cmake --build ${{github.workspace}}/Build/Linux_ReleaseCoverage -j $(nproc)
|
|
- name: Run unit tests and create coverage report
|
|
working-directory: ${{github.workspace}}/Build/Linux_ReleaseCoverage
|
|
run: |
|
|
cmake --build . --target test -j $(nproc)
|
|
llvm-profdata-${{ env.CLANG_VERSION }} merge -sparse default.profraw -o default.profdata
|
|
llvm-cov-${{ env.CLANG_VERSION }} show -format=text UnitTests -instr-profile=default.profdata > coverage.txt
|
|
- name: Run sonar-scanner
|
|
uses: SonarSource/sonarqube-scan-action@v7
|
|
env:
|
|
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
|
with:
|
|
args: >
|
|
--define sonar.cfamily.compile-commands=${{ env.BUILD_WRAPPER_OUT_DIR }}/compile_commands.json --define sonar.cfamily.llvm-cov.reportPath=${{github.workspace}}/Build/Linux_ReleaseCoverage/coverage.txt
|