cmake.yml 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. - name: Set up Python 3.8 for gcovr
  25. uses: actions/setup-python@v6
  26. with:
  27. python-version: 3.8
  28. - name: install gcovr 5.0
  29. run: |
  30. pip install gcovr==5.0 # 5.1 is not supported
  31. - name: Install libcap, lcov, and CppUTest
  32. run: sudo apt-get install -y libcap-dev lcov cpputest
  33. - name: Install sonar-scanner and build-wrapper
  34. uses: SonarSource/sonarcloud-github-c-cpp@v3
  35. - name: Configure CMake
  36. # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
  37. # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
  38. 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
  39. - name: Build
  40. # Build your program with the given configuration
  41. run: |
  42. build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
  43. - name: Test
  44. working-directory: ${{github.workspace}}/build
  45. # Execute tests defined by the CMake configuration.
  46. # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
  47. run: ctest -C ${{env.BUILD_TYPE}}
  48. - name: Collect coverage into one XML report
  49. run: |
  50. gcovr --sonarqube > coverage.xml
  51. - name: Run sonar-scanner
  52. env:
  53. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  54. SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} # Put the name of your token here
  55. run: |
  56. sonar-scanner \
  57. --define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}" \
  58. --define sonar.coverageReportPaths=coverage.xml