Skip to content

Commit c6bc85f

Browse files
authored
Merge pull request #551 from Becheler/ci/add-ubsan
ci: adding sanitization job
2 parents 812b205 + 8015f52 commit c6bc85f

1 file changed

Lines changed: 94 additions & 0 deletions

File tree

‎.github/workflows/sanitize.yml‎

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
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: sanitize
12+
13+
on: [push, pull_request]
14+
15+
env:
16+
GIT_FETCH_JOBS: 8
17+
NET_RETRY_COUNT: 5
18+
B2_CI_VERSION: 1
19+
B2_LINK: static
20+
# UBSan gives better stack traces in a debug build; also faster than debug,release.
21+
B2_VARIANT: debug
22+
23+
jobs:
24+
ubsan:
25+
# Blocking: UBSan fails the check on the first UB found
26+
defaults:
27+
run:
28+
shell: bash
29+
30+
strategy:
31+
fail-fast: false
32+
matrix:
33+
include:
34+
- { name: UBSan, ubsan: 1,
35+
compiler: gcc-14, cxxstd: '17,20', os: ubuntu-24.04, install: 'g++-14', address-model: '64' }
36+
37+
timeout-minutes: 120
38+
runs-on: ${{matrix.os}}
39+
container: ${{matrix.container}}
40+
41+
steps:
42+
- name: Setup environment
43+
run: |
44+
if [ -f "/etc/debian_version" ]; then
45+
echo "DEBIAN_FRONTEND=noninteractive" >> $GITHUB_ENV
46+
export DEBIAN_FRONTEND=noninteractive
47+
fi
48+
git config --global pack.threads 0
49+
50+
- uses: actions/checkout@v4
51+
with:
52+
fetch-depth: 1
53+
54+
- name: Fetch Boost.CI
55+
uses: actions/checkout@v4
56+
with:
57+
repository: boostorg/boost-ci
58+
ref: master
59+
path: boost-ci-cloned
60+
61+
- name: Get CI scripts folder
62+
run: |
63+
# Copy ci folder if not testing Boost.CI
64+
[[ "$GITHUB_REPOSITORY" =~ "boost-ci" ]] || cp -r boost-ci-cloned/ci .
65+
rm -rf boost-ci-cloned
66+
67+
- name: Install packages
68+
if: startsWith(matrix.os, 'ubuntu')
69+
run: |
70+
SOURCES=(ppa:ubuntu-toolchain-r/test)
71+
for source in "${SOURCES[@]}"; do
72+
for i in {1..$NET_RETRY_COUNT}; do
73+
sudo add-apt-repository $source && break || sleep 10
74+
done
75+
done
76+
sudo apt-get -o Acquire::Retries=$NET_RETRY_COUNT update
77+
if [[ -z "${{matrix.install}}" ]]; then
78+
pkgs="${{matrix.compiler}}"
79+
pkgs="${pkgs/gcc-/g++-}"
80+
else
81+
pkgs="${{matrix.install}}"
82+
fi
83+
sudo apt-get -o Acquire::Retries=$NET_RETRY_COUNT install -y $pkgs
84+
85+
- name: Setup Boost
86+
env:
87+
B2_ADDRESS_MODEL: ${{matrix.address-model}}
88+
B2_COMPILER: ${{matrix.compiler}}
89+
B2_CXXSTD: ${{matrix.cxxstd}}
90+
B2_UBSAN: ${{matrix.ubsan}}
91+
run: source ci/github/install.sh
92+
93+
- name: Run tests
94+
run: ci/build.sh

0 commit comments

Comments
 (0)