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+ # Copyright 2026 Arnaud Becheler
7+ #
8+ # Distributed under the Boost Software License, Version 1.0.
9+ # (See accompanying file LICENSE or copy at http://boost.org/LICENSE_1_0.txt)
10+ ---
11+ name : codecov
12+
13+ on :
14+ pull_request :
15+ push :
16+ branches :
17+ - master
18+ - develop
19+ - bugfix/**
20+ - feature/**
21+ - fix/**
22+ - pr/**
23+
24+ env :
25+ GIT_FETCH_JOBS : 8
26+ NET_RETRY_COUNT : 5
27+ B2_CI_VERSION : 1
28+ B2_VARIANT : debug,release
29+ B2_LINK : shared,static
30+ LCOV_BRANCH_COVERAGE : 1
31+ # gcov emits an unwind edge for every call it cannot prove nothrow, so any line
32+ # calling e.g. BOOST_TEST_EQ carries a branch that is never taken. Drop those,
33+ # and the lone fallthrough left behind, so only real conditionals are reported.
34+ # region and branch_region are what implement the LCOV_EXCL_LINE, LCOV_EXCL_START
35+ # and LCOV_EXCL_BR_* markers. lcov enables them by default only when --filter is
36+ # absent, so they have to be listed here or every marker in the tree is ignored.
37+ LCOV_OPTIONS : --filter region,branch_region,exception,orphan
38+ CODECOV_NAME : Github Actions
39+ ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION : true
40+
41+ jobs :
42+ posix :
43+ defaults :
44+ run :
45+ shell : bash
46+
47+ strategy :
48+ fail-fast : false
49+ matrix :
50+ include :
51+ - { name: Collect coverage, coverage: yes,
52+ compiler : gcc-14, cxxstd: '23', os: ubuntu-24.04, install: 'g++-14', address-model: '64' }
53+
54+ timeout-minutes : 120
55+ runs-on : ${{matrix.os}}
56+ container : ${{matrix.container}}
57+ env : {B2_USE_CCACHE: 1}
58+
59+ steps :
60+ - name : Setup environment
61+ run : |
62+ if [ -f "/etc/debian_version" ]; then
63+ echo "DEBIAN_FRONTEND=noninteractive" >> $GITHUB_ENV
64+ export DEBIAN_FRONTEND=noninteractive
65+ fi
66+ if [ -n "${{matrix.container}}" ] && [ -f "/etc/debian_version" ]; then
67+ apt-get -o Acquire::Retries=$NET_RETRY_COUNT update
68+ apt-get -o Acquire::Retries=$NET_RETRY_COUNT install -y sudo software-properties-common curl
69+ # Need (newer) git, and the older Ubuntu container may require requesting the key manually using port 80
70+ 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
71+ for i in {1..${NET_RETRY_COUNT:-3}}; do sudo -E add-apt-repository -y ppa:git-core/ppa && break || sleep 10; done
72+ apt-get -o Acquire::Retries=$NET_RETRY_COUNT update
73+ osver=$(lsb_release -sr | cut -f1 -d.)
74+ pkgs="g++ git"
75+ # Ubuntu 22+ has only Python 3 in the repos
76+ if [ -n "$osver" ] && [ "$osver" -ge "22" ]; then
77+ pkgs+=" python-is-python3 libpython3-dev"
78+ else
79+ pkgs+=" python libpython-dev"
80+ fi
81+ apt-get -o Acquire::Retries=$NET_RETRY_COUNT install -y $pkgs
82+ fi
83+ # For jobs not compatible with ccache, use "ccache: no" in the matrix
84+ if [[ "${{ matrix.ccache }}" == "no" ]]; then
85+ echo "B2_USE_CCACHE=0" >> $GITHUB_ENV
86+ fi
87+ git config --global pack.threads 0
88+
89+ - uses : actions/checkout@v4
90+ with :
91+ # For coverage builds fetch the whole history, else only 1 commit using a 'fake ternary'
92+ fetch-depth : ${{ matrix.coverage && '0' || '1' }}
93+
94+ - name : Cache ccache
95+ uses : actions/cache@v4
96+ if : env.B2_USE_CCACHE
97+ with :
98+ path : ~/.ccache
99+ key : ${{matrix.os}}-${{matrix.container}}-${{matrix.compiler}}-${{github.sha}}
100+ restore-keys : ${{matrix.os}}-${{matrix.container}}-${{matrix.compiler}}-
101+
102+ - name : Fetch Boost.CI
103+ uses : actions/checkout@v4
104+ with :
105+ repository : boostorg/boost-ci
106+ ref : master
107+ path : boost-ci-cloned
108+
109+ - name : Get CI scripts folder
110+ run : |
111+ # Copy ci folder if not testing Boost.CI
112+ [[ "$GITHUB_REPOSITORY" =~ "boost-ci" ]] || cp -r boost-ci-cloned/ci .
113+ rm -rf boost-ci-cloned
114+
115+ - name : Install packages
116+ if : startsWith(matrix.os, 'ubuntu')
117+ run : |
118+ SOURCE_KEYS=(${{join(matrix.source_keys, ' ')}})
119+ SOURCES=(${{join(matrix.sources, ' ')}})
120+ # Add this by default
121+ SOURCES+=(ppa:ubuntu-toolchain-r/test)
122+ for key in "${SOURCE_KEYS[@]}"; do
123+ for i in {1..$NET_RETRY_COUNT}; do
124+ keyfilename=$(basename -s .key $key)
125+ curl -sSL --retry ${NET_RETRY_COUNT:-5} "$key" | sudo gpg --dearmor > /etc/apt/trusted.gpg.d/${keyfilename} && break || sleep 10
126+ done
127+ done
128+ for source in "${SOURCES[@]}"; do
129+ for i in {1..$NET_RETRY_COUNT}; do
130+ sudo add-apt-repository $source && break || sleep 10
131+ done
132+ done
133+ sudo apt-get -o Acquire::Retries=$NET_RETRY_COUNT update
134+ if [[ -z "${{matrix.install}}" ]]; then
135+ pkgs="${{matrix.compiler}}"
136+ pkgs="${pkgs/gcc-/g++-}"
137+ else
138+ pkgs="${{matrix.install}}"
139+ fi
140+ sudo apt-get -o Acquire::Retries=$NET_RETRY_COUNT install -y $pkgs
141+
142+ - name : Setup GCC Toolchain
143+ if : matrix.gcc_toolchain
144+ run : |
145+ GCC_TOOLCHAIN_ROOT="$HOME/gcc-toolchain"
146+ echo "GCC_TOOLCHAIN_ROOT=$GCC_TOOLCHAIN_ROOT" >> $GITHUB_ENV
147+ if ! command -v dpkg-architecture; then
148+ apt-get install -y dpkg-dev
149+ fi
150+ MULTIARCH_TRIPLET="$(dpkg-architecture -qDEB_HOST_MULTIARCH)"
151+ mkdir -p "$GCC_TOOLCHAIN_ROOT"
152+ ln -s /usr/include "$GCC_TOOLCHAIN_ROOT/include"
153+ ln -s /usr/bin "$GCC_TOOLCHAIN_ROOT/bin"
154+ mkdir -p "$GCC_TOOLCHAIN_ROOT/lib/gcc/$MULTIARCH_TRIPLET"
155+ ln -s "/usr/lib/gcc/$MULTIARCH_TRIPLET/${{matrix.gcc_toolchain}}" "$GCC_TOOLCHAIN_ROOT/lib/gcc/$MULTIARCH_TRIPLET/${{matrix.gcc_toolchain}}"
156+
157+ - name : Setup multiarch
158+ if : matrix.multiarch
159+ run : |
160+ sudo apt-get install --no-install-recommends -y binfmt-support qemu-user-static
161+ sudo docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
162+ git clone https://github.com/jeking3/bdde.git
163+ echo "$(pwd)/bdde/bin/linux" >> ${GITHUB_PATH}
164+ echo "BDDE_DISTRO=${{ matrix.distro }}" >> ${GITHUB_ENV}
165+ echo "BDDE_EDITION=${{ matrix.edition }}" >> ${GITHUB_ENV}
166+ echo "BDDE_ARCH=${{ matrix.arch }}" >> ${GITHUB_ENV}
167+ echo "B2_WRAPPER=bdde" >> ${GITHUB_ENV}
168+
169+ - name : Setup Boost
170+ env :
171+ B2_ADDRESS_MODEL : ${{matrix.address-model}}
172+ B2_COMPILER : ${{matrix.compiler}}
173+ B2_CXXSTD : ${{matrix.cxxstd}}
174+ B2_SANITIZE : ${{matrix.sanitize}}
175+ B2_STDLIB : ${{matrix.stdlib}}
176+ # More entries can be added in the same way, see the B2_ARGS assignment in ci/enforce.sh for the possible keys.
177+ B2_DEFINES : ${{matrix.defines}}
178+ # Variables set here (to non-empty) will override the top-level environment variables, e.g.
179+ B2_VARIANT : ${{matrix.variant}}
180+ # Set the (B2) target(s) to build, defaults to the test folder of the current library
181+ # 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`
182+ # B2_TARGETS: libs/foo/test//bar
183+ run : source ci/github/install.sh
184+
185+ - name : Setup coverage collection
186+ if : matrix.coverage
187+ run : ci/github/codecov.sh "setup"
188+
189+ - name : Run tests
190+ if : ' !matrix.coverity'
191+ run : ci/build.sh
192+
193+ - name : Upload coverage
194+ if : matrix.coverage
195+ run : ci/codecov.sh "upload"
196+ env :
197+ BOOST_CI_CODECOV_IO_UPLOAD : skip
198+
199+ - name : Upload coverage
200+ if : matrix.coverage
201+ uses : codecov/codecov-action@v4
202+ with :
203+ disable_search : true
204+ file : coverage.info
205+ name : Github Actions
206+ token : ${{secrets.CODECOV_TOKEN}}
207+ verbose : true
208+
209+ windows :
210+ defaults :
211+ run :
212+ shell : cmd
213+ strategy :
214+ fail-fast : false
215+ matrix :
216+ include :
217+ - { name: Collect MSVC coverage, coverage: yes,
218+ toolset : msvc-14.3, cxxstd: 'latest', addrmd: '64', os: windows-2022 }
219+
220+ runs-on : ${{matrix.os}}
221+
222+ steps :
223+ - uses : actions/checkout@v4
224+
225+ - name : Fetch Boost.CI
226+ uses : actions/checkout@v4
227+ with :
228+ repository : boostorg/boost-ci
229+ ref : master
230+ path : boost-ci-cloned
231+ - name : Get CI scripts folder
232+ run : |
233+ REM Copy ci folder if not testing Boost.CI
234+ if "%GITHUB_REPOSITORY%" == "%GITHUB_REPOSITORY:boost-ci=%" xcopy /s /e /q /i /y boost-ci-cloned\ci .\ci
235+ rmdir /s /q boost-ci-cloned
236+ - name : Setup Boost
237+ run : ci\github\install.bat
238+
239+ - name : Run tests
240+ if : ' !matrix.coverage'
241+ run : ci\build.bat
242+ env :
243+ B2_TOOLSET : ${{matrix.toolset}}
244+ B2_CXXSTD : ${{matrix.cxxstd}}
245+ B2_ADDRESS_MODEL : ${{matrix.addrmd}}
246+ B2_DEFINES : ${{matrix.defines}}
247+ B2_VARIANT : ${{matrix.variant}}
248+ B2_LINK : ${{matrix.link}}
249+
250+ - name : Collect coverage
251+ shell : powershell
252+ if : matrix.coverage
253+ run : ci\opencppcoverage.ps1
254+ env :
255+ B2_TOOLSET : ${{matrix.toolset}}
256+ B2_CXXSTD : ${{matrix.cxxstd}}
257+ B2_ADDRESS_MODEL : ${{matrix.addrmd}}
258+ B2_DEFINES : ${{matrix.defines}}
259+ B2_VARIANT : ${{matrix.variant}}
260+ B2_LINK : ${{matrix.link}}
261+
262+ - name : Upload
263+ uses : codecov/codecov-action@v5
264+ with :
265+ disable_search : true
266+ files : __out/cobertura.xml
267+ name : ${{env.CODECOV_NAME}} (Windows)
268+ token : ${{secrets.CODECOV_TOKEN}}
269+ verbose : true
0 commit comments