From 02cbaf3ca87fd20e2747a0632aa195cc23945171 Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Sun, 6 Sep 2026 11:14:54 +0200 Subject: [PATCH 1/2] Replace GHA by Boost.CIs reusable workflow --- .github/workflows/ci.yml | 592 +++------------------------------------ 1 file changed, 37 insertions(+), 555 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1701c3cfa..6d22e3b90 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,9 +1,23 @@ -# Copyright 2021-2022 Andrey Semashev -# Copyright 2023 Matt Borland +# +# Copyright 2020-2021 Peter Dimov +# Copyright 2021 Andrey Semashev +# Copyright 2021-2026 Alexander Grund +# Copyright 2022-2025 James E. King III +# # Distributed under the Boost Software License, Version 1.0. # (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt) - -name: CI +# +# This workflow uses the Boost.CI reusable workflow which builds a variety of +# configurations of your project, runs tests, and generates code coverage reports. +# +# To use it, copy this file into your repository as `.github/workflows/ci.yml` and +# customize it appropriately. +# +--- +name: Boost.CI + +permissions: + contents: read on: pull_request: @@ -11,557 +25,25 @@ on: branches: - master - develop + - bugfix/** - feature/** - -concurrency: - group: ${{format('{0}:{1}', github.repository, github.ref)}} - cancel-in-progress: true - -env: - GIT_FETCH_JOBS: 8 - NET_RETRY_COUNT: 5 - DEFAULT_BUILD_VARIANT: debug,release + - fix/** + - github/** + - pr/** + paths-ignore: + - LICENSE + - meta/** + - README.md jobs: - posix: - defaults: - run: - shell: bash - - strategy: - fail-fast: false - matrix: - include: - - toolset: gcc-5 - cxxstd: "03,11,14,1z" - address_model: 32,64 - os: ubuntu-latest - container: ubuntu:16.04 - install: - - g++-5-multilib - - toolset: gcc-5 - cxxstd: "11-gnu,14-gnu,1z-gnu" - address_model: 32,64 - os: ubuntu-latest - container: ubuntu:16.04 - install: - - g++-5-multilib - - toolset: gcc-6 - cxxstd: "11,14,1z" - address_model: 32,64 - os: ubuntu-latest - container: ubuntu:18.04 - install: - - g++-6-multilib - - toolset: gcc-7 - cxxstd: "11,14,17" - address_model: 32,64 - os: ubuntu-latest - container: ubuntu:18.04 - install: - - g++-7-multilib - - toolset: gcc-8 - cxxstd: "11,14,17,2a" - address_model: 32,64 - os: ubuntu-latest - container: ubuntu:18.04 - install: - - g++-8-multilib - - toolset: gcc-9 - cxxstd: "11,14,17,2a" - address_model: 32,64 - os: ubuntu-latest - container: ubuntu:20.04 - install: - - g++-9-multilib - - toolset: gcc-9 - cxxstd: "11-gnu,14-gnu,17-gnu,2a-gnu" - address_model: 32,64 - os: ubuntu-latest - container: ubuntu:20.04 - install: - - g++-9-multilib - - toolset: gcc-10 - cxxstd: "11,14,17,20" - address_model: 32,64 - os: ubuntu-latest - container: ubuntu:20.04 - install: - - g++-10-multilib - - toolset: gcc-11 - cxxstd: "11,14,17,20,23" - address_model: 32,64 - os: ubuntu-latest - container: ubuntu:22.04 - install: - - g++-11-multilib - - toolset: gcc-12 - cxxstd: "11,14,17,20,23" - address_model: 32,64 - os: ubuntu-latest - container: ubuntu:22.04 - install: - - g++-12-multilib - - toolset: gcc-12 - cxxstd: "11-gnu,14-gnu,17-gnu,20-gnu,23-gnu" - address_model: 32,64 - os: ubuntu-latest - container: ubuntu:22.04 - install: - - g++-12-multilib - - # Linux, clang - - toolset: clang - compiler: clang++-3.7 - cxxstd: "11,14" - os: ubuntu-latest - container: ubuntu:16.04 - install: - - clang-3.7 - - toolset: clang - compiler: clang++-3.8 - cxxstd: "11,14" - os: ubuntu-latest - container: ubuntu:16.04 - install: - - clang-3.8 - - toolset: clang - compiler: clang++-3.9 - cxxstd: "11,14" - os: ubuntu-latest - container: ubuntu:18.04 - install: - - clang-3.9 - - toolset: clang - compiler: clang++-4.0 - cxxstd: "11,14" - os: ubuntu-latest - container: ubuntu:18.04 - install: - - clang-4.0 - - toolset: clang - compiler: clang++-5.0 - cxxstd: "11,14,1z" - os: ubuntu-latest - container: ubuntu:18.04 - install: - - clang-5.0 - - toolset: clang - compiler: clang++-6.0 - cxxstd: "11,14,17" - os: ubuntu-latest - container: ubuntu:18.04 - install: - - clang-6.0 - - toolset: clang - compiler: clang++-7 - cxxstd: "11,14,17" - os: ubuntu-latest - container: ubuntu:18.04 - install: - - clang-7 - # Note: clang-8 does not fully support C++20, so it is not compatible with libstdc++-8 in this mode - - toolset: clang - compiler: clang++-8 - cxxstd: "11,14,17,2a" - os: ubuntu-latest - container: ubuntu:18.04 - install: - - clang-8 - - g++-7 - gcc_toolchain: 7 - - toolset: clang - compiler: clang++-9 - cxxstd: "11,14,17,2a" - os: ubuntu-latest - container: ubuntu:20.04 - install: - - clang-9 - - toolset: clang - compiler: clang++-10 - cxxstd: "11,14,17,20" - os: ubuntu-latest - container: ubuntu:20.04 - install: - - clang-10 - - toolset: clang - compiler: clang++-11 - cxxstd: "11,14,17,20" - os: ubuntu-latest - container: ubuntu:22.04 - install: - - clang-11 - - toolset: clang - compiler: clang++-12 - cxxstd: "11,14,17,20" - os: ubuntu-latest - container: ubuntu:22.04 - install: - - clang-12 - - toolset: clang - compiler: clang++-13 - cxxstd: "11,14,17,20" - os: ubuntu-latest - container: ubuntu:22.04 - install: - - clang-13 - - toolset: clang - compiler: clang++-14 - cxxstd: "11,14,17,20" - os: ubuntu-latest - container: ubuntu:22.04 - install: - - clang-14 - - toolset: clang - compiler: clang++-14 - cxxstd: "11-gnu,14-gnu,17-gnu,20-gnu" - os: ubuntu-latest - container: ubuntu:22.04 - install: - - clang-14 - - toolset: clang - compiler: clang++-15 - cxxstd: "11,14,17,20" - os: ubuntu-latest - container: ubuntu:22.04 - install: - - clang-15 - sources: - - "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-15 main" - source_keys: - - "https://apt.llvm.org/llvm-snapshot.gpg.key" - - toolset: clang - compiler: clang++-15 - cxxstd: "11,14,17,20,2b" - os: ubuntu-latest - container: ubuntu:22.04 - install: - - clang-15 - - libc++-15-dev - - libc++abi-15-dev - sources: - - "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-15 main" - source_keys: - - "https://apt.llvm.org/llvm-snapshot.gpg.key" - cxxflags: -stdlib=libc++ - linkflags: -stdlib=libc++ - - - toolset: clang - cxxstd: "11,14,17,20,2b" - os: macos-14 - - toolset: clang - cxxstd: "11,14,17,20,2b" - os: macos-15 - - timeout-minutes: 360 - runs-on: ${{matrix.os}} - container: - image: ${{matrix.container}} - volumes: - - /node20217:/node20217:rw,rshared - - ${{ startsWith(matrix.container, 'ubuntu:1') && '/node20217:/__e/node20:ro,rshared' || ' ' }} - - steps: - - name: Setup environment - run: | - if [ -f "/etc/debian_version" ] - then - echo "DEBIAN_FRONTEND=noninteractive" >> $GITHUB_ENV - export DEBIAN_FRONTEND=noninteractive - fi - if [ -n "${{matrix.container}}" ] - then - echo "GHA_CONTAINER=${{matrix.container}}" >> $GITHUB_ENV - if [ -f "/etc/debian_version" ] - then - apt-get -o Acquire::Retries=$NET_RETRY_COUNT update - if [ "$(apt-cache search "^python-is-python3$" | wc -l)" -ne 0 ] - then - PYTHON_PACKAGE="python-is-python3" - else - PYTHON_PACKAGE="python" - fi - apt-get -o Acquire::Retries=$NET_RETRY_COUNT install -y sudo software-properties-common tzdata wget curl apt-transport-https ca-certificates make build-essential g++ $PYTHON_PACKAGE python3 perl git cmake - fi - if [[ "${{matrix.container}}" == "ubuntu:1"* ]]; then - # Node 20 doesn't work with Ubuntu 16/18 glibc: https://github.com/actions/checkout/issues/1590 - curl -sL https://archives.boost.io/misc/node/node-v20.9.0-linux-x64-glibc-217.tar.xz | tar -xJ --strip-components 1 -C /node20217 - fi - fi - git config --global pack.threads 0 - - uses: actions/checkout@v4 - - - name: Install packages - if: matrix.install - run: | - declare -a SOURCE_KEYS SOURCES - if [ -n "${{join(matrix.source_keys, ' ')}}" ] - then - SOURCE_KEYS=("${{join(matrix.source_keys, '" "')}}") - fi - if [ -n "${{join(matrix.sources, ' ')}}" ] - then - SOURCES=("${{join(matrix.sources, '" "')}}") - fi - for key in "${SOURCE_KEYS[@]}" - do - for i in {1..$NET_RETRY_COUNT} - do - echo "Adding key: $key" - wget -O - "$key" | sudo apt-key add - && break || sleep 2 - done - done - if [ ${#SOURCES[@]} -gt 0 ] - then - APT_ADD_REPO_COMMON_ARGS=("-y") - APT_ADD_REPO_SUPPORTED_ARGS="$(apt-add-repository --help | perl -ne 'if (/^\s*-n/) { print "n"; } elsif (/^\s*-P/) { print "P"; } elsif (/^\s*-S/) { print "S"; } elsif (/^\s*-U/) { print "U"; }')" - if [ -n "$APT_ADD_REPO_SUPPORTED_ARGS" -a -z "${APT_ADD_REPO_SUPPORTED_ARGS##*n*}" ] - then - APT_ADD_REPO_COMMON_ARGS+=("-n") - fi - APT_ADD_REPO_HAS_SOURCE_ARGS="$([ -n "$APT_ADD_REPO_SUPPORTED_ARGS" -a -z "${APT_ADD_REPO_SUPPORTED_ARGS##*P*}" -a -z "${APT_ADD_REPO_SUPPORTED_ARGS##*S*}" -a -z "${APT_ADD_REPO_SUPPORTED_ARGS##*U*}" ] && echo 1 || echo 0)" - for source in "${SOURCES[@]}" - do - for i in {1..$NET_RETRY_COUNT} - do - APT_ADD_REPO_ARGS=("${APT_ADD_REPO_COMMON_ARGS[@]}") - if [ $APT_ADD_REPO_HAS_SOURCE_ARGS -ne 0 ] - then - case "$source" in - "ppa:"*) - APT_ADD_REPO_ARGS+=("-P") - ;; - "deb "*) - APT_ADD_REPO_ARGS+=("-S") - ;; - *) - APT_ADD_REPO_ARGS+=("-U") - ;; - esac - fi - APT_ADD_REPO_ARGS+=("$source") - echo "apt-add-repository ${APT_ADD_REPO_ARGS[@]}" - sudo -E apt-add-repository "${APT_ADD_REPO_ARGS[@]}" && break || sleep 2 - done - done - fi - sudo apt-get -o Acquire::Retries=$NET_RETRY_COUNT update - sudo apt-get -o Acquire::Retries=$NET_RETRY_COUNT install -y ${{join(matrix.install, ' ')}} - - name: Setup GCC Toolchain - if: matrix.gcc_toolchain - run: | - GCC_TOOLCHAIN_ROOT="$HOME/gcc-toolchain" - echo "GCC_TOOLCHAIN_ROOT=\"$GCC_TOOLCHAIN_ROOT\"" >> $GITHUB_ENV - MULTIARCH_TRIPLET="$(dpkg-architecture -qDEB_HOST_MULTIARCH)" - mkdir -p "$GCC_TOOLCHAIN_ROOT" - ln -s /usr/include "$GCC_TOOLCHAIN_ROOT/include" - ln -s /usr/bin "$GCC_TOOLCHAIN_ROOT/bin" - mkdir -p "$GCC_TOOLCHAIN_ROOT/lib/gcc/$MULTIARCH_TRIPLET" - ln -s "/usr/lib/gcc/$MULTIARCH_TRIPLET/${{matrix.gcc_toolchain}}" "$GCC_TOOLCHAIN_ROOT/lib/gcc/$MULTIARCH_TRIPLET/${{matrix.gcc_toolchain}}" - - name: Setup Boost - run: | - echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY - LIBRARY=${GITHUB_REPOSITORY#*/} - echo LIBRARY: $LIBRARY - echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV - echo GITHUB_BASE_REF: $GITHUB_BASE_REF - echo GITHUB_REF: $GITHUB_REF - REF=${GITHUB_BASE_REF:-$GITHUB_REF} - REF=${REF#refs/heads/} - echo REF: $REF - BOOST_BRANCH=develop && [ "$REF" = "master" ] && BOOST_BRANCH=master || true - echo BOOST_BRANCH: $BOOST_BRANCH - BUILD_JOBS=$((nproc || sysctl -n hw.ncpu) 2> /dev/null) - echo "BUILD_JOBS=$BUILD_JOBS" >> $GITHUB_ENV - echo "CMAKE_BUILD_PARALLEL_LEVEL=$BUILD_JOBS" >> $GITHUB_ENV - DEPINST_ARGS=() - GIT_VERSION="$(git --version | sed -e 's/git version //')" - GIT_HAS_JOBS=1 - if [ -f "/etc/debian_version" ] - then - if $(dpkg --compare-versions "$GIT_VERSION" lt 2.8.0) - then - GIT_HAS_JOBS=0 - fi - else - declare -a GIT_VER=(${GIT_VERSION//./ }) - declare -a GIT_MIN_VER=(2 8 0) - for ((i=0; i<${#GIT_VER[@]}; i++)) - do - if [ -z "${GIT_MIN_VER[i]}" ] - then - GIT_MIN_VER[i]=0 - fi - if [ "${GIT_VER[i]}" -lt "${GIT_MIN_VER[i]}" ] - then - GIT_HAS_JOBS=0 - break - fi - done - fi - if [ "$GIT_HAS_JOBS" -ne 0 ] - then - DEPINST_ARGS+=("--git_args" "--jobs $GIT_FETCH_JOBS") - fi - cd .. - git clone -b "$BOOST_BRANCH" --depth 1 "https://github.com/boostorg/boost.git" "boost-root" - cd boost-root - mkdir -p libs/$LIBRARY - cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY - git submodule update --init tools/boostdep - DEPINST_ARGS+=("$LIBRARY") - python tools/boostdep/depinst/depinst.py "${DEPINST_ARGS[@]}" - if [ -z "${{matrix.cmake_tests}}" ] - then - ./bootstrap.sh - ./b2 headers - if [ -n "${{matrix.compiler}}" -o -n "$GCC_TOOLCHAIN_ROOT" ] - then - echo -n "using ${{matrix.toolset}} : : ${{matrix.compiler}}" > ~/user-config.jam - if [ -n "$GCC_TOOLCHAIN_ROOT" ] - then - echo -n " : \"--gcc-toolchain=$GCC_TOOLCHAIN_ROOT\" \"--gcc-toolchain=$GCC_TOOLCHAIN_ROOT\"" >> ~/user-config.jam - fi - echo " ;" >> ~/user-config.jam - fi - fi - - name: Run tests - if: matrix.cmake_tests == '' - run: | - cd ../boost-root - B2_ARGS=("-j" "$BUILD_JOBS" "toolset=${{matrix.toolset}}" "cxxstd=${{matrix.cxxstd}}" "link=static,shared") - if [ -n "${{matrix.build_variant}}" ] - then - B2_ARGS+=("variant=${{matrix.build_variant}}") - else - B2_ARGS+=("variant=$DEFAULT_BUILD_VARIANT") - fi - if [ -n "${{matrix.threading}}" ] - then - B2_ARGS+=("threading=${{matrix.threading}}") - fi - if [ -n "${{matrix.ubsan}}" ] - then - export UBSAN_OPTIONS="print_stacktrace=1" - B2_ARGS+=("cxxflags=-fsanitize=undefined -fno-sanitize-recover=undefined" "linkflags=-fsanitize=undefined -fuse-ld=gold" "define=UBSAN=1" "debug-symbols=on" "visibility=global") - fi - if [ -n "${{matrix.cxxflags}}" ] - then - B2_ARGS+=("cxxflags=${{matrix.cxxflags}}") - fi - if [ -n "${{matrix.linkflags}}" ] - then - B2_ARGS+=("linkflags=${{matrix.linkflags}}") - fi - if [ -n "${{matrix.address_model}}" ] - then - B2_ARGS+=("address-model=${{matrix.address_model}}") - fi - B2_ARGS+=("libs/$LIBRARY/test") - ./b2 "${B2_ARGS[@]}" - - windows: - strategy: - fail-fast: false - matrix: - include: - - toolset: msvc-14.3 - cxxstd: "17,20,latest" - addrmd: 64 - os: windows-2022 - - toolset: clang-win - cxxstd: "14,17,latest" - addrmd: 64 - os: windows-2022 - - toolset: gcc - cxxstd: "11,14,17,2a" - addrmd: 64 - os: windows-latest - - runs-on: ${{matrix.os}} - - steps: - - uses: actions/checkout@v3 - - - name: Setup Boost - shell: cmd - run: | - echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY% - for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi - echo LIBRARY: %LIBRARY% - echo LIBRARY=%LIBRARY%>>%GITHUB_ENV% - echo GITHUB_BASE_REF: %GITHUB_BASE_REF% - echo GITHUB_REF: %GITHUB_REF% - if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF% - set BOOST_BRANCH=develop - for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master - echo BOOST_BRANCH: %BOOST_BRANCH% - cd .. - git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root - cd boost-root - xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\ - git submodule update --init tools/boostdep - python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" %LIBRARY% - cmd /c bootstrap - b2 -d0 headers - - - name: Run tests - shell: cmd - run: | - cd ../boost-root - b2 -j3 libs/%LIBRARY%/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} address-model=${{matrix.addrmd}} variant=release link=static,shared embed-manifest-via=linker - - posix-cmake-test: - strategy: - fail-fast: false - matrix: - include: - - os: ubuntu-24.04 - - os: macos-14 - - os: macos-15 - - runs-on: ${{matrix.os}} - - steps: - - uses: actions/checkout@v3 - - - name: Install packages - if: matrix.install - run: sudo apt-get -y install ${{matrix.install}} - - - name: Setup Boost - run: | - echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY - LIBRARY=${GITHUB_REPOSITORY#*/} - echo LIBRARY: $LIBRARY - echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV - echo GITHUB_BASE_REF: $GITHUB_BASE_REF - echo GITHUB_REF: $GITHUB_REF - REF=${GITHUB_BASE_REF:-$GITHUB_REF} - REF=${REF#refs/heads/} - echo REF: $REF - BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true - echo BOOST_BRANCH: $BOOST_BRANCH - cd .. - git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root - cd boost-root - mkdir -p libs/$LIBRARY - cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY - git submodule update --init tools/boostdep - python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY - - - name: Configure - run: | - cd ../boost-root - mkdir __build__ && cd __build__ - cmake -DBOOST_INCLUDE_LIBRARIES=$LIBRARY -DBUILD_TESTING=ON .. - - - name: Build tests - run: | - cd ../boost-root/__build__ - cmake --build . --target tests - - - name: Run tests - run: | - cd ../boost-root/__build__ - ctest --output-on-failure --no-tests=error + call-boost-ci: + name: Run Boost.CI + uses: boostorg/boost-ci/.github/workflows/reusable.yml@master + # Customization: + with: + enable_reflection: true + # enable_windows: false + secrets: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + COVERITY_SCAN_NOTIFICATION_EMAIL: ${{ secrets.COVERITY_SCAN_NOTIFICATION_EMAIL }} + COVERITY_SCAN_TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }} From c0090e2e54b42731887b96a9f957088ec7d45432 Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Sun, 6 Sep 2026 11:44:54 +0200 Subject: [PATCH 2/2] Add CMake subdir test --- test/cmake_test/CMakeLists.txt | 52 ++++++++++++++++++++++++++++++++++ test/cmake_test/main.cpp | 9 ++++++ 2 files changed, 61 insertions(+) create mode 100644 test/cmake_test/CMakeLists.txt create mode 100644 test/cmake_test/main.cpp diff --git a/test/cmake_test/CMakeLists.txt b/test/cmake_test/CMakeLists.txt new file mode 100644 index 000000000..e82ad2a2f --- /dev/null +++ b/test/cmake_test/CMakeLists.txt @@ -0,0 +1,52 @@ +# Copyright 2021-2026 Alexander Grund +# Distributed under the Boost Software License, Version 1.0. +# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt + +cmake_minimum_required(VERSION 3.5...3.31) + +project(cmake_subdir_test LANGUAGES CXX) + +# Those 2 should work the same +# while using find_package for the installed Boost avoids the need to manually specify dependencies +if(BOOST_CI_INSTALL_TEST) + # Regular usage: + # Provides target Boost::random + find_package(Boost COMPONENTS random REQUIRED) +else() + add_subdirectory(../.. boostorg/random) + + set(deps + # Primary dependencies + assert + config + core + dynamic_bitset + integer + io + system + throw_exception + type_traits + utility + # Secondary dependencies + compat + container_hash + describe + mp11 + predef + preprocessor + variant2 + winapi + ) + + foreach(dep IN LISTS deps) + add_subdirectory(../../../${dep} boostorg/${dep}) + endforeach() +endif() + +add_executable(main main.cpp) +target_link_libraries(main Boost::random) + +enable_testing() +add_test(NAME main COMMAND main) + +add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $) diff --git a/test/cmake_test/main.cpp b/test/cmake_test/main.cpp new file mode 100644 index 000000000..7cfcbf8ae --- /dev/null +++ b/test/cmake_test/main.cpp @@ -0,0 +1,9 @@ +#include + +int main() +{ + boost::mt19937 rng; + boost::uniform_int<> six(1,6); + int x = six(rng); + return (x >= 1 && x <= 6) ? 0 : 1; +}