spawn #87
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # based on https://github.com/actions/starter-workflows/blob/main/ci/cmake-multi-platform.yml | |
| name: CMake build and test | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: [ trunk ] | |
| pull_request: | |
| branches: [ trunk ] | |
| 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 | |
| # | |
| matrix: | |
| os: [ubuntu-latest, windows-latest] | |
| build_type: [Debug, Release] | |
| c_compiler: [gcc, cl] | |
| include: | |
| - os: windows-latest | |
| c_compiler: cl | |
| cxx_compiler: cl | |
| - os: ubuntu-latest | |
| c_compiler: gcc | |
| cxx_compiler: g++ | |
| exclude: | |
| - os: windows-latest | |
| c_compiler: gcc | |
| - os: ubuntu-latest | |
| c_compiler: cl | |
| steps: | |
| - uses: actions/checkout@v3 | |
| with: | |
| submodules: true | |
| - 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" | |
| if [ "$RUNNER_OS" = "Linux" ]; then | |
| echo "vcpkg-setup-file=bootstrap-vcpkg.sh" >> "$GITHUB_OUTPUT" | |
| elif [ "$RUNNER_OS" = "Windows" ]; then | |
| echo "vcpkg-setup-file=bootstrap-vcpkg.bat" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Cache vcpkg | |
| id: cache-vcpkg | |
| uses: actions/cache@v3 | |
| with: | |
| path: ${{ github.workspace }}/vcpkg | |
| key: ${{ matrix.os }}-${{ matrix.c_compiler }}-${{ matrix.build_type }}-vcpkg | |
| - name: Configure vcpkg | |
| if: steps.cache-vcpkg.outputs.cache-hit != 'true' | |
| working-directory: ${{ github.workspace }} | |
| run: | | |
| git clone https://github.com/Microsoft/vcpkg.git | |
| ./vcpkg/${{ steps.strings.outputs.vcpkg-setup-file }} -disableMetrics | |
| ./vcpkg/vcpkg install catch2 | |
| - name: Configure CMake | |
| run: > | |
| cmake --preset ci | |
| -B ${{ steps.strings.outputs.build-output-dir }} | |
| -DCMAKE_CXX_COMPILER=${{ matrix.cxx_compiler }} | |
| -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} | |
| -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} | |
| -S ${{ github.workspace }} | |
| - name: Build | |
| run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} -j | |
| - name: Test | |
| working-directory: ${{ steps.strings.outputs.build-output-dir }}/tests | |
| run: ctest --build-config ${{ matrix.build_type }} --output-on-failure |