Test CHECK/REQUIRE abort with no active test state #146
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
| # Copyright Agustin K-ballo Berge, Fusion Fenix 2026 | |
| # | |
| # Distributed under the Boost Software License, Version 1.0. (See accompanying | |
| # file LICENSE.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |
| name: test | |
| on: | |
| push: | |
| branches: [ main, feature/** ] | |
| pull_request: | |
| types: [opened, synchronize, reopened] | |
| jobs: | |
| build: | |
| name: ${{ matrix.os }} / ${{ matrix.compiler }} | |
| runs-on: ${{ matrix.os }} | |
| timeout-minutes: 6 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| # -- Linux / GCC 13 -- | |
| - os: ubuntu-24.04 | |
| compiler: gcc-13 | |
| preset: dev-gcc | |
| # -- Linux / GCC 16 -- | |
| - os: ubuntu-24.04 | |
| compiler: gcc-16 | |
| preset: dev-gcc | |
| # -- Linux / Clang 18 -- | |
| - os: ubuntu-24.04 | |
| compiler: clang-18 | |
| preset: dev-clang | |
| # -- Linux / Clang 18 + libc++ -- | |
| - os: ubuntu-24.04 | |
| compiler: clang-18+libc++ | |
| preset: dev-clang-libcxx | |
| # -- Linux / Clang 22 -- | |
| - os: ubuntu-24.04 | |
| compiler: clang-22 | |
| preset: dev-clang | |
| # -- Linux / Clang 22 + libc++ -- | |
| - os: ubuntu-24.04 | |
| compiler: clang-22+libc++ | |
| preset: dev-clang-libcxx | |
| # -- Windows 2022 / MSVC 2022 -- | |
| - os: windows-2022 | |
| compiler: msvc-2022 | |
| preset: dev-msvc | |
| # -- Windows 2025 / MSVC 2026 -- | |
| - os: windows-2025-vs2026 | |
| compiler: msvc-2026 | |
| preset: dev-msvc | |
| # -- Windows 2025 / Clang-CL 20 -- | |
| - os: windows-2025-vs2026 | |
| compiler: clang-cl-20 | |
| preset: dev-clang-cl | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Install CMake | |
| uses: lukka/get-cmake@latest | |
| with: | |
| cmakeVersion: "4.4.0" | |
| - name: Set up MSVC environment | |
| if: startsWith(matrix.compiler, 'msvc') || startsWith(matrix.compiler, 'clang-cl') | |
| shell: pwsh | |
| run: | | |
| $vsPath = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" ` | |
| -latest -property installationPath | |
| $vcvars = "$vsPath\VC\Auxiliary\Build\vcvars64.bat" | |
| cmd /c "`"$vcvars`" && set" | ForEach-Object { | |
| if ($_ -match '^([^=]+)=(.*)$') { | |
| "$($Matches[1])=$($Matches[2])" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append | |
| } | |
| } | |
| - name: Set up APT package cache | |
| if: runner.os == 'Linux' | |
| run: | | |
| mkdir -p ~/.cache/apt/archives/partial | |
| echo "Dir::Cache::archives \"$HOME/.cache/apt/archives\";" \ | |
| | sudo tee /etc/apt/apt.conf.d/99user-cache | |
| - name: Cache APT packages | |
| if: runner.os == 'Linux' | |
| continue-on-error: true | |
| uses: actions/cache@v5 | |
| with: | |
| path: ~/.cache/apt/archives | |
| key: apt-${{ matrix.os }}-${{ matrix.compiler }}-${{ hashFiles('.github/workflows/test.yml') }} | |
| restore-keys: apt-${{ matrix.os }}-${{ matrix.compiler }}- | |
| - name: Install GCC 16 | |
| if: matrix.compiler == 'gcc-16' | |
| run: | | |
| sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y | |
| sudo apt-get update -q | |
| sudo apt-get install -y gcc-16 g++-16 | |
| sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-16 100 \ | |
| --slave /usr/bin/g++ g++ /usr/bin/g++-16 | |
| - name: Install Clang 18 | |
| if: startsWith(matrix.compiler, 'clang-18') | |
| run: | | |
| sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-18 200 | |
| sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-18 200 | |
| - name: Install libc++-18 | |
| if: matrix.compiler == 'clang-18+libc++' | |
| run: sudo apt-get install -y libc++-18-dev libc++abi-18-dev | |
| - name: Install Clang 22 | |
| if: startsWith(matrix.compiler, 'clang-22') | |
| run: | | |
| wget -q https://apt.llvm.org/llvm.sh | |
| sudo bash llvm.sh 22 | |
| sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-22 200 | |
| sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-22 200 | |
| - name: Install libc++-22 | |
| if: matrix.compiler == 'clang-22+libc++' | |
| run: sudo apt-get install -y libc++-22-dev libc++abi-22-dev | |
| - name: Fix APT cache permissions | |
| if: always() && runner.os == 'Linux' | |
| run: sudo rm -rf ~/.cache/apt/archives/lock ~/.cache/apt/archives/partial | |
| # ----------------------------------------------------------------------- | |
| # Main project | |
| # ----------------------------------------------------------------------- | |
| - name: Configure | |
| id: configure | |
| run: cmake --preset ${{ matrix.preset }} -B build/${{ matrix.preset }} | |
| - name: Build library (Debug) | |
| id: build_lib_debug | |
| if: >- | |
| always() | |
| && steps.configure.outcome == 'success' | |
| run: cmake --build build/${{ matrix.preset }} --config Debug | |
| --target _eggs_test _eggs_test_main | |
| - name: Build tests (Debug) | |
| id: build_debug | |
| if: >- | |
| always() | |
| && steps.configure.outcome == 'success' | |
| run: | | |
| cmake --build build/${{ matrix.preset }} --config Debug -- -k 0 | |
| - name: Run header tests (Debug) | |
| id: test_header_debug | |
| if: >- | |
| always() | |
| && steps.build_debug.outcome == 'success' | |
| run: ctest --test-dir build/${{ matrix.preset }} --build-config Debug | |
| --label-regex header | |
| --output-on-failure | |
| --no-compress-output | |
| --output-junit test-results-${{ matrix.compiler }}-debug-header.xml | |
| - name: Run unit tests (Debug) | |
| id: test_unit_debug | |
| if: >- | |
| always() | |
| && steps.build_debug.outcome == 'success' | |
| run: ctest --test-dir build/${{ matrix.preset }} --build-config Debug | |
| --label-regex unit | |
| --output-on-failure | |
| --no-compress-output | |
| --output-junit test-results-${{ matrix.compiler }}-debug-unit.xml | |
| - name: Run examples (Debug) | |
| id: test_example_debug | |
| if: >- | |
| always() | |
| && steps.build_debug.outcome == 'success' | |
| run: ctest --test-dir build/${{ matrix.preset }} --build-config Debug | |
| --label-regex example | |
| --output-on-failure | |
| --no-compress-output | |
| --output-junit test-results-${{ matrix.compiler }}-debug-example.xml | |
| - name: Build library (Release) | |
| id: build_lib_release | |
| if: >- | |
| always() | |
| && steps.configure.outcome == 'success' | |
| run: cmake --build build/${{ matrix.preset }} --config Release | |
| --target _eggs_test _eggs_test_main | |
| - name: Build tests (Release) | |
| id: build_release | |
| if: >- | |
| always() | |
| && steps.configure.outcome == 'success' | |
| run: cmake --build build/${{ matrix.preset }} --config Release -- -k 0 | |
| - name: Run header tests (Release) | |
| id: test_header_release | |
| if: >- | |
| always() | |
| && steps.build_release.outcome == 'success' | |
| run: ctest --test-dir build/${{ matrix.preset }} --build-config Release | |
| --label-regex header | |
| --output-on-failure | |
| --no-compress-output | |
| --output-junit test-results-${{ matrix.compiler }}-release-header.xml | |
| - name: Run unit tests (Release) | |
| id: test_unit_release | |
| if: >- | |
| always() | |
| && steps.build_release.outcome == 'success' | |
| run: ctest --test-dir build/${{ matrix.preset }} --build-config Release | |
| --label-regex unit | |
| --output-on-failure | |
| --no-compress-output | |
| --output-junit test-results-${{ matrix.compiler }}-release-unit.xml | |
| - name: Run examples (Release) | |
| id: test_example_release | |
| if: >- | |
| always() | |
| && steps.build_release.outcome == 'success' | |
| run: ctest --test-dir build/${{ matrix.preset }} --build-config Release | |
| --label-regex example | |
| --output-on-failure | |
| --no-compress-output | |
| --output-junit test-results-${{ matrix.compiler }}-release-example.xml | |
| - name: Upload test results | |
| id: upload_test_results | |
| continue-on-error: true | |
| if: always() | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: test-results-${{ matrix.compiler }} | |
| path: build/${{ matrix.preset }}/test-results-*.xml | |
| retention-days: 30 | |
| # ----------------------------------------------------------------------- | |
| # FetchContent variant - simulates embedding via FetchContent_MakeAvailable | |
| # (main only) | |
| # ----------------------------------------------------------------------- | |
| - name: Copy Preset (FetchContent) | |
| id: fc_copy_preset | |
| if: >- | |
| always() | |
| && github.ref == 'refs/heads/main' | |
| && steps.configure.outcome == 'success' | |
| run: cp ./CMakePresets.json test/cmake-fetch_content | |
| - name: Test Consumer (FetchContent) - Configure | |
| id: fc_configure | |
| if: >- | |
| always() | |
| && github.ref == 'refs/heads/main' | |
| && steps.configure.outcome == 'success' | |
| working-directory: test/cmake-fetch_content | |
| run: cmake --preset ${{ matrix.preset }} -B build-consumer-fetch_content | |
| -DEGGS_TEST_SOURCE_DIR=${{ github.workspace }} | |
| - name: Test Consumer (FetchContent) - Build (Debug) | |
| id: fc_build_debug | |
| if: >- | |
| always() | |
| && github.ref == 'refs/heads/main' | |
| && steps.fc_configure.outcome == 'success' | |
| working-directory: test/cmake-fetch_content | |
| run: cmake --build build-consumer-fetch_content --config Debug | |
| - name: Test Consumer (FetchContent) - Test (Debug) | |
| id: fc_test_debug | |
| if: >- | |
| always() | |
| && github.ref == 'refs/heads/main' | |
| && steps.fc_configure.outcome == 'success' | |
| working-directory: test/cmake-fetch_content | |
| run: ctest --test-dir build-consumer-fetch_content --build-config Debug -V | |
| - name: Test Consumer (FetchContent) - Build (Release) | |
| id: fc_build_release | |
| if: >- | |
| always() | |
| && github.ref == 'refs/heads/main' | |
| && steps.fc_configure.outcome == 'success' | |
| working-directory: test/cmake-fetch_content | |
| run: cmake --build build-consumer-fetch_content --config Release | |
| - name: Test Consumer (FetchContent) - Test (Release) | |
| id: fc_test_release | |
| if: >- | |
| always() | |
| && github.ref == 'refs/heads/main' | |
| && steps.fc_configure.outcome == 'success' | |
| working-directory: test/cmake-fetch_content | |
| run: ctest --test-dir build-consumer-fetch_content --build-config Release -V | |
| # ----------------------------------------------------------------------- | |
| # Install variant - simulates a real end-user find_package workflow | |
| # (main only) | |
| # ----------------------------------------------------------------------- | |
| - name: Test Install (Debug) | |
| id: install_debug | |
| if: >- | |
| always() | |
| && github.ref == 'refs/heads/main' | |
| && steps.build_lib_debug.outcome == 'success' | |
| run: cmake --install build/${{ matrix.preset }} | |
| --prefix ${{ runner.temp }}/eggs-test-install | |
| --config Debug | |
| - name: Test Install (Release) | |
| id: install_release | |
| if: >- | |
| always() | |
| && github.ref == 'refs/heads/main' | |
| && steps.build_lib_release.outcome == 'success' | |
| run: cmake --install build/${{ matrix.preset }} | |
| --prefix ${{ runner.temp }}/eggs-test-install | |
| --config Release | |
| - name: Upload installed package | |
| id: upload_installed_package | |
| continue-on-error: true | |
| if: >- | |
| always() | |
| && github.ref == 'refs/heads/main' | |
| && steps.install_debug.outcome == 'success' | |
| && steps.install_release.outcome == 'success' | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: installed-package-${{ matrix.compiler }} | |
| path: ${{ runner.temp }}/eggs-test-install | |
| if-no-files-found: error | |
| retention-days: 7 | |
| - name: Clean Source and Build Tree | |
| id: clean_source_build_tree | |
| if: >- | |
| always() | |
| && github.ref == 'refs/heads/main' | |
| && steps.configure.outcome == 'success' | |
| run: cmake -E rm -rf ./include ./src ./build | |
| - name: Install CMake (find_package minimum) | |
| id: fp_install_cmake_min | |
| if: >- | |
| always() | |
| && github.ref == 'refs/heads/main' | |
| && steps.install_debug.outcome == 'success' | |
| && steps.install_release.outcome == 'success' | |
| uses: lukka/get-cmake@latest | |
| with: | |
| cmakeVersion: "3.21.0" | |
| - name: Test Consumer (find_package) - Configure | |
| id: fp_configure | |
| if: >- | |
| always() | |
| && github.ref == 'refs/heads/main' | |
| && steps.install_debug.outcome == 'success' | |
| && steps.install_release.outcome == 'success' | |
| && steps.fp_install_cmake_min.outcome == 'success' | |
| working-directory: test/cmake-find_package | |
| env: | |
| CXX: ${{ startsWith(matrix.compiler, 'gcc') && 'g++' || startsWith(matrix.compiler, 'clang-cl') && 'clang-cl' || startsWith(matrix.compiler, 'clang') && 'clang++' || 'cl' }} | |
| CXXFLAGS: ${{ contains(matrix.compiler, 'libc++') && '-stdlib=libc++' || '' }} | |
| LDFLAGS: ${{ contains(matrix.compiler, 'libc++') && '-stdlib=libc++' || '' }} | |
| CMAKE_PREFIX_PATH: ${{ runner.temp }}/eggs-test-install | |
| run: cmake -S . -B build-consumer-find_package | |
| -G "Ninja Multi-Config" | |
| --debug-find | |
| - name: Test Consumer (find_package) - Build (Debug) | |
| id: fp_build_debug | |
| if: >- | |
| always() | |
| && github.ref == 'refs/heads/main' | |
| && steps.fp_configure.outcome == 'success' | |
| working-directory: test/cmake-find_package | |
| run: cmake --build build-consumer-find_package --config Debug | |
| - name: Test Consumer (find_package) - Test (Debug) | |
| id: fp_test_debug | |
| if: >- | |
| always() | |
| && github.ref == 'refs/heads/main' | |
| && steps.fp_configure.outcome == 'success' | |
| working-directory: test/cmake-find_package | |
| run: ctest --test-dir build-consumer-find_package --build-config Debug -V | |
| - name: Test Consumer (find_package) - Build (Release) | |
| id: fp_build_release | |
| if: >- | |
| always() | |
| && github.ref == 'refs/heads/main' | |
| && steps.fp_configure.outcome == 'success' | |
| working-directory: test/cmake-find_package | |
| run: cmake --build build-consumer-find_package --config Release | |
| - name: Test Consumer (find_package) - Test (Release) | |
| id: fp_test_release | |
| if: >- | |
| always() | |
| && github.ref == 'refs/heads/main' | |
| && steps.fp_configure.outcome == 'success' | |
| working-directory: test/cmake-find_package | |
| run: ctest --test-dir build-consumer-find_package --build-config Release -V | |
| - name: Check all step outcomes | |
| if: always() | |
| shell: bash | |
| run: | | |
| failed=$(echo '${{ toJSON(steps) }}' | jq -r '[to_entries[] | select(.value.outcome == "failure") | .key] | join(", ")') | |
| if [ -n "$failed" ]; then | |
| echo "::error::Failed steps: $failed" | |
| fi |