From ce20d1504895ec8004a0e4fc1c5cb8e0842fc6b3 Mon Sep 17 00:00:00 2001 From: Andrey Semashev Date: Tue, 6 Feb 2024 02:30:13 +0300 Subject: [PATCH] Fix posix-cmake-test failures on Mac OS. Properly set BUILD_JOBS environment variable in CMake-related jobs as it is used in build and run steps. Without the variable being set, -j without a number means "no limit on the number of jobs", which may hit system resource limits and cause the job to fail. Also, Mac OS seem to sometimes hang on too many parallel build jobs, even if BUILD_JOBS is specified correctly. So disable parallel builds for now. Additionally, use GIT_FETCH_JOBS universally. --- .github/workflows/ci.yml | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bede815..579a481 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -636,6 +636,9 @@ jobs: echo REF: $REF BOOST_BRANCH=develop && [ "$REF" = "master" ] && BOOST_BRANCH=master || true echo BOOST_BRANCH: $BOOST_BRANCH + BUILD_JOBS=$((nproc || sysctl -n hw.ncpu) 2> /dev/null) + echo "BUILD_JOBS=$BUILD_JOBS" >> $GITHUB_ENV + echo "CMAKE_BUILD_PARALLEL_LEVEL=$BUILD_JOBS" >> $GITHUB_ENV mkdir -p snapshot cd snapshot echo "Downloading library snapshot: https://github.com/${GITHUB_REPOSITORY}/archive/${GITHUB_SHA}.tar.gz" @@ -698,6 +701,9 @@ jobs: echo REF: $REF BOOST_BRANCH=develop && [ "$REF" = "master" ] && BOOST_BRANCH=master || true echo BOOST_BRANCH: $BOOST_BRANCH + BUILD_JOBS=$((nproc || sysctl -n hw.ncpu) 2> /dev/null) + echo "BUILD_JOBS=$BUILD_JOBS" >> $GITHUB_ENV + echo "CMAKE_BUILD_PARALLEL_LEVEL=$BUILD_JOBS" >> $GITHUB_ENV mkdir -p snapshot cd snapshot echo "Downloading library snapshot: https://github.com/${GITHUB_REPOSITORY}/archive/${GITHUB_SHA}.tar.gz" @@ -770,6 +776,11 @@ jobs: echo REF: $REF BOOST_BRANCH=develop && [ "$REF" = "master" ] && BOOST_BRANCH=master || true echo BOOST_BRANCH: $BOOST_BRANCH + # Building tests on Mac OS occasionally fail with a timeout if there are too many parallel build jobs + BUILD_JOBS=$((nproc || echo 1) 2> /dev/null) + echo BUILD_JOBS: $BUILD_JOBS + echo "BUILD_JOBS=$BUILD_JOBS" >> $GITHUB_ENV + echo "CMAKE_BUILD_PARALLEL_LEVEL=$BUILD_JOBS" >> $GITHUB_ENV mkdir -p snapshot cd snapshot echo "Downloading library snapshot: https://github.com/${GITHUB_REPOSITORY}/archive/${GITHUB_SHA}.tar.gz" @@ -852,7 +863,7 @@ jobs: move /Y "..\snapshot\%LIBRARY%-%GITHUB_SHA%" "libs\%LIBRARY%" rmdir /s /q "..\snapshot" git submodule update --init tools/boostdep - python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" %LIBRARY% + python tools/boostdep/depinst/depinst.py --git_args "--jobs %GIT_FETCH_JOBS%" %LIBRARY% - name: Use library with add_subdirectory (Debug) shell: cmd @@ -914,7 +925,7 @@ jobs: move /Y "..\snapshot\%LIBRARY%-%GITHUB_SHA%" "libs\%LIBRARY%" rmdir /s /q "..\snapshot" git submodule update --init tools/boostdep - python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" %LIBRARY% + python tools/boostdep/depinst/depinst.py --git_args "--jobs %GIT_FETCH_JOBS%" %LIBRARY% - name: Configure shell: cmd @@ -994,7 +1005,7 @@ jobs: move /Y "..\snapshot\%LIBRARY%-%GITHUB_SHA%" "libs\%LIBRARY%" rmdir /s /q "..\snapshot" git submodule update --init tools/boostdep - python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" %LIBRARY% + python tools/boostdep/depinst/depinst.py --git_args "--jobs %GIT_FETCH_JOBS%" %LIBRARY% - name: Configure shell: cmd