From cd6847aee883a0387531cc4badbe418485eaaa47 Mon Sep 17 00:00:00 2001 From: Andrey Semashev Date: Mon, 6 Sep 2021 01:11:33 +0300 Subject: [PATCH] Update GitHub Actions config to switch Ubuntu 16.04 jobs to Docker containers. The Ubuntu 16.04 environment is scheduled to be removed from GitHub Actions in September 2021. Migrate those jobs to Docker containers or Ubuntu 18.04. Also, added some older compilers. Ported CMake tests from Travis CI. Based on https://github.com/boostorg/core/pull/95. Closes https://github.com/boostorg/core/pull/95. --- .github/workflows/ci.yml | 274 ++++++++++++++++++++++++++++----------- 1 file changed, 201 insertions(+), 73 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bd3f639..3a188bf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,3 +1,9 @@ +# Copyright 2020-2021 Peter Dimov +# Copyright 2021 Andrey Semashev +# +# 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 on: @@ -14,32 +20,48 @@ concurrency: env: GIT_FETCH_JOBS: 8 - UBSAN_OPTIONS: print_stacktrace=1 jobs: posix: + defaults: + run: + shell: bash + strategy: fail-fast: false matrix: include: + - toolset: gcc-4.4 + cxxstd: "98,0x" + os: ubuntu-20.04 + container: ubuntu:16.04 + install: g++-4.4 + - toolset: gcc-4.6 + cxxstd: "03,0x" + os: ubuntu-20.04 + container: ubuntu:16.04 + install: g++-4.6 - toolset: gcc-4.7 cxxstd: "03,11" - os: ubuntu-16.04 + os: ubuntu-20.04 + container: ubuntu:16.04 install: g++-4.7 - toolset: gcc-4.8 cxxstd: "03,11" - os: ubuntu-16.04 + os: ubuntu-18.04 install: g++-4.8 - toolset: gcc-4.9 cxxstd: "03,11" - os: ubuntu-16.04 + os: ubuntu-20.04 + container: ubuntu:16.04 install: g++-4.9 - toolset: gcc-5 cxxstd: "03,11,14,1z" - os: ubuntu-16.04 + os: ubuntu-20.04 + container: ubuntu:16.04 - toolset: gcc-6 cxxstd: "03,11,14,1z" - os: ubuntu-16.04 + os: ubuntu-18.04 install: g++-6 - toolset: gcc-7 cxxstd: "03,11,14,17" @@ -58,40 +80,51 @@ jobs: cxxstd: "03,11,14,17,20" os: ubuntu-20.04 install: g++-11 + - name: UBSAN + toolset: gcc-11 + cxxstd: "03,11,14,17,20" + ubsan: 1 + os: ubuntu-20.04 + install: g++-11 + - toolset: clang compiler: clang++-3.5 cxxstd: "03,11" - os: ubuntu-16.04 + os: ubuntu-20.04 + container: ubuntu:16.04 install: clang-3.5 - toolset: clang compiler: clang++-3.6 cxxstd: "03,11,14" - os: ubuntu-16.04 + os: ubuntu-20.04 + container: ubuntu:16.04 install: clang-3.6 - toolset: clang compiler: clang++-3.7 cxxstd: "03,11,14" - os: ubuntu-16.04 + os: ubuntu-20.04 + container: ubuntu:16.04 install: clang-3.7 - toolset: clang compiler: clang++-3.8 cxxstd: "03,11,14" - os: ubuntu-16.04 + os: ubuntu-20.04 + container: ubuntu:16.04 install: clang-3.8 - toolset: clang compiler: clang++-3.9 cxxstd: "03,11,14" - os: ubuntu-16.04 + os: ubuntu-18.04 install: clang-3.9 - toolset: clang compiler: clang++-4.0 cxxstd: "03,11,14" - os: ubuntu-16.04 + os: ubuntu-18.04 install: clang-4.0 - toolset: clang compiler: clang++-5.0 cxxstd: "03,11,14,1z" - os: ubuntu-16.04 + os: ubuntu-18.04 install: clang-5.0 - toolset: clang compiler: clang++-6.0 @@ -126,71 +159,166 @@ jobs: compiler: clang++-12 cxxstd: "03,11,14,17,20" os: ubuntu-20.04 + - toolset: clang + compiler: clang++-12 + cxxstd: "03,11,14,17,20" + os: ubuntu-20.04 + install: libc++-12-dev libc++abi-12-dev + cxxflags: -stdlib=libc++ + linkflags: -stdlib=libc++ + - name: UBSAN + toolset: clang + compiler: clang++-12 + cxxstd: "03,11,14,17,20" + ubsan: 1 + os: ubuntu-20.04 + install: libc++-12-dev libc++abi-12-dev + cxxflags: -stdlib=libc++ + linkflags: -stdlib=libc++ + - toolset: clang cxxstd: "03,11,14,17,2a" os: macos-10.15 + - name: CMake tests + cmake_tests: 1 + os: ubuntu-20.04 + runs-on: ${{matrix.os}} + container: ${{matrix.container}} steps: + - name: Setup container + if: matrix.container + run: | + echo "GHA_CONTAINER=${{matrix.container}}" >> $GITHUB_ENV + apt-get -o Acquire::Retries=3 update && DEBIAN_FRONTEND=noninteractive apt-get -o Acquire::Retries=3 install -y sudo software-properties-common tzdata wget curl apt-transport-https make apt-file unzip libssl-dev build-essential autotools-dev autoconf automake g++ libc++-helpers python ruby cpio gcc-multilib g++-multilib pkgconf python3 ccache libpython-dev git cmake + - uses: actions/checkout@v2 - name: Install packages if: matrix.install run: | - sudo apt-get update - sudo apt-get install ${{matrix.install}} + for i in {1..3}; do sudo -E apt-add-repository -y "ppa:ubuntu-toolchain-r/test" && break || sleep 2; done + sudo apt-get update + sudo apt-get install -y ${{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}}" + 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 - 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 $GIT_FETCH_JOBS" $LIBRARY - ./bootstrap.sh - ./b2 -d0 headers + 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 //')" + if $(dpkg --compare-versions "$GIT_VERSION" ge 2.8.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 + if [ -n "${{matrix.extra_tests}}" ] + then + DEPINST_ARGS+=("--include" "example") + fi + DEPINST_ARGS+=("$LIBRARY") + python tools/boostdep/depinst/depinst.py "${DEPINST_ARGS[@]}" + ./bootstrap.sh + ./b2 headers - name: Create user-config.jam - if: matrix.compiler + if: matrix.cmake_tests == '' && matrix.compiler != '' run: | - 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 + 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 - name: Run tests + if: matrix.cmake_tests == '' run: | - BUILD_JOBS=$((nproc || sysctl -n hw.ncpu) 2> /dev/null) - cd ../boost-root - ./b2 -j $BUILD_JOBS libs/$LIBRARY/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} variant=debug,release + cd ../boost-root + B2_ARGS=("-j" "$BUILD_JOBS" "toolset=${{matrix.toolset}}" "cxxstd=${{matrix.cxxstd}}" "variant=debug,release") + 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 + B2_ARGS+=("libs/$LIBRARY/test") + ./b2 "${B2_ARGS[@]}" + + - name: Run CMake tests + if: matrix.cmake_tests != '' + run: | + cd ../boost-root + export CMAKE_TEST=1 + mkdir __build_cmake_test__ && cd __build_cmake_test__ + cmake -DBUILD_TESTING=ON -DBOOST_INCLUDE_LIBRARIES=$LIBRARY .. + cmake --build . --target tests + ctest --output-on-failure + + - name: Run CMake subdir tests + if: matrix.cmake_tests != '' + run: | + cd ../boost-root + export CMAKE_SUBDIR_TEST=1 + cd libs/$LIBRARY/test/cmake_subdir_test && mkdir __build_cmake_subdir_test__ && cd __build_cmake_subdir_test__ + cmake .. + cmake --build . + cmake --build . --target check + + - name: Run CMake install tests + if: matrix.cmake_tests != '' + run: | + cd ../boost-root + export CMAKE_INSTALL_TEST=1 + mkdir __build_cmake_install_test__ && cd __build_cmake_install_test__ + cmake -DBOOST_INCLUDE_LIBRARIES=$LIBRARY -DCMAKE_INSTALL_PREFIX=~/.local .. + cmake --build . --target install + cd libs/$LIBRARY/test/cmake_install_test && mkdir __build_cmake_install_test__ && cd __build_cmake_install_test__ + cmake -DCMAKE_INSTALL_PREFIX=~/.local .. + cmake --build . + cmake --build . --target check windows: strategy: @@ -218,27 +346,27 @@ jobs: - 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 %GIT_FETCH_JOBS%" %LIBRARY% - cmd /c bootstrap - b2 -d0 headers + 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 %GIT_FETCH_JOBS%" %LIBRARY% + cmd /c bootstrap + b2 -d0 headers - name: Run tests shell: cmd run: | - cd ../boost-root - b2 -j %NUMBER_OF_PROCESSORS% libs/%LIBRARY%/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} address-model=${{matrix.addrmd}} variant=debug,release + cd ../boost-root + b2 -j %NUMBER_OF_PROCESSORS% libs/%LIBRARY%/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} address-model=${{matrix.addrmd}} variant=debug,release