GHA: Set N parallelism dynamically

To adapt automatically to the number of available CPU cores.
This commit is contained in:
Martin Kinkelin 2024-02-21 01:11:34 +01:00 committed by Iain Buclaw
parent c9f0c364f9
commit 65b6c2b62d
2 changed files with 9 additions and 4 deletions

View file

@ -78,7 +78,7 @@ jobs:
OS_NAME: ${{ startsWith(matrix.os, 'ubuntu') && 'linux' || (startsWith(matrix.os, 'macos') && 'osx' || (startsWith(matrix.os, 'windows') && 'windows' || '')) }}
MODEL: ${{ matrix.model || '64' }}
HOST_DMD: ${{ matrix.host_dmd }}
N: ${{ startsWith(matrix.os, 'macos') && '3' || '4' }}
# N is set dynamically below
FULL_BUILD: true
# for coverage:
DMD_TEST_COVERAGE: ${{ matrix.coverage && '1' || '0' }}
@ -92,6 +92,9 @@ jobs:
with:
fetch-depth: 50
- name: Set environment variable N (parallelism)
run: echo "N=$(${{ runner.os == 'macOS' && 'sysctl -n hw.logicalcpu' || 'nproc' }})" >> $GITHUB_ENV
- name: 'Posix: Install prerequisites'
if: runner.os != 'Windows'
run: ${{ runner.os == 'macOS' && 'ci/cirrusci.sh' || 'sudo -E ci/cirrusci.sh' }}
@ -195,7 +198,7 @@ jobs:
export OS_NAME=freebsd
export MODEL=64
export HOST_DMD='${{ matrix.host_dmd }}'
export N=3
export N="$(nproc)"
export FULL_BUILD=true
export CI_DFLAGS="-version=TARGET_FREEBSD${freebsd_major}"

View file

@ -135,10 +135,12 @@ jobs:
# Using a specific version for reproductibility.
# Feel free to update when a new release has matured.
runs-on: ${{ matrix.os }}
env:
N: ${{ startsWith(matrix.os, 'macos') && '3' || '4' }}
steps:
- name: Set environment variable N (parallelism)
shell: bash
run: echo "N=$(${{ runner.os == 'macOS' && 'sysctl -n hw.logicalcpu' || 'nproc' }})" >> $GITHUB_ENV
########################################
# Setting up the host D compiler #
########################################