cmake.yml 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. name: CMake
  2. on:
  3. push:
  4. branches: [ "master" ]
  5. pull_request:
  6. branches: [ "master" ]
  7. env:
  8. # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
  9. BUILD_TYPE: Release
  10. BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed
  11. jobs:
  12. build:
  13. # The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
  14. # You can convert this to a matrix build if you need cross-platform coverage.
  15. # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
  16. name: Build
  17. runs-on: ubuntu-latest
  18. env:
  19. BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed
  20. steps:
  21. - uses: actions/checkout@v4
  22. with:
  23. fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
  24. - uses: actions/checkout@v4
  25. - name: Set up Python 3.8 for gcovr
  26. uses: actions/setup-python@v5
  27. with:
  28. python-version: 3.8
  29. - name: install gcovr 5.0
  30. run: |
  31. pip install gcovr==5.0 # 5.1 is not supported
  32. - name: Install libcap, lcov, and CppUTest
  33. run: sudo apt-get install -y libcap-dev lcov cpputest
  34. - name: Install sonar-scanner and build-wrapper
  35. uses: SonarSource/sonarcloud-github-c-cpp@v2
  36. - name: Configure CMake
  37. # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
  38. # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
  39. run: cmake -S ${{github.workspace}}/source -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DOpENer_PLATFORM:STRING="POSIX" -DBUILD_SHARED_LIBS:BOOL=OFF -DOpENer_TRACES:BOOL=OFF -DOpENer_TESTS:BOOL=ON -DCPPUTEST_HOME:PATH=/usr
  40. - name: Build
  41. # Build your program with the given configuration
  42. run: |
  43. build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
  44. - name: Test
  45. working-directory: ${{github.workspace}}/build
  46. # Execute tests defined by the CMake configuration.
  47. # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
  48. run: ctest -C ${{env.BUILD_TYPE}}
  49. - name: Collect coverage into one XML report
  50. run: |
  51. gcovr --sonarqube > coverage.xml
  52. - name: Run sonar-scanner
  53. env:
  54. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  55. SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} # Put the name of your token here
  56. run: |
  57. sonar-scanner \
  58. --define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}" \
  59. --define sonar.coverageReportPaths=coverage.xml