ci: align job counts across CI providers

GitHub Actions sets JOBS to ten regardless of runner size, while
GitLab CI uses the detected CPU count. Use the CPU count for Make and
prove on both providers, selecting JOBS after the operating system
is identified.

Use nproc on Linux and NUMBER_OF_PROCESSORS on Windows. On macOS, use
sysctl to avoid requiring nproc before the dependency installer has run;
GitHub macOS images need not provide GNU coreutils.

Assisted-by: LLM
Signed-off-by: Tamir Duberstein <tamird@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Tamir Duberstein 2026-09-25 12:35:39 -04:00 committed by Junio C Hamano
parent 73072c5dcb
commit c694fc2ab7
1 changed files with 12 additions and 4 deletions

View File

@ -226,7 +226,6 @@ then
cache_dir="$HOME/none"

GIT_TEST_OPTS="--github-workflow-markup"
JOBS=10

distro=$(echo "$CI_JOB_IMAGE" | tr : -)
elif test true = "$GITLAB_CI"
@ -242,7 +241,6 @@ then
case "$OS,$CI_JOB_IMAGE" in
Windows_NT,*)
CI_OS_NAME=windows
JOBS=$NUMBER_OF_PROCESSORS
;;
*,macos-*)
# GitLab CI has Python installed via multiple package managers,
@ -252,11 +250,9 @@ then
export PATH="$(brew --prefix)/bin:$PATH"

CI_OS_NAME=osx
JOBS=$(nproc)
;;
*,almalinux:*|*,alpine:*|*,debian:*|*,fedora:*|*,ubuntu:*|*,i386/ubuntu:*)
CI_OS_NAME=linux
JOBS=$(nproc)
;;
*)
echo "Could not identify OS image" >&2
@ -283,6 +279,18 @@ else
exit 1
fi

case "$CI_OS_NAME" in
windows|windows_nt)
JOBS=$NUMBER_OF_PROCESSORS
;;
osx)
JOBS=$(sysctl -n hw.logicalcpu)
;;
*)
JOBS=$(nproc)
;;
esac

MAKEFLAGS="$MAKEFLAGS --jobs=$JOBS"
GIT_PROVE_OPTS="--timer --jobs $JOBS"