diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 914dc72..ba300cb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,15 +11,15 @@ name: CI on: pull_request: + push: branches: - master - develop + - bugfix/** - feature/** - push: - branches: - - '*' - tags: - - "boost-*.*.*" + - fix/** + - pr/** + concurrency: group: ${{format('{0}:{1}', github.repository, github.ref)}} @@ -29,11 +29,13 @@ env: GIT_FETCH_JOBS: 8 NET_RETRY_COUNT: 5 DEFAULT_BUILD_VARIANT: debug,release + UBSAN_OPTIONS: "print_stacktrace=1" + ASAN_OPTIONS: "detect_invalid_pointer_pairs=2" jobs: runner-selection: name: Runner Selection - runs-on: ${{ github.repository_owner == 'cppalliance' && fromJSON('[ "self-hosted", "linux", "x64", "ubuntu-latest-aws" ]') || 'ubuntu-latest' }} + runs-on: ${{ github.repository_owner == 'boostorg' && fromJSON('[ "self-hosted", "linux", "x64", "ubuntu-latest-aws" ]') || 'ubuntu-latest' }} outputs: labelmatrix: ${{ steps.aws_hosted_runners.outputs.labelmatrix }} steps: @@ -41,107 +43,943 @@ jobs: id: aws_hosted_runners uses: cppalliance/aws-hosted-runners@v1.0.0 - cpp-matrix: - needs: [ runner-selection ] - runs-on: ${{ fromJSON(needs.runner-selection.outputs.labelmatrix)['ubuntu-latest'] }} - name: Generate Test Matrix - outputs: - matrix: ${{ steps.cpp-matrix.outputs.matrix }} - steps: - - name: Generate Test Matrix - uses: alandefreitas/cpp-actions/cpp-matrix@v1.8.10 - id: cpp-matrix - with: - compilers: | - gcc >=4.8 - clang >=3.8 - msvc >=14.20 - apple-clang * - mingw * - clang-cl * - subrange-policy: | - msvc: one-per-minor - standards: '>=11' - latest-factors: | - gcc ASan - factors: | - gcc UBSan Coverage Shared - msvc Shared x86 - clang ASan UBSan - mingw Shared - trace-commands: true - build: - needs: [ cpp-matrix,runner-selection ] + needs: [ runner-selection ] defaults: run: shell: bash + strategy: fail-fast: false matrix: - include: ${{ fromJSON(needs.cpp-matrix.outputs.matrix) }} + include: + # Windows compilers + # + + - compiler: "msvc" + version: "14.42" + cxxstd: "11,14,17,20" + latest-cxxstd: "20" + runs-on: "windows-2022" + b2-toolset: "msvc-14.4" + generator: "Visual Studio 17 2022" + is-latest: true + name: "MSVC 14.42: C++11-20" + build-type: "Release" + build-cmake: true + + - compiler: "msvc" + version: "14.34" + cxxstd: "11,14,17,20" + latest-cxxstd: "20" + runs-on: "windows-2022" + b2-toolset: "msvc-14.3" + generator: "Visual Studio 17 2022" + is-latest: true + name: "MSVC 14.34: C++11-20" + build-type: "Release" + build-cmake: true + + - compiler: "msvc" + version: "14.34" + cxxstd: "11,14,17,20" + latest-cxxstd: "20" + runs-on: "windows-2022" + b2-toolset: "msvc-14.3" + generator: "Visual Studio 17 2022" + is-latest: true + name: "MSVC 14.34: C++11-20 (shared)" + shared: true + build-type: "Release" + build-cmake: true + + - compiler: "clang-cl" + version: "*" + cxx: "clang++-cl" + cc: "clang-cl" + runs-on: "windows-2022" + b2-toolset: "clang-win" + generator-toolset: "ClangCL" + is-latest: true + is-earliest: true + name: "Windows-Clang" + build-type: "Release" + build-cmake: true + + - compiler: "mingw" + version: "*" + cxx: "g++" + cc: "gcc" + runs-on: "windows-2022" + b2-toolset: "gcc" + generator: "MinGW Makefiles" + is-latest: true + is-earliest: true + name: "MinGW" + build-type: "Release" + build-cmake: true + + - compiler: "mingw" + version: "*" + cxx: "g++" + cc: "gcc" + runs-on: "windows-2022" + b2-toolset: "gcc" + generator: "MinGW Makefiles" + is-latest: true + is-earliest: true + name: "MinGW (shared)" + shared: true + build-type: "Release" + build-cmake: true + + # OSX compilers + # + + - compiler: "apple-clang" + version: "*" + cxx: "clang++" + cc: "clang" + runs-on: "macos-15" + b2-toolset: "clang" + is-latest: true + name: "Apple-Clang (macOS 15)" + build-type: "Release" + build-cmake: true + + - compiler: "apple-clang" + version: "*" + cxx: "clang++" + cc: "clang" + runs-on: "macos-15" + b2-toolset: "clang" + is-latest: true + name: "Apple-Clang (macOS 15, ubsan)" + build-type: "RelWithDebInfo" + ubsan: true + + - compiler: "apple-clang" + version: "*" + cxx: "clang++" + cc: "clang" + runs-on: "macos-15" + b2-toolset: "clang" + is-latest: true + name: "Apple-Clang (macOS 15, asan)" + build-type: "RelWithDebInfo" + asan: true + + - compiler: "apple-clang" + version: "*" + cxx: "clang++" + cc: "clang" + runs-on: "macos-14" + b2-toolset: "clang" + name: "Apple-Clang (macOS 14)" + build-type: "Release" + + - compiler: "apple-clang" + version: "*" + cxx: "clang++" + cc: "clang" + runs-on: "macos-13" + b2-toolset: "clang" + name: "Apple-Clang (macOS 13)" + build-type: "Release" + + # Linux compilers + # + + - compiler: "gcc" + version: "14" + cxxstd: "11,14,17,20" + latest-cxxstd: "20" + cxx: "g++-14" + cc: "gcc-14" + runs-on: "ubuntu-latest" + container: "ubuntu:24.04" + b2-toolset: "gcc" + is-latest: true + name: "GCC 14: C++11-20" + build-type: "Release" + build-cmake: true + + - compiler: "gcc" + version: "14" + cxxstd: "11,14,17,20" + latest-cxxstd: "20" + cxx: "g++-14" + cc: "gcc-14" + runs-on: "ubuntu-latest" + container: "ubuntu:24.04" + b2-toolset: "gcc" + is-latest: true + name: "GCC 14: C++11-20 (shared)" + shared: true + build-type: "Release" + build-cmake: true + + - compiler: "gcc" + version: "14" + cxxstd: "11,14,17,20" + latest-cxxstd: "20" + cxx: "g++-14" + cc: "gcc-14" + runs-on: "ubuntu-latest" + container: "ubuntu:24.04" + b2-toolset: "gcc" + is-latest: true + name: "GCC 14: C++11-20 (asan)" + asan: true + build-type: "RelWithDebInfo" + + - compiler: "gcc" + version: "14" + cxxstd: "11,14,17,20" + latest-cxxstd: "20" + cxx: "g++-14" + cc: "gcc-14" + runs-on: "ubuntu-latest" + container: "ubuntu:24.04" + b2-toolset: "gcc" + is-latest: true + name: "GCC 14: C++11-20 (ubsan)" + ubsan: true + build-type: "RelWithDebInfo" + + - compiler: "gcc" + version: "13" + cxxstd: "11,14,17,20" + latest-cxxstd: "20" + cxx: "g++-13" + cc: "gcc-13" + runs-on: "ubuntu-latest" + container: "ubuntu:24.04" + b2-toolset: "gcc" + name: "GCC 13: C++11-20" + build-type: "Release" + + - compiler: "gcc" + version: "13" + cxxstd: "11,14,17,20" + latest-cxxstd: "20" + cxx: "g++-13" + cc: "gcc-13" + runs-on: "ubuntu-latest" + container: "ubuntu:24.04" + b2-toolset: "gcc" + is-latest: true + name: "GCC 13: C++11-20 (coverage)" + coverage: true + build-type: "Debug" + cxxflags: "--coverage -fprofile-arcs -ftest-coverage" + ccflags: "--coverage -fprofile-arcs -ftest-coverage" + install: "lcov zlib1g-dev wget unzip" + + - compiler: "gcc" + version: "12" + cxxstd: "11,14,17,20" + latest-cxxstd: "20" + cxx: "g++-12" + cc: "gcc-12" + runs-on: "ubuntu-latest" + container: "ubuntu:22.04" + b2-toolset: "gcc" + name: "GCC 12: C++11-20" + build-type: "Release" + + - compiler: "gcc" + version: "11" + cxxstd: "11,14,17,20" + latest-cxxstd: "20" + cxx: "g++-11" + cc: "gcc-11" + runs-on: "ubuntu-latest" + container: "ubuntu:22.04" + b2-toolset: "gcc" + name: "GCC 11: C++11-20" + build-type: "Release" + + - compiler: "gcc" + version: "10" + cxxstd: "11,14,17" + latest-cxxstd: "17" + cxx: "g++-10" + cc: "gcc-10" + runs-on: "ubuntu-latest" + container: "ubuntu:20.04" + b2-toolset: "gcc" + name: "GCC 10: C++11-17" + build-type: "Release" + + - compiler: "gcc" + version: "9" + cxxstd: "11,14,17" + latest-cxxstd: "17" + cxx: "g++-9" + cc: "gcc-9" + runs-on: "ubuntu-latest" + container: "ubuntu:20.04" + b2-toolset: "gcc" + name: "GCC 9: C++11-17" + build-type: "Release" + + - compiler: "gcc" + version: "8" + cxxstd: "11,14,17" + latest-cxxstd: "17" + cxx: "g++-8" + cc: "gcc-8" + runs-on: "ubuntu-latest" + container: "ubuntu:20.04" + b2-toolset: "gcc" + name: "GCC 8: C++11-17" + build-type: "Release" + + - compiler: "gcc" + version: "7" + cxxstd: "11,14,17" + latest-cxxstd: "17" + cxx: "g++-7" + cc: "gcc-7" + runs-on: "ubuntu-latest" + container: "ubuntu:20.04" + b2-toolset: "gcc" + name: "GCC 7: C++11-17" + build-type: "Release" + + - compiler: "gcc" + version: "6" + cxxstd: "11,14" + latest-cxxstd: "14" + cxx: "g++-6" + cc: "gcc-6" + runs-on: "ubuntu-latest" + container: "ubuntu:18.04" + b2-toolset: "gcc" + name: "GCC 6: C++11-14" + build-type: "Release" + + - compiler: "gcc" + version: "5" + cxxstd: "11" + latest-cxxstd: "11" + cxx: "g++-5" + cc: "gcc-5" + runs-on: "ubuntu-latest" + container: "ubuntu:18.04" + b2-toolset: "gcc" + is-earliest: true + name: "GCC 5: C++11" + build-type: "Release" + + - compiler: "clang" + version: "18" + cxxstd: "11,14,17,20" + latest-cxxstd: "20" + cxx: "clang++-18" + cc: "clang-18" + runs-on: "ubuntu-latest" + container: "ubuntu:24.04" + b2-toolset: "clang" + is-latest: true + name: "Clang 18: C++11-20" + build-type: "Release" + build-cmake: true + + - compiler: "clang" + version: "18" + cxxstd: "20" + latest-cxxstd: "20" + cxx: "clang++-18" + cc: "clang-18" + runs-on: "ubuntu-latest" + container: "ubuntu:24.04" + b2-toolset: "clang" + is-latest: true + name: "Clang 18: C++20 (time-trace)" + time-trace: true + build-type: "Release" + cxxflags: "-ftime-trace" + ccflags: "-ftime-trace" + install: "wget unzip" + + - compiler: "clang" + version: "18" + cxxstd: "11,14,17,20" + latest-cxxstd: "20" + cxx: "clang++-18" + cc: "clang-18" + runs-on: "ubuntu-latest" + container: "ubuntu:24.04" + b2-toolset: "clang" + is-latest: true + name: "Clang 18: C++11-20 (asan)" + asan: true + build-type: "RelWithDebInfo" + + - compiler: "clang" + version: "18" + cxxstd: "11,14,17,20" + latest-cxxstd: "20" + cxx: "clang++-18" + cc: "clang-18" + runs-on: "ubuntu-latest" + container: "ubuntu:24.04" + b2-toolset: "clang" + is-latest: true + name: "Clang 18: C++11-20 (ubsan)" + ubsan: true + build-type: "RelWithDebInfo" + + - compiler: "clang" + version: "17" + cxxstd: "11,14,17,20" + latest-cxxstd: "20" + cxx: "clang++-17" + cc: "clang-17" + runs-on: "ubuntu-latest" + container: "ubuntu:24.04" + b2-toolset: "clang" + name: "Clang 17: C++11-20" + build-type: "Release" + + - compiler: "clang" + version: "16" + cxxstd: "11,14,17,20" + latest-cxxstd: "20" + cxx: "clang++-16" + cc: "clang-16" + runs-on: "ubuntu-latest" + container: "ubuntu:24.04" + b2-toolset: "clang" + name: "Clang 16: C++11-20" + build-type: "Release" + + - compiler: "clang" + version: "15" + cxxstd: "11,14,17,20" + latest-cxxstd: "20" + cxx: "clang++-15" + cc: "clang-15" + runs-on: "ubuntu-latest" + container: "ubuntu:22.04" + b2-toolset: "clang" + name: "Clang 15: C++11-20" + build-type: "Release" + + - compiler: "clang" + version: "14" + cxxstd: "11,14,17,20" + latest-cxxstd: "20" + cxx: "clang++-14" + cc: "clang-14" + runs-on: "ubuntu-latest" + container: "ubuntu:22.04" + b2-toolset: "clang" + name: "Clang 14: C++11-20" + build-type: "Release" + + - compiler: "clang" + version: "13" + cxxstd: "11,14,17,20" + latest-cxxstd: "20" + cxx: "clang++-13" + cc: "clang-13" + runs-on: "ubuntu-latest" + container: "ubuntu:22.04" + b2-toolset: "clang" + name: "Clang 13: C++11-20" + build-type: "Release" + + - compiler: "clang" + version: "12" + cxxstd: "11,14,17,20" + latest-cxxstd: "20" + cxx: "clang++-12" + cc: "clang-12" + runs-on: "ubuntu-latest" + container: "ubuntu:22.04" + b2-toolset: "clang" + name: "Clang 12: C++11-20" + build-type: "Release" + + - compiler: "clang" + version: "11" + cxxstd: "11,14,17" + latest-cxxstd: "17" + cxx: "clang++-11" + cc: "clang-11" + runs-on: "ubuntu-latest" + container: "ubuntu:22.04" + b2-toolset: "clang" + name: "Clang 11: C++11-17" + build-type: "Release" + + - compiler: "clang" + version: "10" + cxxstd: "11,14,17" + latest-cxxstd: "17" + cxx: "clang++-10" + cc: "clang-10" + runs-on: "ubuntu-latest" + container: "ubuntu:20.04" + b2-toolset: "clang" + name: "Clang 10: C++11-17" + build-type: "Release" + + - compiler: "clang" + version: "9" + cxxstd: "11,14,17" + latest-cxxstd: "17" + cxx: "clang++-9" + cc: "clang-9" + runs-on: "ubuntu-latest" + container: "ubuntu:20.04" + b2-toolset: "clang" + name: "Clang 9: C++11-17" + build-type: "Release" + + - compiler: "clang" + version: "8" + cxxstd: "11,14,17" + latest-cxxstd: "17" + cxx: "clang++-8" + cc: "clang-8" + runs-on: "ubuntu-latest" + container: "ubuntu:20.04" + b2-toolset: "clang" + name: "Clang 8: C++11-17" + build-type: "Release" + + - compiler: "clang" + version: "7" + cxxstd: "11,14,17" + latest-cxxstd: "17" + cxx: "clang++-7" + cc: "clang-7" + runs-on: "ubuntu-latest" + container: "ubuntu:20.04" + b2-toolset: "clang" + name: "Clang 7: C++11-17" + build-type: "Release" + + - compiler: "clang" + version: "6" + cxxstd: "11,14,17" + latest-cxxstd: "17" + cxx: "clang++-6.0" + cc: "clang-6.0" + runs-on: "ubuntu-latest" + container: "ubuntu:20.04" + b2-toolset: "clang" + name: "Clang 6: C++11-17" + build-type: "Release" + + - compiler: "clang" + version: "5" + cxxstd: "11,14" + latest-cxxstd: "14" + cxx: "clang++-5.0" + cc: "clang-5.0" + runs-on: "ubuntu-latest" + container: "ubuntu:18.04" + b2-toolset: "clang" + name: "Clang 5: C++11-14" + build-type: "Release" + + - compiler: "clang" + version: "4" + cxxstd: "11,14" + latest-cxxstd: "14" + cxx: "clang++-4.0" + cc: "clang-4.0" + runs-on: "ubuntu-latest" + container: "ubuntu:18.04" + b2-toolset: "clang" + name: "Clang 4: C++11-14" + build-type: "Release" + + - compiler: "clang" + version: "3.9" + cxxstd: "11" + latest-cxxstd: "11" + cxx: "clang++-3.9" + cc: "clang-3.9" + runs-on: "ubuntu-latest" + container: "ubuntu:18.04" + b2-toolset: "clang" + is-earliest: true + name: "Clang 3.9: C++11" + build-type: "Release" name: ${{ matrix.name }} runs-on: ${{ fromJSON(needs.runner-selection.outputs.labelmatrix)[matrix.runs-on] }} - container: ${{ matrix.container }} - env: ${{ matrix.env }} + container: + image: ${{ matrix.container }} + options: --privileged + volumes: + - /node20217:/node20217:rw,rshared + - ${{ startsWith(matrix.container, 'ubuntu:1') && '/node20217:/__e/node20:ro,rshared' || ' ' }} + timeout-minutes: 120 steps: - - name: Clone Repository + - name: install nodejs20glibc2.17 + if: ${{ startsWith( matrix.container, 'ubuntu:1' ) }} + run: | + apt-get update + apt-get -yqq install xz-utils curl + curl -LO https://archives.boost.io/misc/node/node-v20.9.0-linux-x64-glibc-217.tar.xz + tar -xf node-v20.9.0-linux-x64-glibc-217.tar.xz --strip-components 1 -C /node20217 + ldd /__e/node20/bin/node + + - name: Clone Boost.Yaml uses: actions/checkout@v4 + with: + path: yaml-root - name: Setup C++ - uses: alandefreitas/cpp-actions/setup-cpp@v1.8.10 + uses: alandefreitas/cpp-actions/setup-cpp@v1.8.8 id: setup-cpp with: compiler: ${{ matrix.compiler }} version: ${{ matrix.version }} + check-latest: ${{ matrix.compiler != 'clang' || matrix.version != '^3.8' }} + trace-commands: true - name: Install packages - uses: alandefreitas/cpp-actions/package-install@v1.8.10 + uses: alandefreitas/cpp-actions/package-install@v1.8.8 id: package-install with: - apt-get: ${{ matrix.install }} + apt-get: >- + ${{ matrix.install }} + build-essential - name: Clone Boost + uses: alandefreitas/cpp-actions/boost-clone@v1.8.8 + id: boost-clone + with: + branch: ${{ (github.ref_name == 'master' && github.ref_name) || 'develop' }} + boost-dir: boost-source + cache: false + modules-exclude-paths: '' + scan-modules-dir: yaml-root + scan-modules-ignore: yaml + + - name: Patch Boost + id: patch + shell: bash run: | set -xe - if [ ! -d boost-root ]; then - git clone -b master --depth 1 https://github.com/boostorg/boost.git boost-root - cd boost-root - git submodule update --init --depth 1 tools/boostdep tools/build tools/cmake - python tools/boostdep/depinst/depinst.py --include example --include tools --git_args "--depth 1" ../include/boost - fi + pwd + ls + ls -lah boost-source + + # Identify boost module being tested + module=${GITHUB_REPOSITORY#*/} + echo "module=$module" >> $GITHUB_OUTPUT + + # Identify GitHub workspace root + workspace_root=$(echo "$GITHUB_WORKSPACE" | sed 's/\\/\//g') + echo -E "workspace_root=$workspace_root" >> $GITHUB_OUTPUT + + # Remove module from boost-source + rm -r "boost-source/libs/$module" || true + + # Copy cached boost-source to an isolated boost-root + cp -r boost-source boost-root - - name: CMake Workflow - uses: alandefreitas/cpp-actions/cmake-workflow@v1.8.10 + # Set boost-root output + cd boost-root + boost_root="$(pwd)" + boost_root=$(echo "$boost_root" | sed 's/\\/\//g') + echo -E "boost_root=$boost_root" >> $GITHUB_OUTPUT + + # Patch boost-root with workspace module + cp -r "$workspace_root"/yaml-root "libs/$module" + + - name: Boost B2 Workflow + uses: alandefreitas/cpp-actions/b2-workflow@v1.8.8 + if: ${{ !matrix.coverage && !matrix.time-trace }} + with: + source-dir: boost-root + modules: yaml + toolset: ${{ matrix.b2-toolset }} + build-variant: ${{ matrix.build-type }} + cxx: ${{ steps.setup-cpp.outputs.cxx || matrix.cxx || '' }} + cxxstd: ${{ matrix.cxxstd }} + address-model: ${{ (matrix.x86 && '32') || '64' }} + asan: ${{ matrix.asan }} + ubsan: ${{ matrix.ubsan }} + shared: ${{ matrix.shared }} + rtti: ${{ (matrix.is-latest && 'on,off') || 'on' }} + cxxflags: ${{ (matrix.asan && '-fsanitize=pointer-subtract') || '' }} + stop-on-error: true + + - name: Boost CMake Workflow + uses: alandefreitas/cpp-actions/cmake-workflow@v1.8.8 + if: ${{ matrix.coverage || matrix.time-trace || matrix.build-cmake || matrix.is-earliest }} + with: + source-dir: boost-root + build-dir: __build_cmake_test__ + generator: ${{ matrix.generator }} + generator-toolset: ${{ matrix.generator-toolset }} + build-type: ${{ matrix.build-type }} + build-target: tests + run-tests: true + install-prefix: .local + cxxstd: ${{ matrix.latest-cxxstd }} + cc: ${{ steps.setup-cpp.outputs.cc || matrix.cc }} + ccflags: ${{ matrix.ccflags }} + cxx: ${{ steps.setup-cpp.outputs.cxx || matrix.cxx }} + cxxflags: ${{ matrix.cxxflags }} + shared: ${{ matrix.shared }} + cmake-version: '>=3.20' + extra-args: | + -D Boost_VERBOSE=ON + -D BOOST_INCLUDE_LIBRARIES="${{ steps.patch.outputs.module }}" + export-compile-commands: ${{ matrix.time-trace }} + package: false + package-artifact: false + ref-source-dir: boost-root/libs/yaml + toolchain: ${{ (startsWith(matrix.runs-on, 'windows') && steps.patch-user-config.outputs.toolchain) || '' }} + + - name: Set Path + if: startsWith(matrix.runs-on, 'windows') && matrix.shared + run: echo "$GITHUB_WORKSPACE/.local/bin" >> $GITHUB_PATH + + - name: Set LD_LIBRARY_PATH + if: startsWith(matrix.runs-on, 'ubuntu') && matrix.shared + run: | + echo "LD_LIBRARY_PATH=$GITHUB_WORKSPACE/.local/lib:$LD_LIBRARY_PATH" >> "$GITHUB_ENV" + + - name: Find Package Integration Workflow + uses: alandefreitas/cpp-actions/cmake-workflow@v1.8.8 + if: ${{ matrix.build-cmake || matrix.is-earliest }} with: - source-dir: . - build-dir: build - generator: Ninja + source-dir: boost-root/libs/${{ steps.patch.outputs.module }}/test/cmake_test + build-dir: __build_cmake_install_test__ + generator: ${{ matrix.generator }} + generator-toolset: ${{ matrix.generator-toolset }} build-type: ${{ matrix.build-type }} - toolchain: ${{ steps.setup-cpp.outputs.toolchain }} + cxxstd: ${{ matrix.latest-cxxstd }} + cc: ${{ steps.setup-cpp.outputs.cc || matrix.cc }} + ccflags: ${{ matrix.ccflags }} + cxx: ${{ steps.setup-cpp.outputs.cxx || matrix.cxx }} + cxxflags: ${{ matrix.cxxflags }} + shared: ${{ matrix.shared }} + install: false + cmake-version: '>=3.15' extra-args: | - -D BOOST_SRC_DIR=boost-root - -D BOOST_YAML_BUILD_TESTS=ON - -D BOOST_YAML_BUILD_EXAMPLES=ON - export-compile-commands: ${{ matrix.time-trace == 'true' }} + -D BOOST_CI_INSTALL_TEST=ON + -D CMAKE_PREFIX_PATH=${{ steps.patch.outputs.workspace_root }}/.local + ref-source-dir: boost-root/libs/yaml + trace-commands: true + + - name: Subdirectory Integration Workflow + uses: alandefreitas/cpp-actions/cmake-workflow@v1.8.8 + if: ${{ matrix.build-cmake || matrix.is-earliest }} + with: + source-dir: boost-root/libs/${{ steps.patch.outputs.module }}/test/cmake_test + build-dir: __build_cmake_subdir_test__ + generator: ${{ matrix.generator }} + generator-toolset: ${{ matrix.generator-toolset }} + build-type: ${{ matrix.build-type }} + cxxstd: ${{ matrix.latest-cxxstd }} + cc: ${{ steps.setup-cpp.outputs.cc || matrix.cc }} + ccflags: ${{ matrix.ccflags }} + cxx: ${{ steps.setup-cpp.outputs.cxx || matrix.cxx }} + cxxflags: ${{ matrix.cxxflags }} + shared: ${{ matrix.shared }} + install: false + cmake-version: '>=3.15' + extra-args: -D BOOST_CI_INSTALL_TEST=OFF + ref-source-dir: boost-root/libs/yaml/test/cmake_test + + - name: Root Project CMake Workflow + uses: alandefreitas/cpp-actions/cmake-workflow@v1.8.8 + if: ${{ matrix.build-cmake || matrix.is-earliest }} + with: + source-dir: boost-root/libs/${{ steps.patch.outputs.module }} + build-dir: __build_root_test__ + build-target: tests + run-tests: true + generator: ${{ matrix.generator }} + generator-toolset: ${{ matrix.generator-toolset }} + build-type: ${{ matrix.build-type }} + install: false + cxxstd: ${{ matrix.latest-cxxstd }} + cc: ${{ steps.setup-cpp.outputs.cc || matrix.cc }} + ccflags: ${{ matrix.ccflags }} + cxx: ${{ steps.setup-cpp.outputs.cxx || matrix.cxx }} + cxxflags: ${{ matrix.cxxflags }} + shared: ${{ matrix.shared }} + cmake-version: '>=3.20' + package: false + package-artifact: false + ref-source-dir: boost-root + toolchain: ${{ (startsWith(matrix.runs-on, 'windows') && steps.patch-user-config.outputs.toolchain) || '' }} - name: FlameGraph - uses: alandefreitas/cpp-actions/flamegraph@v1.8.10 - if: matrix.time-trace == 'true' + uses: alandefreitas/cpp-actions/flamegraph@v1.8.8 + if: matrix.time-trace with: - build-dir: build + source-dir: boost-root/libs/yaml + build-dir: boost-root/__build_cmake_test__ github_token: ${{ secrets.GITHUB_TOKEN }} - name: Codecov - if: ${{ matrix.coverage == 'true' }} + if: ${{ matrix.coverage }} run: | - set -xe + set -x + + # Generate report gcov_tool="gcov" - if command -v "gcov-${{ matrix.version }}" &> /dev/null; then - gcov_tool="gcov-${{ matrix.version }}" + if command -v "gcov-${{ steps.setup-cpp.outputs.version-major }}.${{ steps.setup-cpp.outputs.version-minor }}" &> /dev/null; then + gcov_tool="gcov" + elif command -v "gcov-${{ steps.setup-cpp.outputs.version-major }}" &> /dev/null; then + gcov_tool="gcov-${{ steps.setup-cpp.outputs.version-major }}" + fi + lcov -c -q -o "boost-root/__build_cmake_test__/coverage.info" -d "boost-root/__build_cmake_test__" --include "$(pwd)/boost-root/libs/${{steps.patch.outputs.module}}/*" --gcov-tool "$gcov_tool" + + # Upload to codecov + bash <(curl -s https://codecov.io/bash) -f "boost-root/__build_cmake_test__/coverage.info" + + # Summary + echo "# Coverage" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "[![codecov](https://codecov.io/github/$GITHUB_REPOSITORY/commit/$GITHUB_SHA/graphs/sunburst.svg)](https://codecov.io/github/$GITHUB_REPOSITORY/commit/$GITHUB_SHA)" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "Commit: [![codecov](https://codecov.io/github/$GITHUB_REPOSITORY/commit/$GITHUB_SHA/graph/badge.svg)](https://codecov.io/github/$GITHUB_REPOSITORY/commit/$GITHUB_SHA)" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "Branch: [![codecov](https://codecov.io/github/$GITHUB_REPOSITORY/branch/$GITHUB_REF_NAME/graph/badge.svg)](https://codecov.io/github/$GITHUB_REPOSITORY/commit/$GITHUB_SHA)" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + + changelog: + needs: [ runner-selection ] + defaults: + run: + shell: bash + + name: Changelog Summary + runs-on: ${{ fromJSON(needs.runner-selection.outputs.labelmatrix)['ubuntu-22.04'] }} + timeout-minutes: 120 + + steps: + - name: Clone Boost.Yaml + uses: actions/checkout@v4 + with: + # Avoid the common API rate limit exceeded error in boostorg by including 100 latest commits in any case + fetch-depth: 100 + + - name: Changelog + uses: alandefreitas/cpp-actions/create-changelog@v1.8.8 + with: + thank-non-regular: ${{ startsWith(github.ref, 'refs/tags/') }} + github-token: ${{ secrets.GITHUB_TOKEN }} + limit: 200 + tag-pattern: 'boost-.*\..*\..*' + + antora: + needs: [ runner-selection ] + strategy: + fail-fast: false + matrix: + include: + - { name: Windows, os: windows-latest } + - { name: Ubuntu, os: ubuntu-latest } + - { name: MacOS, os: macos-15 } + name: Antora Docs (${{ matrix.name }}) + runs-on: ${{ fromJSON(needs.runner-selection.outputs.labelmatrix)[matrix.os] }} + defaults: + run: + shell: bash + steps: + - name: Install packages + uses: alandefreitas/cpp-actions/package-install@v1.8.8 + with: + apt-get: git cmake + + - name: Clone Boost.Yaml + uses: actions/checkout@v3 + with: + path: yaml-root + + - name: Clone Boost + uses: alandefreitas/cpp-actions/boost-clone@v1.8.8 + id: boost-clone + with: + branch: ${{ (github.ref_name == 'master' && github.ref_name) || 'develop' }} + boost-dir: boost-source + cache: false + modules-exclude-paths: '' + scan-modules-dir: yaml-root + scan-modules-ignore: yaml + + - name: Patch Boost + id: patch + shell: bash + run: | + set -xe + pwd + ls + ls -lah boost-source + + # Identify boost module being tested + module=${GITHUB_REPOSITORY#*/} + echo "module=$module" >> $GITHUB_OUTPUT + + # Identify GitHub workspace root + workspace_root=$(echo "$GITHUB_WORKSPACE" | sed 's/\\/\//g') + echo -E "workspace_root=$workspace_root" >> $GITHUB_OUTPUT + + # Remove module from boost-source + rm -r "boost-source/libs/$module" || true + + # Copy cached boost-source to an isolated boost-root + cp -r boost-source boost-root + + # Set boost-root output + cd boost-root + boost_root="$(pwd)" + boost_root=$(echo "$boost_root" | sed 's/\\/\//g') + echo -E "boost_root=$boost_root" >> $GITHUB_OUTPUT + + # Patch boost-root with workspace module + cp -r "$workspace_root"/yaml-root "libs/$module" + + + - uses: actions/setup-node@v4 + with: + node-version: 18 + + - name: Setup Ninja + if: runner.os == 'Windows' + uses: seanmiddleditch/gha-setup-ninja@v5 + + - name: Build Antora Docs + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + git config --global --add safe.directory "$(pwd)" + + BOOST_SRC_DIR="$(pwd)/boost-root" + export BOOST_SRC_DIR + cd boost-root/libs/yaml + + cd doc + bash ./build_antora.sh + + # Antora returns zero even if it fails, so we check if the site directory exists + if [ ! -d "build/site" ]; then + echo "Antora build failed" + exit 1 fi - lcov --gcov-tool "$gcov_tool" -c -q -o "./coverage.info" -d "./build" - bash <(curl -s https://codecov.io/bash) -f "./coverage.info" + + - name: Create Antora Docs Artifact + uses: actions/upload-artifact@v4 + with: + name: antora-docs-${{ matrix.name }} + path: doc/build/site diff --git a/doc/.gitignore b/doc/.gitignore new file mode 100644 index 0000000..dd87e2d --- /dev/null +++ b/doc/.gitignore @@ -0,0 +1,2 @@ +node_modules +build diff --git a/doc/build_antora.sh b/doc/build_antora.sh new file mode 100755 index 0000000..b2a904c --- /dev/null +++ b/doc/build_antora.sh @@ -0,0 +1,28 @@ +# +# Copyright (c) 2024 Boost.Yaml Authors +# +# 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) +# +# Official repository: https://github.com/cppalliance/yaml +# + +set -xe + +if [ $# -eq 0 ] + then + echo "No playbook supplied, using default playbook" + PLAYBOOK="local-playbook.yml" + else + PLAYBOOK=$1 +fi + +echo "Building documentation with Antora..." +echo "Installing npm dependencies..." +npm ci + +echo "Building docs in custom dir..." +PATH="$(pwd)/node_modules/.bin:${PATH}" +export PATH +npx antora --clean --fetch "$PLAYBOOK" --stacktrace --log-level all +echo "Done" diff --git a/doc/local-playbook.yml b/doc/local-playbook.yml new file mode 100644 index 0000000..bc70bba --- /dev/null +++ b/doc/local-playbook.yml @@ -0,0 +1,40 @@ +site: + title: Boost.Yaml + url: https://antora.cppalliance.org/develop/lib/doc + start_page: yaml::index.adoc + robots: allow + keys: + repo_url: 'https://github.com/cppalliance/yaml' + +content: + sources: + - url: .. + start_path: doc + edit_url: 'https://github.com/cppalliance/yaml/edit/{refname}/{path}' + +ui: + bundle: + url: https://github.com/boostorg/website-v2-docs/releases/download/ui-develop/ui-bundle.zip + snapshot: true + +antora: + extensions: + - require: '@cppalliance/antora-cpp-tagfiles-extension' + cpp-tagfiles: + using-namespaces: + - 'boost::' + - require: '@cppalliance/antora-cpp-reference-extension' + dependencies: + - name: 'boost' + repo: 'https://github.com/boostorg/boost.git' + tag: 'develop' + variable: 'BOOST_SRC_DIR' + system-env: 'BOOST_SRC_DIR' + +asciidoc: + attributes: + # Enable pagination + page-pagination: '' + extensions: + - '@cppalliance/asciidoctor-boost-links' + - '@asciidoctor/tabs' diff --git a/doc/package.json b/doc/package.json new file mode 100644 index 0000000..fdc1849 --- /dev/null +++ b/doc/package.json @@ -0,0 +1,15 @@ +{ + "devDependencies": { + "@antora/cli": "3.1.3", + "@antora/site-generator": "3.1.3", + "antora": "3.1.3" + }, + "dependencies": { + "@cppalliance/antora-cpp-reference-extension": "^0.0.6", + "@cppalliance/antora-cpp-tagfiles-extension": "^0.0.4", + "@cppalliance/asciidoctor-boost-links": "^0.0.2", + "@antora/expand-path-helper": "^2.0.0", + "@antora/lunr-extension": "^1.0.0-alpha.8", + "@asciidoctor/tabs": "^1.0.0-beta.3" + } +} diff --git a/test/cmake_test/CMakeLists.txt b/test/cmake_test/CMakeLists.txt new file mode 100644 index 0000000..4ede984 --- /dev/null +++ b/test/cmake_test/CMakeLists.txt @@ -0,0 +1,40 @@ +# +# Copyright (c) 2024 Boost.Yaml Authors +# +# Distributed under the Boost Software License, Version 1.0. +# https://www.boost.org/LICENSE_1_0.txt +# + +cmake_minimum_required(VERSION 3.5...3.16) + +project(cmake_subdir_test LANGUAGES CXX) +set(__ignore__ ${CMAKE_C_COMPILER}) +set(__ignore__ ${CMAKE_C_FLAGS}) + +if(BOOST_CI_INSTALL_TEST) + find_package(Boost CONFIG REQUIRED COMPONENTS yaml) +else() + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) + add_subdirectory(../.. boostorg/yaml) + + set(deps + # Primary dependencies + + assert + config + core + system + variant2 + ) + + foreach(dep IN LISTS deps) + add_subdirectory(../../../${dep} boostorg/${dep} EXCLUDE_FROM_ALL) + endforeach() +endif() + +add_executable(main main.cpp) +target_link_libraries(main Boost::yaml) + +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 0000000..5ae9c41 --- /dev/null +++ b/test/cmake_test/main.cpp @@ -0,0 +1,23 @@ +// +// Copyright (c) 2024 Boost.Yaml Authors +// +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt +// + +#include + +int main() { + // Test basic YAML parsing + auto result = boost::yaml::parse("key: value"); + if (!result) { + return 1; + } + + auto& value = result.value(); + if (!value.is_mapping()) { + return 2; + } + + return 0; +}