cmake.yml 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. runs-on: ubuntu-latest
  17. steps:
  18. - uses: actions/checkout@v3
  19. with:
  20. fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
  21. - name: Install sonar-scanner and build-wrapper
  22. uses: SonarSource/sonarcloud-github-c-cpp@v1
  23. - name: Install libcap
  24. run: sudo apt-get install -y libcap-dev
  25. - name: Configure CMake
  26. # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
  27. # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
  28. 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
  29. - name: Build
  30. # Build your program with the given configuration
  31. run: |
  32. cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
  33. - name: Test
  34. working-directory: ${{github.workspace}}/build
  35. # Execute tests defined by the CMake configuration.
  36. # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
  37. run: ctest -C ${{env.BUILD_TYPE}}
  38. - name: Run sonar-scanner
  39. env:
  40. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  41. SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} # Put the name of your token here
  42. run: |
  43. cmake --build ${{github.workspace}}/build --target clean
  44. build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} cmake --build ${{github.workspace}}/build --config Release
  45. sonar-scanner --define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}"