Feature: stacktrace support #695
This file contains 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
name: build & test | |
on: | |
push: | |
branches: [ main, development ] | |
pull_request: | |
branches: [ main, development ] | |
jobs: | |
############ | |
# | |
# Defines the compiler configurations for the other jobs. | |
# | |
##### | |
define-matrix: | |
runs-on: ubuntu-latest | |
env: | |
config: | | |
[ | |
{ | |
"prefix": "Linux", | |
"suffix": "/libc++", | |
"os": "ubuntu-latest", | |
"container": { | |
"image": "ghcr.io/dnkpp/clang:18" | |
}, | |
"compiler_name": "clang", | |
"compiler_version": 18, | |
"architecture": "x64", | |
"libcxx": true, | |
"asan": true | |
}, | |
{ | |
"prefix": "Linux", | |
"os": "ubuntu-latest", | |
"container": { | |
"image": "ghcr.io/dnkpp/clang:18" | |
}, | |
"compiler_name": "clang", | |
"compiler_version": 18, | |
"architecture": "x64", | |
"libcxx": false, | |
"asan": true | |
}, | |
{ | |
"prefix": "Linux", | |
"suffix": "/libc++", | |
"os": "ubuntu-latest", | |
"container": { "image": "ghcr.io/dnkpp/clang:17" }, | |
"compiler_name": "clang", | |
"compiler_version": 17, | |
"architecture": "x64", | |
"libcxx": true, | |
"asan": true | |
}, | |
{ | |
"prefix": "Linux", | |
"os": "ubuntu-latest", | |
"container": { "image": "ghcr.io/dnkpp/clang:17" }, | |
"compiler_name": "clang", | |
"compiler_version": 17, | |
"architecture": "x64", | |
"libcxx": false, | |
"asan": true | |
}, | |
{ | |
"prefix": "Linux", | |
"suffix": "/libc++", | |
"os": "ubuntu-latest", | |
"container": { "image": "ghcr.io/dnkpp/clang:16" }, | |
"compiler_name": "clang", | |
"compiler_version": 16, | |
"architecture": "x64", | |
"libcxx": true, | |
"asan": true | |
}, | |
{ | |
"prefix": "Linux", | |
"os": "ubuntu-latest", | |
"container": { "image": "ghcr.io/dnkpp/clang:16" }, | |
"compiler_name": "clang", | |
"compiler_version": 16, | |
"architecture": "x64", | |
"libcxx": false, | |
"asan": true | |
}, | |
{ | |
"prefix": "Linux", | |
"os": "ubuntu-latest", | |
"container": { "image": "ghcr.io/dnkpp/gcc:14" }, | |
"compiler_name": "gcc", | |
"compiler_version": 14, | |
"architecture": "x64", | |
"libcxx": false, | |
"asan": true | |
}, | |
{ | |
"prefix": "Linux", | |
"os": "ubuntu-latest", | |
"container": { "image": "ghcr.io/dnkpp/gcc:13" }, | |
"compiler_name": "gcc", | |
"compiler_version": 13, | |
"architecture": "x64", | |
"libcxx": false, | |
"asan": true | |
}, | |
{ | |
"prefix": "Linux", | |
"os": "ubuntu-latest", | |
"container": { "image": "ghcr.io/dnkpp/gcc:12" }, | |
"compiler_name": "gcc", | |
"compiler_version": 12, | |
"architecture": "x64", | |
"libcxx": false, | |
"asan": true | |
}, | |
{ | |
"prefix": "Linux", | |
"os": "ubuntu-latest", | |
"container": { "image": "ghcr.io/dnkpp/gcc:14" }, | |
"compiler_name": "gcc", | |
"compiler_version": 14, | |
"architecture": "32bit", | |
"libcxx": false, | |
"asan": true | |
}, | |
{ | |
"prefix": "Windows 2022", | |
"os": "windows-2022", | |
"compiler_name": "msvc", | |
"compiler_version": "v143", | |
"cmake_generator": "Visual Studio 17 2022", | |
"architecture": "x64" | |
}, | |
{ | |
"prefix": "Windows 2022", | |
"os": "windows-2022", | |
"compiler_name": "msvc", | |
"compiler_version": "v143", | |
"cmake_generator": "Visual Studio 17 2022", | |
"architecture": "x64", | |
"default_call_convention": "vectorcall" | |
}, | |
{ | |
"prefix": "Windows 2022", | |
"os": "windows-2022", | |
"compiler_name": "msvc", | |
"compiler_version": "ClangCl", | |
"cmake_generator": "Visual Studio 17 2022", | |
"architecture": "x64" | |
}, | |
{ | |
"prefix": "Windows 2022", | |
"os": "windows-2022", | |
"compiler_name": "msvc", | |
"compiler_version": "v143", | |
"cmake_generator": "Visual Studio 17 2022", | |
"architecture": "Win32" | |
}, | |
{ | |
"prefix": "Windows 2022", | |
"os": "windows-2022", | |
"compiler_name": "msvc", | |
"compiler_version": "v143", | |
"cmake_generator": "Visual Studio 17 2022", | |
"architecture": "Win32", | |
"default_call_convention": "vectorcall" | |
}, | |
{ | |
"prefix": "Windows 2022", | |
"os": "windows-2022", | |
"compiler_name": "msvc", | |
"compiler_version": "ClangCl", | |
"cmake_generator": "Visual Studio 17 2022", | |
"architecture": "Win32" | |
}, | |
{ | |
"prefix": "macOS", | |
"os": "macos-latest", | |
"compiler_name": "AppleClang", | |
"compiler_version": 18, | |
"architecture": "x64", | |
"ldflags_workaround": "-L/opt/homebrew/opt/llvm/lib/c++ -L/opt/homebrew/opt/llvm/lib/unwind -lunwind", | |
"asan": true | |
}, | |
{ | |
"prefix": "macOS", | |
"os": "macos-latest", | |
"compiler_name": "AppleClang", | |
"compiler_version": 17, | |
"architecture": "x64", | |
"ldflags_workaround": "-L/opt/homebrew/opt/llvm@17/lib/c++ -Wl,-rpath,/opt/homebrew/opt/llvm@17/lib/c++", | |
"asan": true | |
}, | |
{ | |
"prefix": "macOS", | |
"os": "macos-latest", | |
"compiler_name": "AppleClang", | |
"compiler_version": 16, | |
"architecture": "x64", | |
"ldflags_workaround": "-L/opt/homebrew/opt/llvm@16/lib/c++ -Wl,-rpath,/opt/homebrew/opt/llvm@16/lib/c++", | |
"asan": true | |
} | |
] | |
outputs: | |
config: ${{ steps.output-config.outputs.config }} | |
build_modes: ${{ steps.output-options.outputs.build_modes }} | |
cxx_versions: ${{ steps.output-options.outputs.cxx_versions }} | |
steps: | |
- name: Output configs | |
id: output-config | |
shell: bash | |
run: | | |
# seems to convert that to a single-line json and thus please the output step | |
# wrap in single '! | |
OUTPUT='${{ env.config }}' | |
echo "config=$(echo $OUTPUT)" >> "$GITHUB_OUTPUT" | |
# enables debug-mode and c++20 for all cases | |
- name: Enable base matrix | |
shell: bash | |
run: | | |
echo "BUILD_MODES=\"Debug\"" >> $GITHUB_ENV | |
echo "CXX_VERSIONS=20" >> $GITHUB_ENV | |
# if its a PR from development or the main branch in general, add release-mode and c++23 | |
- name: Enable extended matrix | |
if: ${{ | |
(github.event_name == 'pull_request' && github.head_ref == 'development') | |
|| github.ref_name == 'main' | |
}} | |
shell: bash | |
run: | | |
echo "BUILD_MODES=$(echo $BUILD_MODES, \"Release\")" >> $GITHUB_ENV | |
echo "CXX_VERSIONS=$(echo $CXX_VERSIONS, 23)" >> $GITHUB_ENV | |
- name: Output build-modes and c++-versions | |
id: output-options | |
shell: bash | |
run: | | |
echo "build_modes=$(echo [ $BUILD_MODES ])" >> "$GITHUB_OUTPUT" | |
echo "cxx_versions=$(echo [ $CXX_VERSIONS ])" >> "$GITHUB_OUTPUT" | |
############ | |
# | |
# Runs all general unit tests and examples, without any adapter tests. | |
# They are excluded, because the dependency fetching and building increased the build times quite heavily, | |
# which does not scale properly. | |
# | |
# Runs all tests on every machine with | |
# - debug and release | |
# - c++20 and c++23 | |
# - std- and fmt-formatting backend | |
# | |
##### | |
run-unit-tests: | |
needs: define-matrix | |
name: | | |
[UT] | |
${{ matrix.config.prefix }} | |
${{ matrix.config.compiler_name }}-${{ matrix.config.compiler_version }} | |
${{ matrix.config.suffix }} | |
(C++${{ matrix.cxx_standard }}, | |
${{ matrix.build_mode }}, | |
${{ matrix.config.architecture }}, | |
${{ matrix.format_backend }}, | |
${{ matrix.str_matcher }}, | |
EXTRA={ ${{ matrix.config.default_call_convention }} }) | |
runs-on: ${{ matrix.config.os }} | |
container: ${{ matrix.config.container }} | |
strategy: | |
fail-fast: false | |
matrix: | |
format_backend: [ std, fmt ] | |
str_matcher: [ char, unicode ] | |
build_mode: ${{ fromJSON(needs.define-matrix.outputs.build_modes) }} | |
cxx_standard: ${{ fromJSON(needs.define-matrix.outputs.cxx_versions) }} | |
config: ${{ fromJSON(needs.define-matrix.outputs.config) }} | |
exclude: | |
# all listed compilers do not support std's format header | |
- format_backend: "std" | |
config: | |
compiler_name: "clang" | |
compiler_version: 16 | |
- format_backend: "std" | |
config: | |
compiler_name: "gcc" | |
compiler_version: 12 | |
- format_backend: "std" | |
config: | |
compiler_name: "AppleClang" | |
compiler_version: 16 | |
# The format_backend and str_matcher options are rather orthogonal. | |
# To see, whether support both str_matcher variants, let's use the fmt backend, | |
# as this is supported by all compilers. | |
- format_backend: "std" | |
str_matcher: "unicode" | |
# disable several combinations with vectorcall | |
- str_matcher: "unicode" | |
config: | |
default_call_convention: "vectorcall" | |
- format_backend: "fmt" | |
config: | |
default_call_convention: "vectorcall" | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup macOS | |
if: startsWith(matrix.config.os, 'macOS') | |
shell: bash | |
run: | | |
env brew install ninja llvm | |
LLVM_NAME=llvm@${{ matrix.config.compiler_version }} | |
env brew install $LLVM_NAME | |
LLVM_PATH="$(brew --prefix $LLVM_NAME)" | |
echo "CC=$(echo $LLVM_PATH/bin/clang)" >> $GITHUB_ENV | |
echo "CXX=$(echo $LLVM_PATH/bin/clang++)" >> $GITHUB_ENV | |
# solves this issue: https://github.com/Homebrew/homebrew-core/issues/178435 | |
echo "LDFLAGS=$(echo $LDFLAGS ${{ matrix.config.ldflags_workaround }})" >> $GITHUB_ENV | |
echo "CMAKE_CONFIG_EXTRA=$(echo $CMAKE_CONFIG_EXTRA -DCMAKE_BUILD_TYPE=${{ matrix.build_mode }})" >> $GITHUB_ENV | |
- name: Clang libc++ setup | |
if: ${{ matrix.config.compiler_name == 'clang' && matrix.config.libcxx == true }} | |
shell: bash | |
run: | | |
echo "CXXFLAGS=$(echo $CXXFLAGS -stdlib=libc++)" >> $GITHUB_ENV | |
echo "LDFLAGS=$(echo $LDFLAGS -lc++abi)" >> $GITHUB_ENV | |
- name: Setup linux | |
if: ${{ matrix.config.prefix == 'Linux' }} | |
shell: bash | |
run: | | |
echo "CMAKE_CONFIG_EXTRA=$(echo $CMAKE_CONFIG_EXTRA -DCMAKE_BUILD_TYPE=${{ matrix.build_mode }})" >> $GITHUB_ENV | |
- name: Setup linux 32bit builds | |
if: ${{ matrix.config.prefix == 'Linux' && matrix.config.architecture == '32bit' }} | |
shell: bash | |
run: | | |
apt-get install -y gcc-${{ matrix.config.compiler_version }}-multilib g++-${{ matrix.config.compiler_version }}-multilib | |
echo "CXXFLAGS=$(echo $CXXFLAGS -m32)" >> $GITHUB_ENV | |
echo "CFLAGS=$(echo $CFLAGS -m32)" >> $GITHUB_ENV | |
echo "LDFLAGS=$(echo $LDFLAGS -m32)" >> $GITHUB_ENV | |
- name: Setup msvc | |
if: ${{ matrix.config.compiler_name == 'msvc' }} | |
shell: bash | |
run: | | |
echo "CMAKE_CONFIG_EXTRA=$(echo $CMAKE_CONFIG_EXTRA -G\"${{ matrix.config.cmake_generator }}\" -T\"${{ matrix.config.compiler_version }}\" -A\"${{ matrix.config.architecture }}\")" >> $GITHUB_ENV | |
echo "CMAKE_BUILD_EXTRA=$(echo $CMAKE_BUILD_EXTRA --config ${{ matrix.build_mode }})" >> $GITHUB_ENV | |
- name: Setup __vectorcall as default call-convention on msvc | |
if: ${{ matrix.config.compiler_name == 'msvc' && matrix.config.default_call_convention == 'vectorcall' }} | |
shell: bash | |
# Do NOT remove the double /, as this will cause trouble during cmake configuration (it somehow expands to C:/Program Files/Git/Gv ???!) | |
# But, we will probably run into another issue, when CXXFLAGS happens to be not empty... | |
run: | | |
echo "CXXFLAGS=$(echo ${CXXFLAGS} //Gv)" >> $GITHUB_ENV | |
- name: Enable Address and Undefined Sanitizer | |
if: ${{ matrix.config.asan == true }} | |
shell: bash | |
run: | | |
echo "CMAKE_CONFIG_EXTRA=$(echo $CMAKE_CONFIG_EXTRA -DSANITIZE_ADDRESS=YES -DSANITIZE_UNDEFINED=YES)" >> $GITHUB_ENV | |
- name: Setup fmt as formatting backend | |
if: startsWith(matrix.format_backend, 'fmt') | |
shell: bash | |
run: | | |
echo "CMAKE_CONFIG_EXTRA=$(echo $CMAKE_CONFIG_EXTRA -DMIMICPP_CONFIG_USE_FMT=YES)" >> $GITHUB_ENV | |
- name: Enable unicode support for string matchers | |
if: startsWith(matrix.str_matcher, 'unicode') | |
shell: bash | |
run: | | |
echo "CMAKE_CONFIG_EXTRA=$(echo $CMAKE_CONFIG_EXTRA -DMIMICPP_CONFIG_EXPERIMENTAL_UNICODE_STR_MATCHER=YES)" >> $GITHUB_ENV | |
# ASan has some serious trouble with libc++ exception mechanism | |
# see: https://github.com/llvm/llvm-project/issues/59432 | |
- name: Disable alloc_dealloc_mismatch detection with libc++ | |
if: ${{ matrix.config.asan == true && matrix.config.libcxx == true}} | |
shell: bash | |
run: | | |
echo "ASAN_OPTIONS=$(echo $ASAN_OPTIONS:alloc_dealloc_mismatch=0)" >> $GITHUB_ENV | |
# std::stacktrace is not supported on c++20. | |
# cpptrace has issues with alternative default call convention | |
# see: https://github.com/jeremy-rifkin/cpptrace/issues/197 | |
- name: Enable cpptrace if c++20 | |
if: ${{ matrix.cxx_standard == 20 && matrix.config.default_call_convention != 'vectorcall' }} | |
shell: bash | |
run: | | |
echo "CMAKE_CONFIG_EXTRA=$(echo $CMAKE_CONFIG_EXTRA -DMIMICPP_CONFIG_EXPERIMENTAL_USE_CPPTRACE=YES)" >> $GITHUB_ENV | |
- name: Configure | |
shell: bash | |
run: | | |
cmake \ | |
-S . \ | |
-B build \ | |
--log-level=DEBUG \ | |
-D CMAKE_VERBOSE_MAKEFILE=YES \ | |
-D MIMICPP_FORCED_CXX_STANDARD="${{ matrix.cxx_standard }}" \ | |
-D MIMICPP_CONFIG_EXPERIMENTAL_STACKTRACE=YES \ | |
${{ env.CMAKE_CONFIG_EXTRA }} | |
- name: Build | |
shell: bash | |
run: | | |
cmake --build build \ | |
-j5 \ | |
${{ env.CMAKE_BUILD_EXTRA }} | |
- name: Run tests | |
shell: bash | |
env: | |
CTEST_OUTPUT_ON_FAILURE: 1 | |
run: | | |
ctest --test-dir build/test/unit-tests \ | |
-C ${{ matrix.build_mode }} \ | |
-j5 | |
- name: Run custom-stacktrace-tests | |
shell: bash | |
env: | |
CTEST_OUTPUT_ON_FAILURE: 1 | |
run: | | |
ctest --test-dir build/test/custom-stacktrace-tests \ | |
-C ${{ matrix.build_mode }} | |
- name: Run examples | |
shell: bash | |
env: | |
CTEST_OUTPUT_ON_FAILURE: 1 | |
run: | | |
ctest --test-dir build/examples \ | |
-C ${{ matrix.build_mode }} \ | |
-j5 | |
############ | |
# | |
# Runs the adapter test on every machine. | |
# | |
##### | |
run-adapter-tests: | |
needs: define-matrix | |
name: | | |
[AT] | |
${{ matrix.config.prefix }} | |
${{ matrix.config.compiler_name }}-${{ matrix.config.compiler_version }} | |
${{ matrix.config.suffix }} | |
(C++${{ matrix.cxx_standard }}, | |
${{ matrix.build_mode }}, | |
${{ matrix.config.architecture }}) | |
runs-on: ${{ matrix.config.os }} | |
container: ${{ matrix.config.container }} | |
strategy: | |
fail-fast: false | |
matrix: | |
build_mode: ${{ fromJSON(needs.define-matrix.outputs.build_modes) }} | |
cxx_standard: ${{ fromJSON(needs.define-matrix.outputs.cxx_versions) }} | |
config: ${{ fromJSON(needs.define-matrix.outputs.config) }} | |
exclude: | |
# call-conventions are not relevant to the adapter tests | |
- config: | |
compiler_name: "msvc" | |
default_call_convention: "vectorcall" | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup macOS | |
if: startsWith(matrix.config.os, 'macOS') | |
shell: bash | |
run: | | |
env brew install ninja llvm | |
LLVM_NAME=llvm@${{ matrix.config.compiler_version }} | |
env brew install $LLVM_NAME | |
LLVM_PATH="$(brew --prefix $LLVM_NAME)" | |
echo "CC=$(echo $LLVM_PATH/bin/clang)" >> $GITHUB_ENV | |
echo "CXX=$(echo $LLVM_PATH/bin/clang++)" >> $GITHUB_ENV | |
echo "LDFLAGS=$(echo $LDFLAGS ${{ matrix.config.ldflags_workaround }})" >> $GITHUB_ENV | |
echo "CMAKE_CONFIG_EXTRA=$(echo $CMAKE_CONFIG_EXTRA -DCMAKE_BUILD_TYPE=${{ matrix.build_mode }})" >> $GITHUB_ENV | |
- name: Clang libc++ setup | |
if: ${{ matrix.config.compiler_name == 'clang' && matrix.config.libcxx == true }} | |
shell: bash | |
run: | | |
echo "CXXFLAGS=$(echo $CXXFLAGS -stdlib=libc++)" >> $GITHUB_ENV | |
echo "LDFLAGS=$(echo $LDFLAGS -lc++abi)" >> $GITHUB_ENV | |
- name: Setup linux | |
if: ${{ matrix.config.prefix == 'Linux' }} | |
shell: bash | |
run: | | |
echo "CMAKE_CONFIG_EXTRA=$(echo $CMAKE_CONFIG_EXTRA -DCMAKE_BUILD_TYPE=${{ matrix.build_mode }})" >> $GITHUB_ENV | |
- name: Setup linux 32bit builds | |
if: ${{ matrix.config.prefix == 'Linux' && matrix.config.architecture == '32bit' }} | |
shell: bash | |
run: | | |
apt-get install -y gcc-${{ matrix.config.compiler_version }}-multilib g++-${{ matrix.config.compiler_version }}-multilib | |
echo "CXXFLAGS=$(echo $CXXFLAGS -m32)" >> $GITHUB_ENV | |
echo "CFLAGS=$(echo $CFLAGS -m32)" >> $GITHUB_ENV | |
echo "LDFLAGS=$(echo $LDFLAGS -m32)" >> $GITHUB_ENV | |
- name: Setup msvc | |
if: ${{ matrix.config.compiler_name == 'msvc' }} | |
shell: bash | |
run: | | |
echo "CMAKE_CONFIG_EXTRA=$(echo $CMAKE_CONFIG_EXTRA -G\"${{ matrix.config.cmake_generator }}\" -T\"${{ matrix.config.compiler_version }}\" -A\"${{ matrix.config.architecture }}\")" >> $GITHUB_ENV | |
echo "CMAKE_BUILD_EXTRA=$(echo $CMAKE_BUILD_EXTRA --config ${{ matrix.build_mode }})" >> $GITHUB_ENV | |
# This is enabled by default, because that's the only formatting-backend which is supported by every compiler. | |
- name: Setup fmt as formatting backend | |
shell: bash | |
run: | | |
echo "CMAKE_CONFIG_EXTRA=$(echo $CMAKE_CONFIG_EXTRA -DMIMICPP_CONFIG_USE_FMT=YES)" >> $GITHUB_ENV | |
- name: Configure | |
shell: bash | |
run: | | |
cmake \ | |
-S . \ | |
-B build \ | |
--log-level=DEBUG \ | |
-D CMAKE_VERBOSE_MAKEFILE=YES \ | |
-D MIMICPP_FORCED_CXX_STANDARD="${{ matrix.cxx_standard }}" \ | |
-D MIMICPP_ENABLE_ADAPTER_TESTS=YES \ | |
-D MIMICPP_CONFIG_EXPERIMENTAL_CATCH2_MATCHER_INTEGRATION=YES \ | |
${{ env.CMAKE_CONFIG_EXTRA }} | |
- name: Build | |
shell: bash | |
run: | | |
cmake --build build \ | |
-j5 \ | |
${{ env.CMAKE_BUILD_EXTRA }} | |
- name: Run adapter tests | |
shell: bash | |
env: | |
CTEST_OUTPUT_ON_FAILURE: 1 | |
run: | | |
ctest --test-dir build/test/adapter-tests \ | |
-C ${{ matrix.build_mode }} \ | |
-j5 |