Skip to content

Commit 19ffa62

Browse files
committed
Implement a reusable GHA workflow with configuration options.
1 parent 363e04d commit 19ffa62

3 files changed

Lines changed: 139 additions & 310 deletions

File tree

.github/workflows/ci.yml

Lines changed: 31 additions & 310 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
1+
#
12
# Copyright 2020-2021 Peter Dimov
23
# Copyright 2021 Andrey Semashev
3-
# Copyright 2021 Alexander Grund
4-
# Copyright 2022 James E. King III
4+
# Copyright 2021-2024 Alexander Grund
5+
# Copyright 2022-2025 James E. King III
56
#
67
# Distributed under the Boost Software License, Version 1.0.
78
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
9+
#
10+
# This workflow uses the Boost.CI reusable workflow which builds a variety of
11+
# configurations of your project, runs tests, and generates code coverage reports.
12+
#
13+
# To use it, copy this file into your repository as `.github/workflows/ci.yml` and
14+
# customize it appropriately.
15+
#
816
---
9-
name: CI
17+
name: Boost.CI
1018

1119
on:
1220
pull_request:
@@ -18,312 +26,25 @@ on:
1826
- feature/**
1927
- fix/**
2028
- pr/**
21-
22-
concurrency:
23-
group: ${{format('{0}:{1}', github.repository, github.ref)}}
24-
cancel-in-progress: true
25-
26-
env:
27-
GIT_FETCH_JOBS: 8
28-
NET_RETRY_COUNT: 5
29-
B2_CI_VERSION: 1
30-
B2_VARIANT: debug,release
31-
B2_LINK: shared,static
32-
LCOV_BRANCH_COVERAGE: 0
33-
CODECOV_NAME: Github Actions
34-
SELF_CONTAINED_HEADER_TESTS: 0
29+
paths-ignore:
30+
- LICENSE
31+
- meta/**
32+
- README.md
3533

3634
jobs:
37-
posix:
38-
defaults:
39-
run:
40-
shell: bash
41-
42-
strategy:
43-
fail-fast: false
44-
matrix:
45-
include:
46-
# Linux, gcc
47-
- { compiler: gcc-4.8, cxxstd: '11', container: 'ubuntu:18.04', os: ubuntu-latest }
48-
- { compiler: gcc-5, cxxstd: '11', container: 'ubuntu:18.04', os: ubuntu-latest }
49-
- { compiler: gcc-6, cxxstd: '11,14,17', container: 'ubuntu:18.04', os: ubuntu-latest }
50-
- { compiler: gcc-7, cxxstd: '11,14,17', container: 'ubuntu:18.04', os: ubuntu-latest }
51-
- { compiler: gcc-8, cxxstd: '11,14,17,2a', container: 'ubuntu:18.04', os: ubuntu-latest }
52-
- { compiler: gcc-9, cxxstd: '11,14,17,2a', container: 'ubuntu:20.04', os: ubuntu-latest }
53-
- { compiler: gcc-10, cxxstd: '11,14,17,20', container: 'ubuntu:20.04', os: ubuntu-latest }
54-
- { compiler: gcc-11, cxxstd: '11,14,17,20', container: 'ubuntu:22.04', os: ubuntu-latest, self-contained-header-tests: 1 }
55-
# disabled: there are too many issues in serialization and not enough time to add suppressions
56-
# - { name: GCC w/ sanitizers, sanitize: yes,
57-
# compiler: gcc-11, cxxstd: '11,14,17,20', container: 'ubuntu:20.04', os: ubuntu-latest }
58-
- { name: Collect coverage, coverage: yes,
59-
compiler: gcc-10, cxxstd: '11', container: 'ubuntu:20.04', os: ubuntu-latest, install: 'g++-10-multilib', address-model: '32,64' }
60-
61-
# Linux, clang
62-
- { compiler: clang-3.9, cxxstd: '11,14', container: 'ubuntu:18.04', os: ubuntu-latest }
63-
- { compiler: clang-4.0, cxxstd: '11,14', container: 'ubuntu:18.04', os: ubuntu-latest }
64-
- { compiler: clang-5.0, cxxstd: '11,14,1z', container: 'ubuntu:18.04', os: ubuntu-latest }
65-
- { compiler: clang-6.0, cxxstd: '11,14,17', container: 'ubuntu:18.04', os: ubuntu-latest }
66-
- { compiler: clang-7, cxxstd: '11,14,17', container: 'ubuntu:18.04', os: ubuntu-latest }
67-
# Note: clang-8 does not fully support C++20, so it is not compatible with some libstdc++ versions in this mode
68-
- { compiler: clang-8, cxxstd: '11,14,17,2a', container: 'ubuntu:18.04', os: ubuntu-latest, install: 'clang-8 g++-7' }
69-
- { compiler: clang-9, cxxstd: '11,14,17,2a', container: 'ubuntu:20.04', os: ubuntu-latest }
70-
- { compiler: clang-10, cxxstd: '11,14,17,20', container: 'ubuntu:20.04', os: ubuntu-latest }
71-
- { compiler: clang-11, cxxstd: '11,14,17,20', container: 'ubuntu:20.04', os: ubuntu-latest }
72-
- { compiler: clang-12, cxxstd: '11,14,17,20', container: 'ubuntu:20.04', os: ubuntu-latest, self-contained-header-tests: 1 }
73-
74-
# libc++
75-
- { compiler: clang-6.0, cxxstd: '11,14', container: 'ubuntu:18.04', os: ubuntu-latest, stdlib: libc++, install: 'clang-6.0 libc++-dev libc++abi-dev' }
76-
- { compiler: clang-12, cxxstd: '11,14,17,20', container: 'ubuntu:20.04', os: ubuntu-latest, stdlib: libc++, install: 'clang-12 libc++-12-dev libc++abi-12-dev', self-contained-header-tests: 1 }
77-
# disabled: there are too many issues in serialization and not enough time to add suppressions
78-
# - { name: Clang w/ sanitizers, sanitize: yes,
79-
# compiler: clang-12, cxxstd: '11,14,17,20', container: 'ubuntu:20.04', os: ubuntu-latest, stdlib: libc++, install: 'clang-12 libc++-12-dev libc++abi-12-dev' }
80-
81-
# OSX, clang
82-
# sanitize disabled: there are too many issues in serialization and not enough time to add suppressions
83-
- { compiler: clang, cxxstd: '11,14,17,20', os: macos-latest }
84-
85-
# Coverity Scan
86-
# requires two github secrets in repo to activate; see ci/github/coverity.sh
87-
# does not run on pull requests, only on pushes into develop and master
88-
- { name: Coverity, coverity: yes,
89-
compiler: clang-10, cxxstd: '17', container: 'ubuntu:20.04', os: ubuntu-latest, ccache: no }
90-
91-
# multiarch (bigendian testing) - does not support coverage yet
92-
# date_time has no endian compile-time branches
93-
# - { name: Big-endian, multiarch: yes,
94-
# compiler: clang, cxxstd: '17', container: 'ubuntu:20.04', os: ubuntu-latest, ccache: no, distro: fedora, edition: 34, arch: s390x }
95-
96-
97-
timeout-minutes: 120
98-
runs-on: ${{matrix.os}}
99-
container:
100-
image: ${{matrix.container}}
101-
volumes:
102-
- /node20217:/node20217:rw,rshared
103-
- ${{ startsWith(matrix.container, 'ubuntu:1') && '/node20217:/__e/node20:ro,rshared' || ' ' }}
104-
env: {B2_USE_CCACHE: 1}
105-
106-
steps:
107-
- name: Setup container environment
108-
if: matrix.container
109-
run: |
110-
apt-get update
111-
apt-get -y install sudo python3 git g++ curl xz-utils
112-
113-
- name: Install nodejs20glibc2.17
114-
if: ${{ startsWith( matrix.container, 'ubuntu:1' ) }}
115-
run: |
116-
curl -LO https://archives.boost.io/misc/node/node-v20.9.0-linux-x64-glibc-217.tar.xz
117-
tar -xf node-v20.9.0-linux-x64-glibc-217.tar.xz --strip-components 1 -C /node20217
118-
ldd /__e/node20/bin/node
119-
120-
- name: Setup environment
121-
run: |
122-
if [ -f "/etc/debian_version" ]; then
123-
echo "DEBIAN_FRONTEND=noninteractive" >> $GITHUB_ENV
124-
export DEBIAN_FRONTEND=noninteractive
125-
fi
126-
# multiple job types are not compatible with ccache, they use "ccache: no" in the matrix
127-
if [[ "${{ matrix.ccache }}" == "no" ]]; then
128-
echo "B2_USE_CCACHE=0" >> $GITHUB_ENV
129-
fi
130-
git config --global pack.threads 0
131-
132-
- uses: actions/checkout@v3
133-
with:
134-
# For coverage builds fetch the whole history, else only 1 commit using a 'fake ternary'
135-
fetch-depth: ${{ matrix.coverage && '0' || '1' }}
136-
137-
- name: Cache ccache
138-
uses: actions/cache@v3
139-
if: env.B2_USE_CCACHE
140-
with:
141-
path: ~/.ccache
142-
key: ${{matrix.os}}-${{matrix.container}}-${{matrix.compiler}}-${{github.sha}}
143-
restore-keys: |
144-
${{matrix.os}}-${{matrix.container}}-${{matrix.compiler}}-
145-
${{matrix.os}}-${{matrix.container}}-${{matrix.compiler}}
146-
147-
- name: Fetch Boost.CI
148-
uses: actions/checkout@v3
149-
with:
150-
repository: boostorg/boost-ci
151-
ref: master
152-
path: boost-ci-cloned
153-
154-
- name: Get CI scripts folder
155-
run: |
156-
# Copy ci folder if not testing Boost.CI
157-
[[ "$GITHUB_REPOSITORY" =~ "boost-ci" ]] || cp -r boost-ci-cloned/ci .
158-
rm -rf boost-ci-cloned
159-
160-
- name: Install packages
161-
if: startsWith(matrix.os, 'ubuntu')
162-
run: |
163-
SOURCE_KEYS=(${{join(matrix.source_keys, ' ')}})
164-
SOURCES=(${{join(matrix.sources, ' ')}})
165-
# Add this by default
166-
SOURCES+=(ppa:ubuntu-toolchain-r/test)
167-
for key in "${SOURCE_KEYS[@]}"; do
168-
for i in {1..$NET_RETRY_COUNT}; do
169-
wget -O - "$key" | sudo apt-key add - && break || sleep 10
170-
done
171-
done
172-
for source in "${SOURCES[@]}"; do
173-
for i in {1..$NET_RETRY_COUNT}; do
174-
sudo add-apt-repository $source && break || sleep 10
175-
done
176-
done
177-
sudo apt-get -o Acquire::Retries=$NET_RETRY_COUNT update
178-
if [[ -z "${{matrix.install}}" ]]; then
179-
pkgs="${{matrix.compiler}}"
180-
pkgs="${pkgs/gcc-/g++-}"
181-
else
182-
pkgs="${{matrix.install}}"
183-
fi
184-
sudo apt-get -o Acquire::Retries=$NET_RETRY_COUNT install -y $pkgs
185-
186-
- name: Setup multiarch
187-
if: matrix.multiarch
188-
run: |
189-
sudo apt-get install --no-install-recommends -y binfmt-support qemu-user-static
190-
sudo docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
191-
git clone https://github.com/jeking3/bdde.git
192-
echo "$(pwd)/bdde/bin/linux" >> ${GITHUB_PATH}
193-
echo "BDDE_DISTRO=${{ matrix.distro }}" >> ${GITHUB_ENV}
194-
echo "BDDE_EDITION=${{ matrix.edition }}" >> ${GITHUB_ENV}
195-
echo "BDDE_ARCH=${{ matrix.arch }}" >> ${GITHUB_ENV}
196-
echo "B2_WRAPPER=bdde" >> ${GITHUB_ENV}
197-
198-
- name: Setup Boost
199-
env:
200-
B2_ADDRESS_MODEL: ${{matrix.address-model}}
201-
B2_COMPILER: ${{matrix.compiler}}
202-
B2_CXXSTD: ${{matrix.cxxstd}}
203-
B2_SANITIZE: ${{matrix.sanitize}}
204-
B2_STDLIB: ${{matrix.stdlib}}
205-
run: source ci/github/install.sh
206-
207-
- name: Setup coverage collection
208-
if: matrix.coverage
209-
run: ci/github/codecov.sh "setup"
210-
211-
- name: Run tests
212-
if: '!matrix.coverity'
213-
run: ci/build.sh
214-
env:
215-
BOOST_DATE_TIME_TEST_WITHOUT_SELF_CONTAINED_HEADER_TESTS: ${{ !(matrix.self-contained-header-tests || env.SELF_CONTAINED_HEADER_TESTS) }}
216-
217-
- name: Upload coverage
218-
if: matrix.coverage
219-
run: ci/codecov.sh "upload"
220-
221-
- name: Run coverity
222-
if: matrix.coverity && github.event_name == 'push' && (github.ref_name == 'develop' || github.ref_name == 'master')
223-
run: ci/github/coverity.sh
224-
env:
225-
BOOST_DATE_TIME_TEST_WITHOUT_SELF_CONTAINED_HEADER_TESTS: ${{ !(matrix.self-contained-header-tests || env.SELF_CONTAINED_HEADER_TESTS) }}
226-
COVERITY_SCAN_NOTIFICATION_EMAIL: ${{ secrets.COVERITY_SCAN_NOTIFICATION_EMAIL }}
227-
COVERITY_SCAN_TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }}
228-
229-
windows:
230-
defaults:
231-
run:
232-
shell: cmd
233-
strategy:
234-
fail-fast: false
235-
matrix:
236-
include:
237-
- { toolset: msvc-14.2, cxxstd: '14,17,20', addrmd: '32,64', os: windows-2019, self-contained-header-tests: 1 }
238-
- { name: Collect coverage, coverage: yes,
239-
toolset: msvc-14.3, cxxstd: '14,17,20', addrmd: '32,64', os: windows-2022 }
240-
- { toolset: gcc, cxxstd: '11,14,17,2a', addrmd: '64', os: windows-2019 }
241-
242-
runs-on: ${{matrix.os}}
243-
244-
steps:
245-
- uses: actions/checkout@v2
246-
247-
- name: Fetch Boost.CI
248-
uses: actions/checkout@v2
249-
with:
250-
repository: boostorg/boost-ci
251-
ref: master
252-
path: boost-ci-cloned
253-
- name: Get CI scripts folder
254-
run: |
255-
REM Copy ci folder if not testing Boost.CI
256-
if "%GITHUB_REPOSITORY%" == "%GITHUB_REPOSITORY:boost-ci=%" xcopy /s /e /q /i /y boost-ci-cloned\ci .\ci
257-
rmdir /s /q boost-ci-cloned
258-
259-
- name: Setup Boost
260-
run: ci\github\install.bat
261-
262-
- name: Run tests
263-
if: '!matrix.coverage'
264-
run: ci\build.bat
265-
env:
266-
B2_TOOLSET: ${{matrix.toolset}}
267-
B2_CXXSTD: ${{matrix.cxxstd}}
268-
B2_ADDRESS_MODEL: ${{matrix.addrmd}}
269-
BOOST_DATE_TIME_TEST_WITHOUT_SELF_CONTAINED_HEADER_TESTS: ${{ !(matrix.self-contained-header-tests || env.SELF_CONTAINED_HEADER_TESTS) }}
270-
271-
- name: Collect coverage
272-
shell: powershell
273-
if: matrix.coverage
274-
run: ci\opencppcoverage.ps1
275-
env:
276-
B2_TOOLSET: ${{matrix.toolset}}
277-
B2_CXXSTD: ${{matrix.cxxstd}}
278-
B2_ADDRESS_MODEL: ${{matrix.addrmd}}
279-
BOOST_DATE_TIME_TEST_WITHOUT_SELF_CONTAINED_HEADER_TESTS: ${{ !(matrix.self-contained-header-tests || env.SELF_CONTAINED_HEADER_TESTS) }}
280-
281-
- name: Upload coverage
282-
if: matrix.coverage
283-
uses: codecov/codecov-action@v2
284-
with:
285-
files: __out/cobertura.xml
286-
287-
CMake:
288-
defaults:
289-
run:
290-
shell: bash
291-
292-
strategy:
293-
fail-fast: false
294-
matrix:
295-
include:
296-
- { os: ubuntu-latest, build_shared: ON, build_type: Release, generator: 'Unix Makefiles' }
297-
- { os: ubuntu-latest, build_shared: OFF, build_type: Debug, generator: 'Unix Makefiles' }
298-
- { os: windows-2019, build_shared: ON, build_type: Release, generator: 'Visual Studio 16 2019' }
299-
- { os: windows-2019, build_shared: OFF, build_type: Debug, generator: 'Visual Studio 16 2019' }
300-
301-
timeout-minutes: 120
302-
runs-on: ${{matrix.os}}
303-
304-
steps:
305-
- uses: actions/checkout@v2
306-
307-
- name: Fetch Boost.CI
308-
uses: actions/checkout@v2
309-
with:
310-
repository: boostorg/boost-ci
311-
ref: master
312-
path: boost-ci-cloned
313-
314-
- name: Get CI scripts folder
315-
run: |
316-
# Copy ci folder if not testing Boost.CI
317-
[[ "$GITHUB_REPOSITORY" =~ "boost-ci" ]] || cp -r boost-ci-cloned/ci .
318-
rm -rf boost-ci-cloned
319-
320-
- name: Setup Boost
321-
env: {B2_DONT_BOOTSTRAP: 1}
322-
run: source ci/github/install.sh
323-
324-
- name: Run CMake
325-
run: |
326-
cd "$BOOST_ROOT"
327-
mkdir __build_cmake_test__ && cd __build_cmake_test__
328-
cmake -G "${{matrix.generator}}" -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DBOOST_INCLUDE_LIBRARIES=$SELF -DBUILD_SHARED_LIBS=${{matrix.build_shared}} -DBUILD_TESTING=ON -DBoost_VERBOSE=ON ..
329-
cmake --build . --config ${{matrix.build_type}}
35+
call-boost-ci:
36+
name: Run Boost.CI
37+
uses: boostorg/boost-ci/.github/workflows/reusable.yml@master
38+
with:
39+
# no endian branches
40+
enable_multiarch: false
41+
# serialization has issues, not enough time to add suppressions
42+
enable_sanitizers: false
43+
# these compilers fail
44+
exclude_compiler: 'gcc-4.7,gcc-4.8,gcc-4.9,gcc-5,clang-3.5,clang-3.6,clang-3.7,clang-3.8'
45+
# the tests take a while; this reduces the load a bit and there isn't any C++20 specific code
46+
exclude_cxxstd: '98,03,0x,2a,20'
47+
secrets:
48+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
49+
COVERITY_SCAN_NOTIFICATION_EMAIL: ${{ secrets.COVERITY_SCAN_NOTIFICATION_EMAIL }}
50+
COVERITY_SCAN_TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }}

test/cmake_test/CMakeLists.txt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Copyright 2021-2024 Alexander Grund
2+
# Distributed under the Boost Software License, Version 1.0.
3+
# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
4+
5+
cmake_minimum_required(VERSION 3.5...3.16)
6+
7+
project(cmake_subdir_test LANGUAGES CXX)
8+
9+
# Those 2 should work the same
10+
# while using find_package for the installed Boost avoids the need to manually specify dependencies
11+
if(BOOST_CI_INSTALL_TEST)
12+
find_package(boost_date_time REQUIRED)
13+
else()
14+
set(BOOST_INCLUDE_LIBRARIES date_time)
15+
add_subdirectory(../../../.. deps/boost EXCLUDE_FROM_ALL)
16+
endif()
17+
18+
add_executable(main main.cpp)
19+
target_link_libraries(main Boost::date_time)
20+
21+
enable_testing()
22+
add_test(NAME main COMMAND main)

0 commit comments

Comments
 (0)