Progmasoft Git

catch3

Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.

Clonegit clone https://git.progmasoft.com/catch3

develroot / .github / workflows / linux-builds.yml

6.2 KiB · Raw · Log

name: Linux Builds

# The Linux hosts are those of the Visual X# compiler, which is the first
# user of this framework: the current Ubuntu LTS, and Fedora in a container.
# Both build with Clang, the compiler that project uses everywhere.

on:
  push:
    branches: [devel]
  pull_request:

permissions:
  contents: read

env:
  CTEST_OUTPUT_ON_FAILURE: 1
  CTEST_NO_TESTS_ACTION: error

jobs:
  ubuntu:
    name: Ubuntu 26.04, C++${{matrix.std}}, ${{matrix.build_type}}
    runs-on: ubuntu-26.04
    timeout-minutes: 45
    strategy:
      fail-fast: false
      matrix:
        build_type: [Debug, Release]
        std: [17, 20]

    steps:
    - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
      with:
        persist-credentials: false

    - name: Install Clang, LLVM's coverage tools, CMake, Ninja and defusedxml
      run: |
        sudo apt-get update
        sudo apt-get install -y clang llvm cmake ninja-build python3 python3-defusedxml

    - name: Configure
      run: |
        cmake --preset basic-tests -GNinja \
              -DCMAKE_BUILD_TYPE=${{matrix.build_type}} \
              -DCMAKE_CXX_COMPILER=clang++ \
              -DCMAKE_CXX_STANDARD=${{matrix.std}} \
              -DCATCH3_BUILD_EXAMPLES=ON \
              -DCATCH3_BUILD_EXTRA_TESTS=ON

    - name: Build
      run: cmake --build build

    - name: Test
      run: ctest --test-dir build -j
      env:
        CATCH3_COVERAGE_REQUIRE_MAP: 1

    - name: Install, and find the installed package
      run: |
        cmake --install build --prefix "$RUNNER_TEMP/catch3"
        mkdir "$RUNNER_TEMP/consumer"
        cat > "$RUNNER_TEMP/consumer/CMakeLists.txt" <<'EOF'
        cmake_minimum_required(VERSION 3.16)
        project(Consumer CXX)
        find_package(Catch3 REQUIRED)
        EOF
        cmake -S "$RUNNER_TEMP/consumer" -B "$RUNNER_TEMP/consumer/build" \
              -GNinja -DCMAKE_CXX_COMPILER=clang++ \
              -DCMAKE_PREFIX_PATH="$RUNNER_TEMP/catch3"

    - name: Link the installed library with -lCatch3, and through pkg-config
      run: |
        prefix="$RUNNER_TEMP/catch3"
        cat > "$RUNNER_TEMP/consumer/test.cpp" <<'EOF'
        #include <Progmasoft/Catch3.hpp>
        TEST_CASE("an installed Catch3 links by its name") { REQUIRE(1 + 1 == 2); }
        EOF
        # A debug build is named apart with a "d".
        d=""
        if [ "$BUILD_TYPE" = Debug ]; then d=d; fi
        clang++ -std=c++${{matrix.std}} -I"$prefix/include" "$RUNNER_TEMP/consumer/test.cpp" \
                -L"$prefix/lib" "-lCatch3Main$d" "-lCatch3$d" -o "$RUNNER_TEMP/consumer/by-name"
        "$RUNNER_TEMP/consumer/by-name"
        export PKG_CONFIG_PATH="$prefix/share/pkgconfig"
        # shellcheck disable=SC2046 # pkg-config prints several flags.
        clang++ -std=c++${{matrix.std}} "$RUNNER_TEMP/consumer/test.cpp" \
                $(pkg-config --cflags --libs catch3-with-main) -o "$RUNNER_TEMP/consumer/by-pkg-config"
        "$RUNNER_TEMP/consumer/by-pkg-config"
      env:
        BUILD_TYPE: ${{matrix.build_type}}

  thread-sanitizer:
    name: Ubuntu 26.04, C++17, ThreadSanitizer and UBSan
    runs-on: ubuntu-26.04
    timeout-minutes: 45

    steps:
    - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
      with:
        persist-credentials: false

    - name: Install Clang, LLVM's coverage tools, CMake and Ninja
      run: |
        sudo apt-get update
        sudo apt-get install -y clang llvm cmake ninja-build python3

    - name: Configure with the sanitizers
      env:
        CXXFLAGS: -fsanitize=thread,undefined
        LDFLAGS: -fsanitize=thread,undefined
      run: |
        cmake --preset basic-tests -GNinja \
              -DCMAKE_BUILD_TYPE=Debug \
              -DCMAKE_CXX_COMPILER=clang++ \
              -DCMAKE_CXX_STANDARD=17 \
              -DCATCH3_BUILD_EXTRA_TESTS=ON

    - name: Build
      run: cmake --build build

    - name: Test
      run: ctest --test-dir build -R ThreadSafetyTests

  fedora:
    name: Fedora 43, C++${{matrix.std}}, ${{matrix.build_type}}
    runs-on: ubuntu-26.04
    container: fedora:43
    timeout-minutes: 45
    strategy:
      fail-fast: false
      matrix:
        build_type: [Debug, Release]
        std: [17, 20]

    steps:
    # Git comes first: without it the checkout falls back to an archive of
    # the repository, which is not a checkout the tests can ask questions of.
    - name: Install Git, Clang, LLVM's coverage tools, CMake, Ninja and defusedxml
      run: dnf install -y git clang llvm gcc-c++ cmake ninja-build python3 python3-defusedxml

    - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
      with:
        persist-credentials: false

    - name: Configure
      run: |
        cmake --preset basic-tests -GNinja \
              -DCMAKE_BUILD_TYPE=${{matrix.build_type}} \
              -DCMAKE_CXX_COMPILER=clang++ \
              -DCMAKE_CXX_STANDARD=${{matrix.std}} \
              -DCATCH3_BUILD_EXAMPLES=ON \
              -DCATCH3_BUILD_EXTRA_TESTS=ON

    - name: Build
      run: cmake --build build

    - name: Test
      run: ctest --test-dir build -j
      env:
        CATCH3_COVERAGE_REQUIRE_MAP: 1

  # Catch3 is built with Clang everywhere; GCC's stricter warnings are not
  # errors here. The job checks per-test coverage in gcov's format, which
  # only GCC writes.
  gcc-coverage:
    name: Ubuntu 26.04, GCC, per-test coverage with gcov
    runs-on: ubuntu-26.04
    timeout-minutes: 30

    steps:
    - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
      with:
        persist-credentials: false

    - name: Install GCC, CMake and Ninja
      run: |
        sudo apt-get update
        sudo apt-get install -y g++ cmake ninja-build python3

    - name: Configure
      run: |
        cmake --preset basic-tests -GNinja \
              -DCMAKE_BUILD_TYPE=Debug \
              -DCMAKE_CXX_COMPILER=g++ \
              -DCMAKE_CXX_STANDARD=17 \
              -DCATCH3_ENABLE_WERROR=OFF

    - name: Build
      run: cmake --build build --target ProgmasoftSelfTest

    - name: Test per-test coverage
      env:
        CATCH3_RUNNER_FIXTURE: build/tests/RunnerFixture
        CATCH3_COVERAGE_FIXTURE: build/tests/CoverageFixture
        CATCH3_COVERAGE_REQUIRE_MAP: 1
      run: build/tests/ProgmasoftSelfTest --no-history "[coverage]"