[CI] Build with all available cores (#6768)
authorAndres Noetzli <andres.noetzli@gmail.com>
Sat, 19 Jun 2021 04:07:10 +0000 (21:07 -0700)
committerGitHub <noreply@github.com>
Sat, 19 Jun 2021 04:07:10 +0000 (04:07 +0000)
macOS virtual machines have three available cores but we were only using two of them for our CI. This commit changes the CI to retrieve the number of available cores and then to use that to number to build and test cvc5.

.github/workflows/ci.yml

index 95c6c035c7a88cedc515f0ea3c84f03abe792471..2a41efb59afba13ec86b4bf2e3cd8bc80742b7e3 100644 (file)
@@ -82,6 +82,7 @@ jobs:
         #
         # https://github.com/actions/runner/blob/master/docs/adrs/0278-env-context.md#dont-populate-the-env-context-with-environment-variables-from-runner-machine
         echo "image_version=$ImageVersion" >> $GITHUB_ENV
+        echo "num_proc=$(nproc)" >> $GITHUB_ENV
         echo "/usr/lib/ccache" >> $GITHUB_PATH
 
     # Note: macOS comes with a libedit; it does not need to brew-installed
@@ -103,6 +104,7 @@ jobs:
         #
         # https://github.com/actions/runner/blob/master/docs/adrs/0278-env-context.md#dont-populate-the-env-context-with-environment-variables-from-runner-machine
         echo "image_version=$ImageVersion" >> $GITHUB_ENV
+        echo "num_proc=$(sysctl -n hw.logicalcpu)" >> $GITHUB_ENV
         echo "/usr/local/opt/ccache/libexec" >> $GITHUB_PATH
 
     - name: Install Python Dependencies
@@ -191,14 +193,14 @@ jobs:
           --werror
 
     - name: Build
-      run: make -j2
+      run: make -j${{ env.num_proc }}
       working-directory: build
 
     - name: ccache Statistics
       run: ccache -s
 
     - name: Run CTest
-      run: make -j2 check
+      run: make -j${{ env.num_proc }} check
       env:
         ARGS: --output-on-failure -LE regress[${{ matrix.exclude_regress }}]
         CVC5_REGRESSION_ARGS: --no-early-exit
@@ -207,7 +209,7 @@ jobs:
 
     - name: Install Check
       run: |
-        make -j2 install
+        make -j${{ env.num_proc }} install
         echo -e "#include <cvc5/cvc5.h>\nint main() { cvc5::api::Solver s; return 0; }" > /tmp/test.cpp
         g++ -std=c++11 /tmp/test.cpp -I install/include -L install/lib -lcvc5
       working-directory: build
@@ -225,14 +227,14 @@ jobs:
         mkdir build
         cd build
         cmake .. -DCMAKE_PREFIX_PATH=$(pwd)/../../build/install/lib/cmake
-        make -j2
-        ctest -j2 --output-on-failure
+        make -j${{ env.num_proc }}
+        ctest -j${{ env.num_proc }} --output-on-failure
       working-directory: examples
 
     - name: Build Documentation
       if: matrix.build-documentation
       run: |
-        make -j2 docs-gh
+        make -j${{ env.num_proc }} docs-gh
         if [ "${{ github.event_name }}" == "pull_request" ] ; then
           echo "${{ github.event.number }}" > docs/sphinx-gh/prnum
         fi