| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- # 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.
- # See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-single-platform.yml
- name: CMake on multiple platforms
- on:
- push:
- branches: [ "master" ]
- pull_request:
- branches: [ "master" ]
- jobs:
- build:
- runs-on: ${{ matrix.os }}
- strategy:
- # 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.
- fail-fast: false
- # Set up a matrix to run the following 3 configurations:
- # 1. <Windows, Release, latest MSVC compiler toolchain on the default runner image, default generator>
- # 2. <Linux, Release, latest GCC compiler toolchain on the default runner image, default generator>
- # 3. <Linux, Release, latest Clang compiler toolchain on the default runner image, default generator>
- #
- # To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list.
- matrix:
- os: [ubuntu-latest, windows-latest]
- build_type: [Debug, Release]
- c_compiler: [gcc, clang, cl]
- include:
- - os: windows-latest
- c_compiler: cl
- cpp_compiler: cl
- - os: ubuntu-latest
- c_compiler: gcc
- cpp_compiler: g++
- - os: ubuntu-latest
- c_compiler: clang
- cpp_compiler: clang++
- exclude:
- - os: windows-latest
- build_type: Debug
- - c_compiler: clang
- build_type: Debug
- - os: windows-latest
- c_compiler: gcc
- - os: windows-latest
- c_compiler: clang
- - os: ubuntu-latest
- c_compiler: cl
- steps:
- - uses: actions/checkout@v4
- - name: Set reusable strings
- # Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
- id: strings
- shell: bash
- run: |
- echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
- - name: Setup Python
- uses: actions/[email protected]
- with:
- python-version: 3.10.11
- - name: Install Conan
- run: |
- pip install --upgrade pip
- pip install setuptools wheel
- pip install conan
- conan profile detect --force
- - name: Version Checks
- run: |
- cmake --version
- conan --version
- - name: Configure Conan
- run: |
- 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
- - name: Configure CMake-Linux
- if: matrix.os == 'ubuntu-latest'
- # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
- # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
- run: >
- cmake --preset conan-$(echo "${{ matrix.build_type }}" | tr '[:upper:]' '[:lower:]') -B ${{ steps.strings.outputs.build-output-dir }} -S ${{ github.workspace }}
- - name: Configure CMake-Windows
- if: matrix.os == 'windows-latest'
- run: >
- cmake --preset conan-default -B ${{ steps.strings.outputs.build-output-dir }} -S ${{ github.workspace }}
- - name: Build
- run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} --parallel
- - name: Test
- working-directory: ${{ steps.strings.outputs.build-output-dir }}
- # 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).
- # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
- run: ctest --build-config ${{ matrix.build_type }}
- # Execute the coverage report. the cmake target "coverage" is greated in the Cmake file. We just need too
- # execute make coverage on a Debug build.
- # Only run this on a Ubuntu-gcc-debug build
- - name: Run Coverage Report
- if: matrix.os == 'ubuntu-latest' && matrix.c_compiler == 'gcc' && matrix.build_type == 'Debug'
- run: |
- sudo apt install -y gcovr
- cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} --target coverage
- # Generate the coverage report Only run this on a Ubuntu-gcc-debug build
- - name: Code Coverage Report
- if: matrix.os == 'ubuntu-latest' && matrix.c_compiler == 'gcc' && matrix.build_type == 'Debug'
- uses: irongut/[email protected]
- with:
- filename: build/coverage/report.xml
- badge: true
- fail_below_min: false
- format: markdown
- hide_branch_rate: false
- hide_complexity: false
- indicators: true
- output: both
- thresholds: '60 80'
|