Skip to content

Build the tests with whatever the library was built without #16

Build the tests with whatever the library was built without

Build the tests with whatever the library was built without #16

Workflow file for this run

name: CI
# Work happens on dev and lands on main, so main is the only branch worth spending runners on.
# workflow_dispatch is there to repeat a run without pushing.
on:
push:
branches: [ main ]
workflow_dispatch:
jobs:
# Two axes, crossed only where the code paths cross.
#
# Shape runs on every platform. It decides dllexport against visibility, and whether a plugin
# and its host share one type table, and that differs per platform.
#
# Turning exceptions or RTTI off does not need every platform. The flag is chosen by MSVC
# against not-MSVC, and the rest of what varies is the standard library underneath, so three
# platforms cover both compiler families and all three standard libraries. That is the
# no-features job below.
build:
name: ${{ matrix.platform }} ${{ matrix.config }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
platform: [ linux-gcc, linux-clang, macos, windows-msvc, windows-clang-cl ]
config: [ shared, static, release ]
include:
- platform: linux-gcc
os: ubuntu-latest
cc: gcc
cxx: g++
- platform: linux-clang
os: ubuntu-latest
cc: clang
cxx: clang++
- platform: macos
os: macos-latest
cc: clang
cxx: clang++
- platform: windows-msvc
os: windows-latest
cc: cl
cxx: cl
- platform: windows-clang-cl
os: windows-latest
cc: clang-cl
cxx: clang-cl
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
- name: Settings for this configuration
id: cfg
shell: bash
run: |
case "${{ matrix.config }}" in
shared) flags="-DSTDC_BUILD_SHARED=ON"; type=Debug ;;
static) flags="-DSTDC_BUILD_STATIC=ON"; type=Debug ;;
release) flags="-DSTDC_BUILD_SHARED=ON"; type=Release ;;
esac
echo "flags=$flags" >> "$GITHUB_OUTPUT"
echo "type=$type" >> "$GITHUB_OUTPUT"
- name: Configure
shell: bash
env:
CC: ${{ matrix.cc }}
CXX: ${{ matrix.cxx }}
run: |
cmake -G Ninja -S . -B build \
-DCMAKE_BUILD_TYPE=${{ steps.cfg.outputs.type }} \
-DSTDC_BUILD_TESTS=ON \
${{ steps.cfg.outputs.flags }}
- name: Build
run: cmake --build build
# ctest rather than the binary by name, so that where it landed is CMake's business. The
# flag is not optional. ctest exits 0 when it finds no tests at all, which is what a test
# CMakeLists that could not find Boost once produced here.
- name: Test
run: ctest --test-dir build --output-on-failure --no-tests=error
# Exceptions and RTTI switched off, one at a time. Off together would stop covering RTTI off
# with exceptions left on, which is the shape a downstream of this library builds.
#
# Three platforms rather than five, being the MSVC standard library, libstdc++ and libc++.
#
# Both flags are private to the library target, so the tests are built the ordinary way and run
# against a library that was not. A consumer gets the same split. This is also the only thing
# here that runs the library's exception-free branches: STDC_EXCEPTIONS is worked out per
# translation unit from __cpp_exceptions, so the code under those #ifdefs is compiled by these
# two jobs and by nothing else.
no-features:
name: ${{ matrix.platform }} ${{ matrix.config }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
platform: [ linux-gcc, macos, windows-msvc ]
config: [ no-exceptions, no-rtti ]
include:
- platform: linux-gcc
os: ubuntu-latest
cxx: g++
- platform: macos
os: macos-latest
cxx: clang++
- platform: windows-msvc
os: windows-latest
cxx: cl
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
- name: Configure
shell: bash
env:
CXX: ${{ matrix.cxx }}
run: |
case "${{ matrix.config }}" in
no-exceptions) flags="-DSTDC_ENABLE_EXCEPTIONS=OFF" ;;
no-rtti) flags="-DSTDC_ENABLE_RTTI=OFF" ;;
esac
cmake -G Ninja -S . -B build -DCMAKE_BUILD_TYPE=Debug -DSTDC_BUILD_TESTS=ON $flags
- name: Build
run: cmake --build build
- name: Test
run: ctest --test-dir build --output-on-failure --no-tests=error
# Doxygen is a check as much as an output. WARN_AS_ERROR in the Doxyfile is what makes this
# step fail rather than quietly produce a wrong page. Its first run found three defects,
# including a \param naming an argument the function never had.
#
# One platform is enough. It reads the headers, and the Doxyfile predefines the platform
# switches itself.
docs:
name: docs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Ninja and Doxygen
run: |
sudo apt-get update
sudo apt-get install -y ninja-build doxygen
- name: Build
run: |
cmake -G Ninja -S . -B build -DCMAKE_BUILD_TYPE=Debug -DSTDC_BUILD_DOCS=ON
cmake --build build --target stdcorelib_docs
# MinGW builds the library but does not run the tests: Boost.Test for MinGW is its own
# undertaking, and what is worth knowing here is that the Windows sources compile and link
# against something other than the Microsoft toolchain.
mingw:
name: windows-mingw ${{ matrix.config }}
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
config: [ shared, static ]
steps:
- uses: actions/checkout@v4
- uses: msys2/setup-msys2@v2
with:
msystem: MINGW64
update: false
install: >-
mingw-w64-x86_64-gcc
mingw-w64-x86_64-cmake
mingw-w64-x86_64-ninja
- name: Build
shell: msys2 {0}
run: |
case "${{ matrix.config }}" in
shared) flags="-DSTDC_BUILD_SHARED=ON" ;;
static) flags="-DSTDC_BUILD_STATIC=ON" ;;
esac
cmake -G Ninja -S . -B build -DCMAKE_BUILD_TYPE=Debug -DSTDC_BUILD_TESTS=OFF $flags
cmake --build build