summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2024-10-09 15:25:23 +0200
committerJunio C Hamano <gitster@pobox.com>2024-10-09 11:33:04 -0700
commitb7a08e947eb42de6f272d60b68a2e30790e7c0d5 (patch)
tree61c2cbd17c62b4633ce9970c76f871d6e915ca8b
parent91839a882779012a2bc18c1bfd1d8d11fe1099aa (diff)
ci: handle Windows-based CI jobs in GitLab CI
We try to abstract away any differences between different CI platforms in "ci/lib.sh", such that knowledge specific to e.g. GitHub Actions or GitLab CI is neatly encapsulated in a single place. Next to some generic variables, we also set up some variables that are specific to the actual platform that the CI operates on, e.g. Linux or macOS. We do not yet support Windows runners on GitLab CI. Unfortunately, those systems do not use the same "CI_JOB_IMAGE" environment variable as both Linux and macOS do. Instead, we can use the "OS" variable, which should have a value of "Windows_NT" on Windows platforms. Handle the combination of "$OS,$CI_JOB_IMAGE" and introduce support for Windows. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rwxr-xr-xci/lib.sh18
1 files changed, 13 insertions, 5 deletions
diff --git a/ci/lib.sh b/ci/lib.sh
index 74b430be23..95f39a26ea 100755
--- a/ci/lib.sh
+++ b/ci/lib.sh
@@ -250,8 +250,13 @@ then
CI_TYPE=gitlab-ci
CI_BRANCH="$CI_COMMIT_REF_NAME"
CI_COMMIT="$CI_COMMIT_SHA"
- case "$CI_JOB_IMAGE" in
- macos-*)
+
+ 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,
# most notably via asdf and Homebrew. Ensure that our builds
# pick up the Homebrew one by prepending it to our PATH as the
@@ -259,9 +264,12 @@ then
export PATH="$(brew --prefix)/bin:$PATH"
CI_OS_NAME=osx
+ JOBS=$(nproc)
+ ;;
+ *,alpine:*|*,fedora:*|*,ubuntu:*)
+ CI_OS_NAME=linux
+ JOBS=$(nproc)
;;
- alpine:*|fedora:*|ubuntu:*)
- CI_OS_NAME=linux;;
*)
echo "Could not identify OS image" >&2
env >&2
@@ -272,6 +280,7 @@ then
CI_JOB_ID="$CI_JOB_ID"
CC="${CC_PACKAGE:-${CC:-gcc}}"
DONT_SKIP_TAGS=t
+
handle_failed_tests () {
create_failed_test_artifacts
return 1
@@ -280,7 +289,6 @@ then
cache_dir="$HOME/none"
distro=$(echo "$CI_JOB_IMAGE" | tr : -)
- JOBS=$(nproc)
else
echo "Could not identify CI type" >&2
env >&2