-
Notifications
You must be signed in to change notification settings - Fork 20
175 lines (154 loc) · 6.98 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
# Copyright 2022 Alexander Grund
#
# 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:
pull_request:
push:
branches:
- main
- develop
- feature/**
concurrency:
group: ${{format('{0}:{1}', github.repository, github.ref)}}
cancel-in-progress: true
env:
NET_RETRY_COUNT: 5
DOCBOOK_XSL_DIR: /usr/share/xml/docbook/stylesheet/docbook-xsl
DOCBOOK_DTD_DIR: /usr/share/xml/docbook/schema/dtd/4.2
jobs:
Formatting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Formatting
uses: DoozyX/[email protected]
with:
clangFormatVersion: 10
posix:
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
include:
# Linux, gcc
- { compiler: gcc-12, cxxstd: '14,17,20', boostBranch: boost-1.86.0, os: ubuntu-22.04 }
- { compiler: gcc-14, cxxstd: '14,17,20', boostBranch: boost-1.86.0, os: ubuntu-22.04 }
- { compiler: gcc-14, cxxstd: '14,17,20', boostBranch: master, os: ubuntu-22.04 }
# Linux, clang
- { compiler: clang-14, cxxstd: '14,17,20', boostBranch: boost-1.86.0, os: ubuntu-22.04 }
- { compiler: clang-19, cxxstd: '14,17,20', boostBranch: boost-1.86.0, os: ubuntu-22.04 }
- { compiler: clang-19, cxxstd: '14,17,20', boostBranch: master, os: ubuntu-22.04 }
- { name: Collect coverage, coverage: yes, compiler: gcc-14, cxxstd: '14', boostBranch: boost-1.86.0, os: ubuntu-22.04 }
timeout-minutes: 120
runs-on: ${{matrix.os}}
container: ${{matrix.container}}
steps:
- name: Prepare container environment
if: matrix.container
run: |
export DEBIAN_FRONTEND=noninteractive
apt-get -o Acquire::Retries=$NET_RETRY_COUNT update
apt-get -o Acquire::Retries=$NET_RETRY_COUNT install -y sudo software-properties-common curl lsb-release
# Need (newer) git & cmake, and the older Ubuntu container may require requesting the key manually using port 80
curl -sSL --retry ${NET_RETRY_COUNT:-5} 'http://keyserver.ubuntu.com/pks/lookup?op=get&search=0xE1DD270288B4E6030699E45FA1715D88E1DF1F24' | sudo gpg --dearmor > /etc/apt/trusted.gpg.d/git-core_ubuntu_ppa.gpg
for i in {1..${NET_RETRY_COUNT:-5}}; do sudo -E add-apt-repository -y ppa:git-core/ppa && break || sleep 10; done
curl -sSL --retry ${NET_RETRY_COUNT:-5} 'https://apt.kitware.com/keys/kitware-archive-latest.asc' | sudo gpg --dearmor > /etc/apt/trusted.gpg.d/kitware-archive-latest.gpg
for i in {1..${NET_RETRY_COUNT:-5}}; do sudo -E add-apt-repository -y "deb https://apt.kitware.com/ubuntu/ $(lsb_release -cs) main" && break || sleep 10; done
apt-get -o Acquire::Retries=$NET_RETRY_COUNT update
apt-get -o Acquire::Retries=$NET_RETRY_COUNT install -y g++ git cmake
git config --global pack.threads 0
- uses: actions/checkout@v4
with:
# For coverage builds fetch the whole history, else only 1 commit using a 'fake ternary'
fetch-depth: ${{ matrix.coverage && '0' || '1' }}
# Checking out Boost and all its submodules takes ages...
- name: Cache Boost
uses: actions/cache@v3
with:
path: boost-root
key: boost-${{matrix.boostBranch}}
- name: Checkout Boost
uses: actions/checkout@v4
with:
repository: boostorg/boost
ref: ${{matrix.boostBranch}}
submodules: true
path: boost-root
persist-credentials: false
- name: Install packages and setup env
run: |
sudo apt-get -o Acquire::Retries=$NET_RETRY_COUNT update
CXX=${{matrix.compiler}}
CXX="${CXX/gcc-/g++-}"
# Package names are g++-* and clang-*, so set this before correcting CXX for Clang
pkgs="$CXX xsltproc docbook-xsl docbook-xml lcov ccache"
sudo apt-get -o Acquire::Retries=$NET_RETRY_COUNT install -y $pkgs
CXX="ccache ${CXX/clang-/clang++-}"
echo "CXX=$CXX" >> $GITHUB_ENV
echo "CC=${{matrix.compiler}}" >> $GITHUB_ENV
if [[ "$CXX" =~ clang ]]; then
B2_TOOLSET=clang
else
B2_TOOLSET=gcc
fi
echo "B2_TOOLSET=$B2_TOOLSET" >> $GITHUB_ENV
echo "using $B2_TOOLSET : : $CXX ;" > ~/user-config.jam
# Move the Boost root to a sibling folder
mv boost-root ..
echo "BOOST_ROOT=${{github.workspace}}/../boost-root" >> $GITHUB_ENV
- name: Cache ccache
uses: hendrikmuhs/ccache-action@v1
with:
key: ${{matrix.os}}-${{matrix.compiler}}-${{matrix.boostBranch}}
- name: Prepare boost
working-directory: ${{env.BOOST_ROOT}}
run: ./bootstrap.sh && ./b2 headers
- name: Boost build
run: |
if [[ "${{matrix.boostBranch}}" == "master" ]]; then
B2_FLAGS="cxxstd=${{matrix.cxxstd}}"
else
B2_FLAGS="cxxflags=-std=c++${{matrix.cxxstd}}"
fi
if [[ "${{matrix.coverage}}" == "yes" ]]; then
B2_FLAGS="$B2_FLAGS cxxflags=--coverage linkflags=--coverage"
fi
scripts/build.sh --toolset=$B2_TOOLSET $B2_FLAGS -j3
- name: Collect coverage
if: matrix.coverage
run: |
lcov --version
lcov --gcov-tool=gcov-8 --directory "$GITHUB_WORKSPACE/test" --capture --output-file all.info
# dump a summary on the console
lcov --list all.info
# Limit to our files (header-only in this case)
lcov --extract all.info "$GITHUB_WORKSPACE/include/*" --output-file coverage.info
# Output what was collected
lcov --list coverage.info
- name: Upload coverage
if: matrix.coverage
uses: coverallsapp/github-action@master
with:
path-to-lcov: ${{github.workspace}}/coverage.info
github-token: ${{secrets.GITHUB_TOKEN}}
- name: Build required boost libs
working-directory: ${{env.BOOST_ROOT}}
run: |
./b2 --toolset=$B2_TOOLSET --with-test --with-thread --with-chrono --with-system --with-atomic --with-date_time -a -j3
# Add lib folder to LD_LIBRARY_PATH, so the tests can load them
echo "LD_LIBRARY_PATH=$PWD/stage/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV
- name: CMake build
run: |
mkdir build && cd build
CXX_STANDARD="${{matrix.cxxstd}}"
cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS="-std=c++${CXX_STANDARD##*,}" -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_VERBOSE_MAKEFILE=ON
cmake --build . --config Debug -- -j3
ctest --output-on-failure --build-config Debug -j3
- name: Cleanup Boost folder to reduce cache usage
if: ${{ always() }}
working-directory: ${{env.BOOST_ROOT}}
run: git clean -fxd