Skip to content

Commit 837b856

Browse files
committed
Add CMake matrix CI evaluation step executing via test loop
1 parent a0a4ebe commit 837b856

3 files changed

Lines changed: 60 additions & 3 deletions

File tree

copier/test_cmake_matrix.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env bash
2+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3+
set -euo pipefail
4+
5+
script_dir=$(realpath "$(dirname "${BASH_SOURCE[0]}")")
6+
7+
PRESET=${1:-gcc-release}
8+
CMAKE_VERSION=${2:-latest}
9+
10+
if [[ "$CMAKE_VERSION" == "latest" || -z "$CMAKE_VERSION" ]]; then
11+
export CMAKE_COMMAND="cmake"
12+
export CTEST_COMMAND="ctest"
13+
echo "Running with default host CMake"
14+
else
15+
echo "Provisioning standard environment for CMake $CMAKE_VERSION"
16+
venv_dir=$(mktemp -d)
17+
uv venv "$venv_dir" > /dev/null
18+
uv pip install "cmake==${CMAKE_VERSION}" --env "$venv_dir" > /dev/null
19+
export CMAKE_COMMAND="$venv_dir/bin/cmake"
20+
export CTEST_COMMAND="$venv_dir/bin/ctest"
21+
22+
echo "Using CMake: $("$CMAKE_COMMAND" --version | head -n 1)"
23+
24+
cleanup() {
25+
rm -rf "$venv_dir"
26+
}
27+
trap cleanup EXIT
28+
fi
29+
30+
"$script_dir/test_standard_project.sh" "$PRESET"

copier/test_standard_project.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1+
#="${CMAKE_COMMAND:-cmake}"
2+
#="${CTEST_COMMAND:-ctest}"
13
#!/usr/bin/env bash
24
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
35
set -euo pipefail
6+
CMAKE_COMMAND="${CMAKE_COMMAND:-cmake}"
7+
CTEST_COMMAND="${CTEST_COMMAND:-ctest}"
8+
49

510
script_dir=$(realpath "$(dirname "${BASH_SOURCE[0]}")")
611
repo_root=$(realpath "$script_dir/..")
@@ -39,15 +44,15 @@ test_project_variant() {
3944

4045
echo "Building standard project variant $variant_name..."
4146
pushd "$work_dir" > /dev/null
42-
cmake --preset "$PRESET" -B build $cmakelists_args || {
47+
"$CMAKE_COMMAND" --preset "$PRESET" -B build $cmakelists_args || {
4348
echo -e "\n\n*** configure failed: $variant_name ***"
4449
echo "*** Sometimes local CMake modules require a newer compiler than the host default."
4550
# If failure is just a module C++ scan lack of support, we could suppress, but let's hard fail.
4651
popd > /dev/null && rm -rf "$work_dir"
4752
exit 1
4853
}
49-
cmake --build build
50-
ctest --test-dir build --output-on-failure
54+
"$CMAKE_COMMAND" --build build
55+
"$CTEST_COMMAND" --test-dir build --output-on-failure
5156

5257
# Cleanup this variant's dir
5358
popd > /dev/null && rm -rf "$work_dir"

template/.github/workflows/ci_tests.yml.jinja

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,28 @@ jobs:
3838
# gcc-release will use GCC 15 which supports C++23 modules appropriately in this container
3939
run: ./copier/test_standard_project.sh gcc-release
4040

41+
copier-cmake-matrix:
42+
runs-on: ubuntu-latest
43+
container:
44+
image: ghcr.io/bemanproject/infra-containers-gcc:latest
45+
strategy:
46+
fail-fast: false
47+
matrix:
48+
cmake_version: ["3.30.9", "3.31.10", "4.0.3", "4.1.3", "4.2.3", "4.3.2"]
49+
steps:
50+
- uses: actions/checkout@v4
51+
- name: Install uv
52+
shell: bash
53+
run: |
54+
curl -LsSf https://astral.sh/uv/install.sh | sh
55+
echo "$HOME/.local/bin" >> $GITHUB_PATH
56+
- name: Test Copier Template Variants Matrix
57+
shell: bash
58+
env:
59+
GITHUB_ACTIONS: true
60+
# Run across our experimental boundaries
61+
run: ./copier/test_cmake_matrix.sh gcc-release ${{ matrix.cmake_version }}
62+
4163
preset-test:
4264
uses: bemanproject/infra-workflows/.github/workflows/reusable-beman-preset-test.yml@1.7.2
4365
with:

0 commit comments

Comments
 (0)