|
| 1 | +# Copyright 2020-2021 Peter Dimov |
| 2 | +# Copyright 2021 Andrey Semashev |
| 3 | +# Copyright 2021 Alexander Grund |
| 4 | +# Copyright 2022 James E. King III |
| 5 | +# Copyright 2023 Matt Borland |
| 6 | +# |
| 7 | +# Distributed under the Boost Software License, Version 1.0. |
| 8 | +# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt) |
| 9 | +--- |
| 10 | +name: codecov |
| 11 | + |
| 12 | +on: |
| 13 | + pull_request: |
| 14 | + push: |
| 15 | + branches: |
| 16 | + - master |
| 17 | + - develop |
| 18 | + - bugfix/** |
| 19 | + - feature/** |
| 20 | + - fix/** |
| 21 | + - pr/** |
| 22 | + |
| 23 | +env: |
| 24 | + GIT_FETCH_JOBS: 8 |
| 25 | + NET_RETRY_COUNT: 5 |
| 26 | + B2_CI_VERSION: 1 |
| 27 | + B2_VARIANT: release |
| 28 | + B2_LINK: shared |
| 29 | + LCOV_BRANCH_COVERAGE: 0 |
| 30 | + CODECOV_NAME: Github Actions |
| 31 | + |
| 32 | +jobs: |
| 33 | + posix: |
| 34 | + defaults: |
| 35 | + run: |
| 36 | + shell: bash |
| 37 | + |
| 38 | + strategy: |
| 39 | + fail-fast: false |
| 40 | + matrix: |
| 41 | + include: |
| 42 | + - { name: Collect coverage special_fun, coverage: yes, |
| 43 | + compiler: gcc-12, cxxstd: '20', os: ubuntu-22.04, install: 'g++-12-multilib', address-model: '64', suite: 'special_fun' } |
| 44 | + - { name: Collect coverage distribution_tests, coverage: yes, |
| 45 | + compiler: gcc-12, cxxstd: '20', os: ubuntu-22.04, install: 'g++-12-multilib', address-model: '64', suite: 'distribution_tests' } |
| 46 | + - { name: Collect coverage mp, coverage: yes, |
| 47 | + compiler: gcc-12, cxxstd: '20', os: ubuntu-22.04, install: 'g++-12-multilib', address-model: '64', suite: 'mp' } |
| 48 | + - { name: Collect coverage misc, coverage: yes, |
| 49 | + compiler: gcc-12, cxxstd: '20', os: ubuntu-22.04, install: 'g++-12-multilib', address-model: '64', suite: 'misc' } |
| 50 | + - { name: Collect coverage quadrature, coverage: yes, |
| 51 | + compiler: gcc-12, cxxstd: '20', os: ubuntu-22.04, install: 'g++-12-multilib', address-model: '64', suite: 'quadrature' } |
| 52 | + - { name: Collect coverage interpolators, coverage: yes, |
| 53 | + compiler: gcc-12, cxxstd: '20', os: ubuntu-22.04, install: 'g++-12-multilib', address-model: '64', suite: 'interpolators' } |
| 54 | + - { name: Collect coverage autodiff, coverage: yes, |
| 55 | + compiler: gcc-12, cxxstd: '20', os: ubuntu-22.04, install: 'g++-12-multilib', address-model: '64', suite: 'autodiff' } |
| 56 | + timeout-minutes: 360 |
| 57 | + runs-on: ${{matrix.os}} |
| 58 | + container: ${{matrix.container}} |
| 59 | + env: {B2_USE_CCACHE: 1} |
| 60 | + |
| 61 | + steps: |
| 62 | + - name: Setup environment |
| 63 | + run: | |
| 64 | + if [ -f "/etc/debian_version" ]; then |
| 65 | + echo "DEBIAN_FRONTEND=noninteractive" >> $GITHUB_ENV |
| 66 | + export DEBIAN_FRONTEND=noninteractive |
| 67 | + fi |
| 68 | + if [ -n "${{matrix.container}}" ] && [ -f "/etc/debian_version" ]; then |
| 69 | + apt-get -o Acquire::Retries=$NET_RETRY_COUNT update |
| 70 | + apt-get -o Acquire::Retries=$NET_RETRY_COUNT install -y sudo software-properties-common curl |
| 71 | + # Need (newer) git, and the older Ubuntu container may require requesting the key manually using port 80 |
| 72 | + curl -sSL --retry ${NET_RETRY_COUNT:-5} 'http://keyserver.ubuntu.com/pks/lookup?op=get&search=0xE1DD270288B4E6030699E45FA1715D88E1DF1F24' | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/git-core_ubuntu_ppa.gpg |
| 73 | + for i in {1..${NET_RETRY_COUNT:-3}}; do sudo -E add-apt-repository -y ppa:git-core/ppa && break || sleep 10; done |
| 74 | + apt-get -o Acquire::Retries=$NET_RETRY_COUNT update |
| 75 | + osver=$(lsb_release -sr | cut -f1 -d.) |
| 76 | + pkgs="g++ git" |
| 77 | + # Ubuntu 22+ has only Python 3 in the repos |
| 78 | + if [ -n "$osver" ] && [ "$osver" -ge "22" ]; then |
| 79 | + pkgs+=" python-is-python3 libpython3-dev" |
| 80 | + else |
| 81 | + pkgs+=" python libpython-dev" |
| 82 | + fi |
| 83 | + apt-get -o Acquire::Retries=$NET_RETRY_COUNT install -y $pkgs |
| 84 | + fi |
| 85 | + # For jobs not compatible with ccache, use "ccache: no" in the matrix |
| 86 | + if [[ "${{ matrix.ccache }}" == "no" ]]; then |
| 87 | + echo "B2_USE_CCACHE=0" >> $GITHUB_ENV |
| 88 | + fi |
| 89 | + git config --global pack.threads 0 |
| 90 | +
|
| 91 | + - uses: actions/checkout@v3 |
| 92 | + with: |
| 93 | + # For coverage builds fetch the whole history, else only 1 commit using a 'fake ternary' |
| 94 | + fetch-depth: ${{ matrix.coverage && '0' || '1' }} |
| 95 | + |
| 96 | + - name: Cache ccache |
| 97 | + uses: actions/cache@v3 |
| 98 | + if: env.B2_USE_CCACHE |
| 99 | + with: |
| 100 | + path: ~/.ccache |
| 101 | + key: ${{matrix.os}}-${{matrix.container}}-${{matrix.compiler}}-${{github.sha}} |
| 102 | + restore-keys: ${{matrix.os}}-${{matrix.container}}-${{matrix.compiler}}- |
| 103 | + |
| 104 | + - name: Fetch Boost.CI |
| 105 | + uses: actions/checkout@v3 |
| 106 | + with: |
| 107 | + repository: boostorg/boost-ci |
| 108 | + ref: master |
| 109 | + path: boost-ci-cloned |
| 110 | + |
| 111 | + - name: Get CI scripts folder |
| 112 | + run: | |
| 113 | + # Copy ci folder if not testing Boost.CI |
| 114 | + [[ "$GITHUB_REPOSITORY" =~ "boost-ci" ]] || cp -r boost-ci-cloned/ci . |
| 115 | + rm -rf boost-ci-cloned |
| 116 | +
|
| 117 | + - name: Install packages |
| 118 | + if: startsWith(matrix.os, 'ubuntu') |
| 119 | + run: | |
| 120 | + SOURCE_KEYS=(${{join(matrix.source_keys, ' ')}}) |
| 121 | + SOURCES=(${{join(matrix.sources, ' ')}}) |
| 122 | + # Add this by default |
| 123 | + SOURCES+=(ppa:ubuntu-toolchain-r/test) |
| 124 | + for key in "${SOURCE_KEYS[@]}"; do |
| 125 | + for i in {1..$NET_RETRY_COUNT}; do |
| 126 | + keyfilename=$(basename -s .key $key) |
| 127 | + curl -sSL --retry ${NET_RETRY_COUNT:-5} "$key" | sudo gpg --dearmor > /etc/apt/trusted.gpg.d/${keyfilename} && break || sleep 10 |
| 128 | + done |
| 129 | + done |
| 130 | + for source in "${SOURCES[@]}"; do |
| 131 | + for i in {1..$NET_RETRY_COUNT}; do |
| 132 | + sudo add-apt-repository $source && break || sleep 10 |
| 133 | + done |
| 134 | + done |
| 135 | + sudo apt-get -o Acquire::Retries=$NET_RETRY_COUNT update |
| 136 | + if [[ -z "${{matrix.install}}" ]]; then |
| 137 | + pkgs="${{matrix.compiler}}" |
| 138 | + pkgs="${pkgs/gcc-/g++-}" |
| 139 | + else |
| 140 | + pkgs="${{matrix.install}}" |
| 141 | + fi |
| 142 | + sudo apt-get -o Acquire::Retries=$NET_RETRY_COUNT install -y $pkgs |
| 143 | +
|
| 144 | + - name: Setup GCC Toolchain |
| 145 | + if: matrix.gcc_toolchain |
| 146 | + run: | |
| 147 | + GCC_TOOLCHAIN_ROOT="$HOME/gcc-toolchain" |
| 148 | + echo "GCC_TOOLCHAIN_ROOT=$GCC_TOOLCHAIN_ROOT" >> $GITHUB_ENV |
| 149 | + if ! command -v dpkg-architecture; then |
| 150 | + apt-get install -y dpkg-dev |
| 151 | + fi |
| 152 | + MULTIARCH_TRIPLET="$(dpkg-architecture -qDEB_HOST_MULTIARCH)" |
| 153 | + mkdir -p "$GCC_TOOLCHAIN_ROOT" |
| 154 | + ln -s /usr/include "$GCC_TOOLCHAIN_ROOT/include" |
| 155 | + ln -s /usr/bin "$GCC_TOOLCHAIN_ROOT/bin" |
| 156 | + mkdir -p "$GCC_TOOLCHAIN_ROOT/lib/gcc/$MULTIARCH_TRIPLET" |
| 157 | + ln -s "/usr/lib/gcc/$MULTIARCH_TRIPLET/${{matrix.gcc_toolchain}}" "$GCC_TOOLCHAIN_ROOT/lib/gcc/$MULTIARCH_TRIPLET/${{matrix.gcc_toolchain}}" |
| 158 | +
|
| 159 | + - name: Setup multiarch |
| 160 | + if: matrix.multiarch |
| 161 | + run: | |
| 162 | + sudo apt-get install --no-install-recommends -y binfmt-support qemu-user-static |
| 163 | + sudo docker run --rm --privileged multiarch/qemu-user-static --reset -p yes |
| 164 | + git clone https://github.com/jeking3/bdde.git |
| 165 | + echo "$(pwd)/bdde/bin/linux" >> ${GITHUB_PATH} |
| 166 | + echo "BDDE_DISTRO=${{ matrix.distro }}" >> ${GITHUB_ENV} |
| 167 | + echo "BDDE_EDITION=${{ matrix.edition }}" >> ${GITHUB_ENV} |
| 168 | + echo "BDDE_ARCH=${{ matrix.arch }}" >> ${GITHUB_ENV} |
| 169 | + echo "B2_WRAPPER=bdde" >> ${GITHUB_ENV} |
| 170 | +
|
| 171 | + - name: Setup Boost |
| 172 | + env: |
| 173 | + B2_ADDRESS_MODEL: ${{matrix.address-model}} |
| 174 | + B2_COMPILER: ${{matrix.compiler}} |
| 175 | + B2_CXXSTD: ${{matrix.cxxstd}} |
| 176 | + B2_SANITIZE: ${{matrix.sanitize}} |
| 177 | + B2_STDLIB: ${{matrix.stdlib}} |
| 178 | + # More entries can be added in the same way, see the B2_ARGS assignment in ci/enforce.sh for the possible keys. |
| 179 | + B2_DEFINES: CI_SUPPRESS_KNOWN_ISSUES=1 SLOW_COMPILER=1 BOOST_MATH_NO_REAL_CONCEPT_TESTS=1 |
| 180 | + # Variables set here (to non-empty) will override the top-level environment variables, e.g. |
| 181 | + # B2_VARIANT: ${{matrix.variant}} |
| 182 | + # Set the (B2) target(s) to build, defaults to the test folder of the current library |
| 183 | + # Can alternatively be done like this in the build step or in the build command of the build step, e.g. `run: B2_TARGETS=libs/$SELF/doc ci/build.sh` |
| 184 | + B2_TARGETS: libs/math/test//${{ matrix.suite }} |
| 185 | + run: source ci/github/install.sh |
| 186 | + |
| 187 | + - name: Setup coverage collection |
| 188 | + if: matrix.coverage |
| 189 | + run: ci/github/codecov.sh "setup" |
| 190 | + |
| 191 | + - name: Run tests |
| 192 | + if: '!matrix.coverity' |
| 193 | + run: ci/build.sh |
| 194 | + |
| 195 | + - name: Upload coverage |
| 196 | + if: matrix.coverage |
| 197 | + run: ci/codecov.sh "upload" |
0 commit comments