Add address and UB sanitizer tests #104
Workflow file for this run
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
| name: skyr-url CI | |
| # Trigger on pushes to all branches and for all pull-requests | |
| on: [ push, pull_request ] | |
| env: | |
| CMAKE_VERSION: 3.21.7 | |
| NINJA_VERSION: 1.11.0 | |
| jobs: | |
| build: | |
| name: ${{ matrix.config.name }} | |
| runs-on: ${{ matrix.config.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| config: | |
| # GCC-13 (C++23) | |
| - { | |
| name: "Linux GCC 13 Debug (C++23)", artifact: "Linux.tar.xz", | |
| os: ubuntu-24.04, | |
| build_type: Debug, | |
| cc: "gcc-13", cxx: "g++-13", | |
| cxx_standard: 23 | |
| } | |
| - { | |
| name: "Linux GCC 13 Release (C++23)", artifact: "Linux.tar.xz", | |
| os: ubuntu-24.04, | |
| build_type: RelWithDebInfo, | |
| cc: "gcc-13", cxx: "g++-13", | |
| cxx_standard: 23 | |
| } | |
| # GCC-14 (C++23) | |
| - { | |
| name: "Linux GCC 14 Debug (C++23)", artifact: "Linux.tar.xz", | |
| os: ubuntu-24.04, | |
| build_type: Debug, | |
| cc: "gcc-14", cxx: "g++-14", | |
| cxx_standard: 23 | |
| } | |
| - { | |
| name: "Linux GCC 14 Release (C++23)", artifact: "Linux.tar.xz", | |
| os: ubuntu-24.04, | |
| build_type: RelWithDebInfo, | |
| cc: "gcc-14", cxx: "g++-14", | |
| cxx_standard: 23 | |
| } | |
| # Clang-18 (C++23) | |
| - { | |
| name: "Linux Clang 18 Debug (C++23)", artifact: "Linux.tar.xz", | |
| os: ubuntu-24.04, | |
| build_type: Debug, | |
| cc: "clang-18", cxx: "clang++-18", | |
| cxx_standard: 23 | |
| } | |
| - { | |
| name: "Linux Clang 18 Release (C++23)", artifact: "Linux.tar.xz", | |
| os: ubuntu-24.04, | |
| build_type: RelWithDebInfo, | |
| cc: "clang-18", cxx: "clang++-18", | |
| cxx_standard: 23 | |
| } | |
| # Clang-19 (C++23) | |
| - { | |
| name: "Linux Clang 19 Debug (C++23)", artifact: "Linux.tar.xz", | |
| os: ubuntu-24.04, | |
| build_type: Debug, | |
| cc: "clang-19", cxx: "clang++-19", | |
| cxx_standard: 23 | |
| } | |
| - { | |
| name: "Linux Clang 19 Release (C++23)", artifact: "Linux.tar.xz", | |
| os: ubuntu-24.04, | |
| build_type: RelWithDebInfo, | |
| cc: "clang-19", cxx: "clang++-19", | |
| cxx_standard: 23 | |
| } | |
| # Clang-20 (C++23) | |
| - { | |
| name: "Linux Clang 20 Debug (C++23)", artifact: "Linux.tar.xz", | |
| os: ubuntu-24.04, | |
| build_type: Debug, | |
| cc: "clang-20", cxx: "clang++-20", | |
| cxx_standard: 23 | |
| } | |
| - { | |
| name: "Linux Clang 20 Release (C++23)", artifact: "Linux.tar.xz", | |
| os: ubuntu-24.04, | |
| build_type: RelWithDebInfo, | |
| cc: "clang-20", cxx: "clang++-20", | |
| cxx_standard: 23 | |
| } | |
| # Clang-21 (C++23) | |
| - { | |
| name: "Linux Clang 21 Debug (C++23)", artifact: "Linux.tar.xz", | |
| os: ubuntu-24.04, | |
| build_type: Debug, | |
| cc: "clang-21", cxx: "clang++-21", | |
| cxx_standard: 23 | |
| } | |
| - { | |
| name: "Linux Clang 21 Release (C++23)", artifact: "Linux.tar.xz", | |
| os: ubuntu-24.04, | |
| build_type: RelWithDebInfo, | |
| cc: "clang-21", cxx: "clang++-21", | |
| cxx_standard: 23 | |
| } | |
| # macOS Clang-18 (C++23) | |
| - { | |
| name: "macOS Clang 18 Debug (C++23)", artifact: "macOS.tar.xz", | |
| os: macos-latest, | |
| build_type: Debug, | |
| cc: "clang-18", cxx: "clang++-18", | |
| cxx_standard: 23 | |
| } | |
| - { | |
| name: "macOS Clang 18 Release (C++23)", artifact: "macOS.tar.xz", | |
| os: macos-latest, | |
| build_type: RelWithDebInfo, | |
| cc: "clang-18", cxx: "clang++-18", | |
| cxx_standard: 23 | |
| } | |
| # macOS Clang-19 (C++23) | |
| - { | |
| name: "macOS Clang 19 Debug (C++23)", artifact: "macOS.tar.xz", | |
| os: macos-latest, | |
| build_type: Debug, | |
| cc: "clang-19", cxx: "clang++-19", | |
| cxx_standard: 23 | |
| } | |
| - { | |
| name: "macOS Clang 19 Release (C++23)", artifact: "macOS.tar.xz", | |
| os: macos-latest, | |
| build_type: RelWithDebInfo, | |
| cc: "clang-19", cxx: "clang++-19", | |
| cxx_standard: 23 | |
| } | |
| # macOS Clang-20 (C++23) | |
| - { | |
| name: "macOS Clang 20 Debug (C++23)", artifact: "macOS.tar.xz", | |
| os: macos-latest, | |
| build_type: Debug, | |
| cc: "clang-20", cxx: "clang++-20", | |
| cxx_standard: 23 | |
| } | |
| - { | |
| name: "macOS Clang 20 Release (C++23)", artifact: "macOS.tar.xz", | |
| os: macos-latest, | |
| build_type: RelWithDebInfo, | |
| cc: "clang-20", cxx: "clang++-20", | |
| cxx_standard: 23 | |
| } | |
| # macOS Clang-21 (C++23) | |
| - { | |
| name: "macOS Clang 21 Debug (C++23)", artifact: "macOS.tar.xz", | |
| os: macos-latest, | |
| build_type: Debug, | |
| cc: "clang-21", cxx: "clang++-21", | |
| cxx_standard: 23 | |
| } | |
| - { | |
| name: "macOS Clang 21 Release (C++23)", artifact: "macOS.tar.xz", | |
| os: macos-latest, | |
| build_type: RelWithDebInfo, | |
| cc: "clang-21", cxx: "clang++-21", | |
| cxx_standard: 23 | |
| } | |
| # MSVC 2022 (Visual Studio 2022, C++23) | |
| - { | |
| name: "Windows MSVC 2022 Debug (C++23)", artifact: "Windows-MSVC.tar.xz", | |
| os: windows-latest, | |
| build_type: Debug, | |
| cc: "cl", cxx: "cl", | |
| environment_script: "C:/Program Files (x86)/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvars64.bat", | |
| cxx_standard: 23 | |
| } | |
| - { | |
| name: "Windows MSVC 2022 Release (C++23)", artifact: "Windows-MSVC.tar.xz", | |
| os: windows-latest, | |
| build_type: RelWithDebInfo, | |
| cc: "cl", cxx: "cl", | |
| environment_script: "C:/Program Files (x86)/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvars64.bat", | |
| cxx_standard: 23 | |
| } | |
| # MSVC 2026 (Visual Studio 2026, C++23) | |
| - { | |
| name: "Windows MSVC 2026 Debug (C++23)", artifact: "Windows-MSVC.tar.xz", | |
| os: windows-latest, | |
| build_type: Debug, | |
| cc: "cl", cxx: "cl", | |
| environment_script: "C:/Program Files/Microsoft Visual Studio/2026/Enterprise/VC/Auxiliary/Build/vcvars64.bat", | |
| cxx_standard: 23 | |
| } | |
| - { | |
| name: "Windows MSVC 2026 Release (C++23)", artifact: "Windows-MSVC.tar.xz", | |
| os: windows-latest, | |
| build_type: RelWithDebInfo, | |
| cc: "cl", cxx: "cl", | |
| environment_script: "C:/Program Files/Microsoft Visual Studio/2026/Enterprise/VC/Auxiliary/Build/vcvars64.bat", | |
| cxx_standard: 23 | |
| } | |
| steps: | |
| - uses: actions/checkout@master | |
| - uses: seanmiddleditch/gha-setup-vsdevenv@master | |
| - name: Download Ninja and CMake | |
| id: cmake_and_ninja | |
| shell: cmake -P {0} | |
| run: | | |
| set(cmake_version $ENV{CMAKE_VERSION}) | |
| set(ninja_version $ENV{NINJA_VERSION}) | |
| message(STATUS "Using host CMake version: ${CMAKE_VERSION}") | |
| if ("${{ runner.os }}" STREQUAL "Windows") | |
| set(ninja_suffix "win.zip") | |
| set(cmake_suffix "windows-x86_64.zip") | |
| set(cmake_dir "cmake-${cmake_version}-windows-x86_64/bin") | |
| elseif ("${{ runner.os }}" STREQUAL "Linux") | |
| set(ninja_suffix "linux.zip") | |
| set(cmake_suffix "linux-x86_64.tar.gz") | |
| set(cmake_dir "cmake-${cmake_version}-linux-x86_64/bin") | |
| elseif ("${{ runner.os }}" STREQUAL "macOS") | |
| set(ninja_suffix "mac.zip") | |
| set(cmake_suffix "macos10.10-universal.tar.gz") | |
| set(cmake_dir "cmake-${cmake_version}-macos10.10-universal/CMake.app/Contents/bin") | |
| endif() | |
| set(ninja_url "https://github.com/ninja-build/ninja/releases/download/v${ninja_version}/ninja-${ninja_suffix}") | |
| file(DOWNLOAD "${ninja_url}" ./ninja.zip SHOW_PROGRESS) | |
| execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvf ./ninja.zip) | |
| set(cmake_url "https://github.com/Kitware/CMake/releases/download/v${cmake_version}/cmake-${cmake_version}-${cmake_suffix}") | |
| file(DOWNLOAD "${cmake_url}" ./cmake.zip SHOW_PROGRESS) | |
| execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvf ./cmake.zip) | |
| # Save the path for other steps | |
| file(TO_CMAKE_PATH "$ENV{GITHUB_WORKSPACE}/${cmake_dir}" cmake_dir) | |
| message("::set-output name=cmake_dir::${cmake_dir}") | |
| execute_process( | |
| COMMAND chmod +x ninja | |
| COMMAND chmod +x ${cmake_dir}/cmake | |
| ) | |
| # GCC 13-14 and Clang 18 are pre-installed on ubuntu-24.04 | |
| # Clang 19-21 need to be installed from LLVM repository | |
| - name: Install Clang and libc++ (C++23 support) | |
| id: install_clang | |
| if: startsWith(matrix.config.os, 'ubuntu') && contains(matrix.config.cxx, 'clang++') | |
| shell: bash | |
| run: | | |
| # Extract version number from compiler name (e.g., clang++-19 -> 19) | |
| CLANG_VERSION=$(echo "${{ matrix.config.cxx }}" | grep -oP '\d+') | |
| # Add LLVM repository for newer versions | |
| if [[ "$CLANG_VERSION" != "18" ]]; then | |
| wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc | |
| sudo add-apt-repository -y "deb http://apt.llvm.org/noble/ llvm-toolchain-noble-${CLANG_VERSION} main" | |
| fi | |
| sudo apt-get update | |
| # Install Clang and libc++ for the specific version | |
| sudo apt-get -y install \ | |
| clang-${CLANG_VERSION} \ | |
| libc++-${CLANG_VERSION}-dev \ | |
| libc++abi-${CLANG_VERSION}-dev | |
| - name: Install vcpkg (Linux) | |
| id: vcpkg_linux | |
| if: startsWith(matrix.config.os, 'ubuntu') | |
| shell: bash | |
| run: | | |
| mkdir -p ${GITHUB_WORKSPACE}/vcpkg | |
| cd ${GITHUB_WORKSPACE}/vcpkg | |
| git init | |
| git remote add origin https://github.com/microsoft/vcpkg.git | |
| git fetch origin master | |
| git checkout -b master origin/master | |
| export | |
| ./bootstrap-vcpkg.sh | |
| # For Clang builds, use custom triplet with libc++ and set compiler | |
| if [[ "${{ matrix.config.cxx }}" == clang++* ]]; then | |
| export CC=${{ matrix.config.cc }} | |
| export CXX=${{ matrix.config.cxx }} | |
| ./vcpkg install catch2 uni-algo nlohmann-json \ | |
| --triplet x64-linux-libcxx \ | |
| --overlay-triplets=${GITHUB_WORKSPACE}/cmake/vcpkg-triplets | |
| else | |
| ./vcpkg install catch2 uni-algo nlohmann-json | |
| fi | |
| - name: Install LLVM Clang on macOS | |
| id: install_clang_macos | |
| if: startsWith(matrix.config.os, 'macos') && contains(matrix.config.cxx, 'clang++') | |
| shell: bash | |
| run: | | |
| # Extract version number from compiler name (e.g., clang++-19 -> 19) | |
| CLANG_VERSION=$(echo "${{ matrix.config.cxx }}" | grep -oE '[0-9]+') | |
| # Install LLVM from Homebrew | |
| brew install llvm@${CLANG_VERSION} | |
| # Create symlinks for versioned clang binaries | |
| LLVM_PREFIX=$(brew --prefix llvm@${CLANG_VERSION}) | |
| sudo ln -sf ${LLVM_PREFIX}/bin/clang /usr/local/bin/clang-${CLANG_VERSION} | |
| sudo ln -sf ${LLVM_PREFIX}/bin/clang++ /usr/local/bin/clang++-${CLANG_VERSION} | |
| # Add LLVM to PATH for this build | |
| echo "${LLVM_PREFIX}/bin" >> $GITHUB_PATH | |
| - name: Install vcpkg (MacOS) | |
| id: vcpkg_macos | |
| if: startsWith(matrix.config.os, 'macos') | |
| shell: bash | |
| run: | | |
| brew install pkg-config | |
| mkdir -p ${GITHUB_WORKSPACE}/vcpkg | |
| cd ${GITHUB_WORKSPACE}/vcpkg | |
| git init | |
| git remote add origin https://github.com/microsoft/vcpkg.git | |
| git fetch origin master | |
| git checkout -b master origin/master | |
| export | |
| ./bootstrap-vcpkg.sh | |
| ./vcpkg install catch2 uni-algo nlohmann-json | |
| - name: Install vcpkg (Windows) | |
| id: vcpkg_windows | |
| if: startsWith(matrix.config.os, 'windows') | |
| shell: powershell | |
| run: | | |
| git clone https://github.com/microsoft/vcpkg.git ${Env:GITHUB_WORKSPACE}\vcpkg | |
| cd ${Env:GITHUB_WORKSPACE}\vcpkg | |
| .\bootstrap-vcpkg.bat | |
| vcpkg install catch2 uni-algo nlohmann-json --triplet x64-windows | |
| - name: Configure | |
| shell: cmake -P {0} | |
| working-directory: ${{ env.HOME }} | |
| run: | | |
| set(ENV{CC} ${{ matrix.config.cc }}) | |
| set(ENV{CXX} ${{ matrix.config.cxx }}) | |
| if ("${{ runner.os }}" STREQUAL "Windows" AND NOT "x${{ matrix.config.environment_script }}" STREQUAL "x") | |
| execute_process( | |
| COMMAND "${{ matrix.config.environment_script }}" && set | |
| OUTPUT_FILE environment_script_output.txt | |
| ) | |
| set(cxx_flags "/permissive- /EHsc") | |
| file(STRINGS environment_script_output.txt output_lines) | |
| foreach(line IN LISTS output_lines) | |
| if (line MATCHES "^([a-zA-Z0-9_-]+)=(.*)$") | |
| set(ENV{${CMAKE_MATCH_1}} "${CMAKE_MATCH_2}") | |
| endif() | |
| endforeach() | |
| endif() | |
| set(path_separator ":") | |
| if ("${{ runner.os }}" STREQUAL "Windows") | |
| set(path_separator ";") | |
| endif() | |
| set(ENV{PATH} "$ENV{GITHUB_WORKSPACE}${path_separator}$ENV{PATH}") | |
| # Use libc++ for Linux Clang builds (needed for std::expected in C++23) | |
| # vcpkg is configured to build with libc++ for Clang as well | |
| set(USE_LLVM OFF) | |
| set(VCPKG_TARGET_TRIPLET "") | |
| set(VCPKG_OVERLAY_TRIPLETS_ARG "") | |
| if ("${{ runner.os }}" STREQUAL "Linux" AND "${{ matrix.config.cxx }}" MATCHES "clang") | |
| set(USE_LLVM ON) | |
| set(VCPKG_TARGET_TRIPLET "x64-linux-libcxx") | |
| set(VCPKG_OVERLAY_TRIPLETS_ARG "-D VCPKG_OVERLAY_TRIPLETS=$ENV{GITHUB_WORKSPACE}/cmake/vcpkg-triplets") | |
| endif() | |
| if (VCPKG_TARGET_TRIPLET) | |
| execute_process( | |
| COMMAND ${{ steps.cmake_and_ninja.outputs.cmake_dir }}/cmake | |
| -S . | |
| -B build | |
| -G Ninja | |
| -D CMAKE_CXX_STANDARD:STRING=${{ matrix.config.cxx_standard }} | |
| -D skyr_WARNINGS_AS_ERRORS=OFF | |
| -D skyr_BUILD_TESTS=ON | |
| -D skyr_BUILD_DOCS=OFF | |
| -D skyr_BUILD_EXAMPLES=OFF | |
| -D skyr_BUILD_WITH_LLVM_LIBCXX=${USE_LLVM} | |
| -D CMAKE_BUILD_TYPE=${{ matrix.config.build_type }} | |
| -D CMAKE_INSTALL_PREFIX=$ENV{GITHUB_WORKSPACE}/install | |
| -D CMAKE_TOOLCHAIN_FILE=$ENV{GITHUB_WORKSPACE}/vcpkg/scripts/buildsystems/vcpkg.cmake | |
| -D VCPKG_TARGET_TRIPLET=${VCPKG_TARGET_TRIPLET} | |
| ${VCPKG_OVERLAY_TRIPLETS_ARG} | |
| RESULT_VARIABLE result | |
| ) | |
| else() | |
| execute_process( | |
| COMMAND ${{ steps.cmake_and_ninja.outputs.cmake_dir }}/cmake | |
| -S . | |
| -B build | |
| -G Ninja | |
| -D CMAKE_CXX_STANDARD:STRING=${{ matrix.config.cxx_standard }} | |
| -D skyr_WARNINGS_AS_ERRORS=OFF | |
| -D skyr_BUILD_TESTS=ON | |
| -D skyr_BUILD_DOCS=OFF | |
| -D skyr_BUILD_EXAMPLES=OFF | |
| -D skyr_BUILD_WITH_LLVM_LIBCXX=${USE_LLVM} | |
| -D CMAKE_BUILD_TYPE=${{ matrix.config.build_type }} | |
| -D CMAKE_INSTALL_PREFIX=$ENV{GITHUB_WORKSPACE}/install | |
| -D CMAKE_TOOLCHAIN_FILE=$ENV{GITHUB_WORKSPACE}/vcpkg/scripts/buildsystems/vcpkg.cmake | |
| RESULT_VARIABLE result | |
| ) | |
| endif() | |
| if (NOT result EQUAL 0) | |
| message(FATAL_ERROR "Bad exit status") | |
| endif() | |
| - name: Build | |
| shell: cmake -P {0} | |
| working-directory: ${{ env.HOME }} | |
| continue-on-error: ${{ matrix.config.experimental || false }} | |
| run: | | |
| set(ENV{NINJA_STATUS} "[%f/%t %o/sec] ") | |
| if ("${{ runner.os }}" STREQUAL "Windows" AND NOT "x${{ matrix.config.environment_script }}" STREQUAL "x") | |
| file(STRINGS environment_script_output.txt output_lines) | |
| foreach(line IN LISTS output_lines) | |
| if (line MATCHES "^([a-zA-Z0-9_-]+)=(.*)$") | |
| set(ENV{${CMAKE_MATCH_1}} "${CMAKE_MATCH_2}") | |
| endif() | |
| endforeach() | |
| endif() | |
| set(path_separator ":") | |
| if ("${{ runner.os }}" STREQUAL "Windows") | |
| set(path_separator ";") | |
| endif() | |
| set(ENV{PATH} "$ENV{GITHUB_WORKSPACE}${path_separator}$ENV{PATH}") | |
| execute_process( | |
| COMMAND ${{ steps.cmake_and_ninja.outputs.cmake_dir }}/cmake --build build | |
| RESULT_VARIABLE result | |
| ) | |
| if (NOT result EQUAL 0) | |
| message(FATAL_ERROR "Bad exit status") | |
| endif() | |
| - name: Run tests | |
| shell: cmake -P {0} | |
| working-directory: ${{ env.HOME }} | |
| continue-on-error: ${{ matrix.config.experimental || false }} | |
| run: | | |
| include(ProcessorCount) | |
| ProcessorCount(N) | |
| set(ENV{CTEST_OUTPUT_ON_FAILURE} "ON") | |
| execute_process( | |
| COMMAND ${{ steps.cmake_and_ninja.outputs.cmake_dir }}/cmake --build build --target test | |
| RESULT_VARIABLE result | |
| ) | |
| if (NOT result EQUAL 0) | |
| message(FATAL_ERROR "Running tests failed!") | |
| endif() | |
| - name: Install | |
| shell: cmake -P {0} | |
| working-directory: ${{ env.HOME }} | |
| continue-on-error: ${{ matrix.config.experimental || false }} | |
| run: | | |
| execute_process( | |
| COMMAND ${{ steps.cmake_and_ninja.outputs.cmake_dir }}/cmake --build build --target install | |
| RESULT_VARIABLE result | |
| ) | |
| if (NOT result EQUAL 0) | |
| message(FATAL_ERROR "Install failed!") | |
| endif() |