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.
This commit is contained in:
12
.github/workflows/ci.yml
vendored
12
.github/workflows/ci.yml
vendored
@@ -293,9 +293,19 @@ jobs:
|
|||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
id: build
|
id: build
|
||||||
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
echo "Building with ${{ env.BUILD_TYPE }} configuration..."
|
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
|
- name: Report Build Failure
|
||||||
if: failure() && steps.build.outcome == 'failure'
|
if: failure() && steps.build.outcome == 'failure'
|
||||||
|
|||||||
8
.github/workflows/release.yml
vendored
8
.github/workflows/release.yml
vendored
@@ -306,7 +306,13 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
echo "Building release with ${{ env.BUILD_TYPE }} configuration..."
|
echo "Building release with ${{ env.BUILD_TYPE }} configuration..."
|
||||||
# Use all available cores for faster builds
|
# 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"
|
echo "Using $CORES parallel jobs"
|
||||||
cmake --build build --config ${{ env.BUILD_TYPE }} --parallel $CORES 2>&1 | tee build.log
|
cmake --build build --config ${{ env.BUILD_TYPE }} --parallel $CORES 2>&1 | tee build.log
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user