cmake-multi-platform.yml 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. # This starter workflow is for a CMake project running on multiple platforms. There is a different starter workflow if you just want a single platform.
  2. # See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-single-platform.yml
  3. name: CMake on multiple platforms
  4. on:
  5. push:
  6. branches: [ "master" ]
  7. pull_request:
  8. branches: [ "master" ]
  9. jobs:
  10. build:
  11. runs-on: ${{ matrix.os }}
  12. strategy:
  13. # Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable.
  14. fail-fast: false
  15. # Set up a matrix to run the following 3 configurations:
  16. # 1. <Windows, Release, latest MSVC compiler toolchain on the default runner image, default generator>
  17. # 2. <Linux, Release, latest GCC compiler toolchain on the default runner image, default generator>
  18. # 3. <Linux, Release, latest Clang compiler toolchain on the default runner image, default generator>
  19. #
  20. # To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list.
  21. matrix:
  22. os: [ubuntu-latest, windows-latest]
  23. build_type: [Debug, Release]
  24. c_compiler: [gcc, clang, cl]
  25. include:
  26. - os: windows-latest
  27. c_compiler: cl
  28. cpp_compiler: cl
  29. - os: ubuntu-latest
  30. c_compiler: gcc
  31. cpp_compiler: g++
  32. - os: ubuntu-latest
  33. c_compiler: clang
  34. cpp_compiler: clang++
  35. exclude:
  36. - os: windows-latest
  37. build_type: Debug
  38. - c_compiler: clang
  39. build_type: Debug
  40. - os: windows-latest
  41. c_compiler: gcc
  42. - os: windows-latest
  43. c_compiler: clang
  44. - os: ubuntu-latest
  45. c_compiler: cl
  46. steps:
  47. - uses: actions/checkout@v4
  48. - name: Set reusable strings
  49. # Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
  50. id: strings
  51. shell: bash
  52. run: |
  53. echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
  54. - name: Setup Python
  55. uses: actions/[email protected]
  56. with:
  57. python-version: 3.10.11
  58. - name: Install Conan
  59. run: |
  60. pip install --upgrade pip
  61. pip install setuptools wheel
  62. pip install conan
  63. conan profile detect --force
  64. - name: Version Checks
  65. run: |
  66. cmake --version
  67. conan --version
  68. - name: Configure Conan
  69. run: |
  70. conan install --build missing -s:h "&:build_type=${{ matrix.build_type }}" -s "compiler.cppstd=20" -of=${{ steps.strings.outputs.build-output-dir }} ${{ github.workspace }}/conanfile.txt
  71. - name: Configure CMake-Linux
  72. if: matrix.os == 'ubuntu-latest'
  73. # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
  74. # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
  75. run: >
  76. cmake --preset conan-$(echo "${{ matrix.build_type }}" | tr '[:upper:]' '[:lower:]') -B ${{ steps.strings.outputs.build-output-dir }} -S ${{ github.workspace }}
  77. - name: Configure CMake-Windows
  78. if: matrix.os == 'windows-latest'
  79. run: >
  80. cmake --preset conan-default -B ${{ steps.strings.outputs.build-output-dir }} -S ${{ github.workspace }}
  81. - name: Build
  82. run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} --parallel
  83. - name: Test
  84. working-directory: ${{ steps.strings.outputs.build-output-dir }}
  85. # Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
  86. # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
  87. run: ctest --build-config ${{ matrix.build_type }}
  88. # Execute the coverage report. the cmake target "coverage" is greated in the Cmake file. We just need too
  89. # execute make coverage on a Debug build.
  90. # Only run this on a Ubuntu-gcc-debug build
  91. - name: Run Coverage Report
  92. if: matrix.os == 'ubuntu-latest' && matrix.c_compiler == 'gcc' && matrix.build_type == 'Debug'
  93. run: |
  94. sudo apt install -y gcovr
  95. cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} --target coverage
  96. # Generate the coverage report Only run this on a Ubuntu-gcc-debug build
  97. - name: Code Coverage Report
  98. if: matrix.os == 'ubuntu-latest' && matrix.c_compiler == 'gcc' && matrix.build_type == 'Debug'
  99. uses: irongut/[email protected]
  100. with:
  101. filename: build/coverage/report.xml
  102. badge: true
  103. fail_below_min: false
  104. format: markdown
  105. hide_branch_rate: false
  106. hide_complexity: false
  107. indicators: true
  108. output: both
  109. thresholds: '60 80'