Skip to content

Commit 97e1b57

Browse files
committed
[ci] Split build-and-test steps per C++ standard
1 parent e637e0e commit 97e1b57

2 files changed

Lines changed: 157 additions & 63 deletions

File tree

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Eggs.Stacktrace
2+
#
3+
# Copyright (c) 2026 Agustin Berge
4+
#
5+
# Distributed under the Boost Software License, Version 1.0.
6+
# See accompanying file LICENSE.txt or copy at
7+
# http://www.boost.org/LICENSE_1_0.txt
8+
9+
name: Build and test (single C++ standard)
10+
description: Configure, build, and test the project (Debug and Release) for one C++ standard.
11+
12+
inputs:
13+
std:
14+
description: C++ standard to build for (e.g. 17)
15+
required: true
16+
preset:
17+
description: CMake preset name
18+
required: true
19+
compiler:
20+
description: Compiler identifier, used to name test result artifacts
21+
required: true
22+
cc:
23+
description: C compiler executable
24+
required: false
25+
default: ""
26+
cxx:
27+
description: C++ compiler executable
28+
required: false
29+
default: ""
30+
31+
runs:
32+
using: composite
33+
steps:
34+
- shell: bash
35+
run: |
36+
std="${{ inputs.std }}"
37+
build_dir="build/${{ inputs.preset }}-cxx${std}"
38+
failed=0
39+
40+
compiler_args=()
41+
if [ -n "${{ inputs.cc }}" ]; then
42+
compiler_args+=(-DCMAKE_C_COMPILER=${{ inputs.cc }} -DCMAKE_CXX_COMPILER=${{ inputs.cxx }})
43+
fi
44+
45+
echo "::group::Configure C++${std}"
46+
cmake --preset ${{ inputs.preset }} -B "${build_dir}" \
47+
"${compiler_args[@]}" \
48+
-DBUILD_EXAMPLES=ON -DBUILD_TESTING=ON \
49+
-DCMAKE_CXX_STANDARD=${std} || failed=1
50+
echo "::endgroup::"
51+
52+
if [ $failed -eq 0 ]; then
53+
echo "::group::Build Debug C++${std}"
54+
cmake --build "${build_dir}" --config Debug -- -k 0 || failed=1
55+
echo "::endgroup::"
56+
fi
57+
58+
if [ $failed -eq 0 ]; then
59+
echo "::group::Test Debug C++${std}"
60+
ctest --test-dir "${build_dir}" --build-config Debug \
61+
--label-regex header --output-on-failure --no-compress-output \
62+
--output-junit "test-results-${{ inputs.compiler }}-cxx${std}-debug-header.xml" || failed=1
63+
ctest --test-dir "${build_dir}" --build-config Debug \
64+
--label-regex unit --output-on-failure --no-compress-output \
65+
--output-junit "test-results-${{ inputs.compiler }}-cxx${std}-debug-unit.xml" || failed=1
66+
ctest --test-dir "${build_dir}" --build-config Debug \
67+
--label-regex example --verbose --no-compress-output \
68+
--output-junit "test-results-${{ inputs.compiler }}-cxx${std}-debug-example.xml" || failed=1
69+
echo "::endgroup::"
70+
fi
71+
72+
if [ $failed -eq 0 ]; then
73+
echo "::group::Build Release C++${std}"
74+
cmake --build "${build_dir}" --config Release -- -k 0 || failed=1
75+
echo "::endgroup::"
76+
fi
77+
78+
if [ $failed -eq 0 ]; then
79+
echo "::group::Test Release C++${std}"
80+
ctest --test-dir "${build_dir}" --build-config Release \
81+
--label-regex header --output-on-failure --no-compress-output \
82+
--output-junit "test-results-${{ inputs.compiler }}-cxx${std}-release-header.xml" || failed=1
83+
ctest --test-dir "${build_dir}" --build-config Release \
84+
--label-regex unit --output-on-failure --no-compress-output \
85+
--output-junit "test-results-${{ inputs.compiler }}-cxx${std}-release-unit.xml" || failed=1
86+
ctest --test-dir "${build_dir}" --build-config Release \
87+
--label-regex example --verbose --no-compress-output \
88+
--output-junit "test-results-${{ inputs.compiler }}-cxx${std}-release-example.xml" || failed=1
89+
echo "::endgroup::"
90+
fi
91+
92+
exit $failed

.github/workflows/test.yml

Lines changed: 65 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -119,69 +119,71 @@ jobs:
119119
# -----------------------------------------------------------------------
120120
# Main project
121121
# -----------------------------------------------------------------------
122-
- name: Build and test
123-
id: build_and_test
124-
shell: bash
125-
run: |
126-
compiler_args=()
127-
if [ -n "${{ matrix.cc }}" ]; then
128-
compiler_args+=(-DCMAKE_C_COMPILER=${{ matrix.cc }} -DCMAKE_CXX_COMPILER=${{ matrix.cxx }})
129-
fi
130-
131-
overall_failed=0
132-
for std in ${{ matrix.cxxstds }}; do
133-
std_failed=0
134-
135-
echo "::group::Configure C++${std}"
136-
cmake --preset ${{ matrix.preset }} -B build/${{ matrix.preset }}-cxx${std} \
137-
"${compiler_args[@]}" \
138-
-DBUILD_EXAMPLES=ON -DBUILD_TESTING=ON \
139-
-DCMAKE_CXX_STANDARD=${std} || std_failed=1
140-
echo "::endgroup::"
141-
142-
if [ $std_failed -eq 0 ]; then
143-
echo "::group::Build Debug C++${std}"
144-
cmake --build build/${{ matrix.preset }}-cxx${std} --config Debug -- -k 0 || std_failed=1
145-
echo "::endgroup::"
146-
fi
147-
148-
if [ $std_failed -eq 0 ]; then
149-
echo "::group::Test Debug C++${std}"
150-
ctest --test-dir build/${{ matrix.preset }}-cxx${std} --build-config Debug \
151-
--label-regex header --output-on-failure --no-compress-output \
152-
--output-junit test-results-${{ matrix.compiler }}-cxx${std}-debug-header.xml || std_failed=1
153-
ctest --test-dir build/${{ matrix.preset }}-cxx${std} --build-config Debug \
154-
--label-regex unit --output-on-failure --no-compress-output \
155-
--output-junit test-results-${{ matrix.compiler }}-cxx${std}-debug-unit.xml || std_failed=1
156-
ctest --test-dir build/${{ matrix.preset }}-cxx${std} --build-config Debug \
157-
--label-regex example --verbose --no-compress-output \
158-
--output-junit test-results-${{ matrix.compiler }}-cxx${std}-debug-example.xml || std_failed=1
159-
echo "::endgroup::"
160-
fi
161-
162-
if [ $std_failed -eq 0 ]; then
163-
echo "::group::Build Release C++${std}"
164-
cmake --build build/${{ matrix.preset }}-cxx${std} --config Release -- -k 0 || std_failed=1
165-
echo "::endgroup::"
166-
fi
167-
168-
if [ $std_failed -eq 0 ]; then
169-
echo "::group::Test Release C++${std}"
170-
ctest --test-dir build/${{ matrix.preset }}-cxx${std} --build-config Release \
171-
--label-regex header --output-on-failure --no-compress-output \
172-
--output-junit test-results-${{ matrix.compiler }}-cxx${std}-release-header.xml || std_failed=1
173-
ctest --test-dir build/${{ matrix.preset }}-cxx${std} --build-config Release \
174-
--label-regex unit --output-on-failure --no-compress-output \
175-
--output-junit test-results-${{ matrix.compiler }}-cxx${std}-release-unit.xml || std_failed=1
176-
ctest --test-dir build/${{ matrix.preset }}-cxx${std} --build-config Release \
177-
--label-regex example --verbose --no-compress-output \
178-
--output-junit test-results-${{ matrix.compiler }}-cxx${std}-release-example.xml || std_failed=1
179-
echo "::endgroup::"
180-
fi
181-
182-
[ $std_failed -ne 0 ] && overall_failed=1
183-
done
184-
exit $overall_failed
122+
- name: Build and test C++11
123+
id: build_test_cxx11
124+
if: contains(matrix.cxxstds, '11')
125+
uses: ./.github/actions/build-test-std
126+
with:
127+
std: "11"
128+
preset: ${{ matrix.preset }}
129+
compiler: ${{ matrix.compiler }}
130+
cc: ${{ matrix.cc }}
131+
cxx: ${{ matrix.cxx }}
132+
133+
- name: Build and test C++14
134+
id: build_test_cxx14
135+
if: always() && contains(matrix.cxxstds, '14')
136+
uses: ./.github/actions/build-test-std
137+
with:
138+
std: "14"
139+
preset: ${{ matrix.preset }}
140+
compiler: ${{ matrix.compiler }}
141+
cc: ${{ matrix.cc }}
142+
cxx: ${{ matrix.cxx }}
143+
144+
- name: Build and test C++17
145+
id: build_test_cxx17
146+
if: always() && contains(matrix.cxxstds, '17')
147+
uses: ./.github/actions/build-test-std
148+
with:
149+
std: "17"
150+
preset: ${{ matrix.preset }}
151+
compiler: ${{ matrix.compiler }}
152+
cc: ${{ matrix.cc }}
153+
cxx: ${{ matrix.cxx }}
154+
155+
- name: Build and test C++20
156+
id: build_test_cxx20
157+
if: always() && contains(matrix.cxxstds, '20')
158+
uses: ./.github/actions/build-test-std
159+
with:
160+
std: "20"
161+
preset: ${{ matrix.preset }}
162+
compiler: ${{ matrix.compiler }}
163+
cc: ${{ matrix.cc }}
164+
cxx: ${{ matrix.cxx }}
165+
166+
- name: Build and test C++23
167+
id: build_test_cxx23
168+
if: always() && contains(matrix.cxxstds, '23')
169+
uses: ./.github/actions/build-test-std
170+
with:
171+
std: "23"
172+
preset: ${{ matrix.preset }}
173+
compiler: ${{ matrix.compiler }}
174+
cc: ${{ matrix.cc }}
175+
cxx: ${{ matrix.cxx }}
176+
177+
- name: Build and test C++26
178+
id: build_test_cxx26
179+
if: always() && contains(matrix.cxxstds, '26')
180+
uses: ./.github/actions/build-test-std
181+
with:
182+
std: "26"
183+
preset: ${{ matrix.preset }}
184+
compiler: ${{ matrix.compiler }}
185+
cc: ${{ matrix.cc }}
186+
cxx: ${{ matrix.cxx }}
185187

186188
- name: Upload test results
187189
id: upload_test_results

0 commit comments

Comments
 (0)