Skip to content

Commit 5c52397

Browse files
committed
ci: optimize workflows with ccache and parallel builds
- Add ccache action and CMake launcher options to cpp-ci workflow - Enable parallel CMake builds (--parallel) for C++ CI - Add pip caching to Python setup actions - Set CMAKE_BUILD_PARALLEL_LEVEL=4 for cibuildwheel builds
1 parent d01f485 commit 5c52397

4 files changed

Lines changed: 18 additions & 7 deletions

File tree

.github/workflows/BuildAndPublish.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ jobs:
2828
- uses: actions/setup-python@v5
2929
with:
3030
python-version: "3.12"
31+
cache: 'pip'
3132

3233
- name: Add requirements
3334
run: python -m pip install --upgrade setuptools pybind11>=2.12.0 cibuildwheel
@@ -40,8 +41,8 @@ jobs:
4041
env:
4142
CIBW_ARCHS: auto64
4243
CIBW_BUILD_FRONTEND: "pip; args: --verbose"
43-
CIBW_ENVIRONMENT: "FORCE_AVX2=1"
44-
CIBW_ENVIRONMENT_MACOS: "FORCE_AVX2=1 MACOSX_DEPLOYMENT_TARGET=11.00"
44+
CIBW_ENVIRONMENT: "FORCE_AVX2=1 CMAKE_BUILD_PARALLEL_LEVEL=4"
45+
CIBW_ENVIRONMENT_MACOS: "FORCE_AVX2=1 MACOSX_DEPLOYMENT_TARGET=11.00 CMAKE_BUILD_PARALLEL_LEVEL=4"
4546
CIBW_SKIP: "cp314-* cp314t-* pp*win*"
4647

4748
# upload artifacts

.github/workflows/BuildAndTest.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ jobs:
2424
- uses: actions/setup-python@v5
2525
with:
2626
python-version: "3.12"
27+
cache: 'pip'
2728

2829
- name: Add requirements
2930
run: python -m pip install --upgrade setuptools pybind11>=2.12.0 cibuildwheel
@@ -36,8 +37,8 @@ jobs:
3637
env:
3738
CIBW_ARCHS: auto64
3839
CIBW_BUILD_FRONTEND: "pip; args: --verbose"
39-
CIBW_ENVIRONMENT: "FORCE_AVX2=1"
40-
CIBW_ENVIRONMENT_MACOS: "FORCE_AVX2=1 MACOSX_DEPLOYMENT_TARGET=11.00"
40+
CIBW_ENVIRONMENT: "FORCE_AVX2=1 CMAKE_BUILD_PARALLEL_LEVEL=4"
41+
CIBW_ENVIRONMENT_MACOS: "FORCE_AVX2=1 MACOSX_DEPLOYMENT_TARGET=11.00 CMAKE_BUILD_PARALLEL_LEVEL=4"
4142
CIBW_SKIP: "cp314t-* cp314-* pp*win*"
4243

4344
build_sdist:

.github/workflows/cpp-ci.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,17 @@ jobs:
2121
with:
2222
submodules: recursive
2323

24+
- name: Setup ccache
25+
uses: hendrikmuhs/ccache-action@v1.2
26+
with:
27+
key: ${{ matrix.os }}-ccache-${{ github.sha }}
28+
restore-keys: ${{ matrix.os }}-ccache-
29+
2430
- name: Configure CMake
25-
run: cmake -B build -S cpp -DFORCE_AVX2=ON -DENABLE_BENCHMARKS=OFF
31+
run: cmake -B build -S cpp -DFORCE_AVX2=ON -DENABLE_BENCHMARKS=OFF -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
2632

2733
- name: Build
28-
run: cmake --build build --config Release
34+
run: cmake --build build --config Release --parallel
2935

3036
- name: Run Tests
3137
run: ctest --test-dir build --output-on-failure -C Release

cpp/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ project(
1515

1616
# build options
1717
option(ENABLE_BENCHMARKS "compile benchmarks" ON)
18+
option(ENABLE_TESTING "compile tests" ON)
1819
option(FORCE_AVX2 "compile for avx2 support. Otherwise compile for this machine." OFF)
1920

2021
# https://cmake.org/cmake/help/latest/prop_tgt/CXX_STANDARD.html
@@ -96,7 +97,9 @@ message("C++ compiler flags release: ${CMAKE_CXX_FLAGS_RELEASE}")
9697

9798
enable_testing()
9899
add_subdirectory(deglib)
99-
add_subdirectory(test)
100+
if (ENABLE_TESTING)
101+
add_subdirectory(test)
102+
endif()
100103

101104
if (ENABLE_BENCHMARKS)
102105
add_subdirectory(external/fmt)

0 commit comments

Comments
 (0)