From ea9e8d24983ed094f1eadfbdf4299b6aaf4f8065 Mon Sep 17 00:00:00 2001 From: scawful Date: Sun, 12 Oct 2025 07:43:43 -0400 Subject: [PATCH] feat(ci): improve build parallelization in CI and release workflows - Updated CI and release workflows to determine the number of parallel jobs based on available CPU cores, enhancing build efficiency. - Added checks for `nproc` and `sysctl` commands to dynamically set the core count, defaulting to 2 if neither is available. - Improved logging to indicate the number of parallel jobs being used during the build process. Benefits: - Optimized build performance by utilizing available resources more effectively, leading to faster build times. --- .github/workflows/ci.yml | 12 +++++++++++- .github/workflows/release.yml | 8 +++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cc420942..d788fa0a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -293,9 +293,19 @@ jobs: - name: Build id: build + shell: bash run: | echo "Building with ${{ env.BUILD_TYPE }} configuration..." - cmake --build build --config ${{ env.BUILD_TYPE }} --parallel $(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 2) 2>&1 | tee build.log + # Determine number of parallel jobs based on platform + if command -v nproc >/dev/null 2>&1; then + CORES=$(nproc) + elif command -v sysctl >/dev/null 2>&1; then + CORES=$(sysctl -n hw.ncpu) + else + CORES=2 + fi + echo "Using $CORES parallel jobs" + cmake --build build --config ${{ env.BUILD_TYPE }} --parallel $CORES 2>&1 | tee build.log - name: Report Build Failure if: failure() && steps.build.outcome == 'failure' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 99af5aa2..6e85cff1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -306,7 +306,13 @@ jobs: run: | echo "Building release with ${{ env.BUILD_TYPE }} configuration..." # Use all available cores for faster builds - CORES=$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 2) + if command -v nproc >/dev/null 2>&1; then + CORES=$(nproc) + elif command -v sysctl >/dev/null 2>&1; then + CORES=$(sysctl -n hw.ncpu) + else + CORES=2 + fi echo "Using $CORES parallel jobs" cmake --build build --config ${{ env.BUILD_TYPE }} --parallel $CORES 2>&1 | tee build.log