sonar-cloud.yml 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. name: Sonar Cloud
  2. on:
  3. push:
  4. branches: [ master ]
  5. paths-ignore:
  6. - 'Docs/**'
  7. - '**.md'
  8. pull_request:
  9. branches: [ master ]
  10. paths-ignore:
  11. - 'Docs/**'
  12. - '**.md'
  13. jobs:
  14. check-secret:
  15. runs-on: ubuntu-latest
  16. outputs:
  17. sonar-token: ${{ steps.sonar-token.outputs.defined }}
  18. steps:
  19. - id: sonar-token
  20. if: ${{ env.SONAR_TOKEN != '' }}
  21. run: echo "defined=true" >> $GITHUB_OUTPUT
  22. env:
  23. SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
  24. build:
  25. name: Build
  26. needs: [check-secret]
  27. if: needs.check-secret.outputs.sonar-token == 'true'
  28. runs-on: ubuntu-latest
  29. env:
  30. BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed
  31. CLANG_VERSION: 18
  32. steps:
  33. - uses: actions/checkout@v5
  34. with:
  35. fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
  36. - name: Install sonar-scanner and build-wrapper
  37. uses: SonarSource/sonarcloud-github-c-cpp@v3
  38. - name: Configure CMake
  39. working-directory: ${{github.workspace}}/Build
  40. run: ./cmake_linux_clang_gcc.sh ReleaseCoverage clang++-${{ env.CLANG_VERSION }}
  41. - name: Run build-wrapper
  42. run: build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} cmake --build ${{github.workspace}}/Build/Linux_ReleaseCoverage -j $(nproc)
  43. - name: Run unit tests and create coverage report
  44. working-directory: ${{github.workspace}}/Build/Linux_ReleaseCoverage
  45. run: |
  46. cmake --build . --target test -j $(nproc)
  47. llvm-profdata-${{ env.CLANG_VERSION }} merge -sparse default.profraw -o default.profdata
  48. llvm-cov-${{ env.CLANG_VERSION }} show -format=text UnitTests -instr-profile=default.profdata > coverage.txt
  49. - name: Run sonar-scanner
  50. env:
  51. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  52. SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
  53. run: |
  54. sonar-scanner --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"