]> git.ipfire.org Git - thirdparty/git.git/commitdiff
ci: handle Windows-based CI jobs in GitLab CI
authorPatrick Steinhardt <ps@pks.im>
Wed, 9 Oct 2024 13:25:23 +0000 (15:25 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 9 Oct 2024 18:33:04 +0000 (11:33 -0700)
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>
ci/lib.sh

index 74b430be2387ac1af2fc382e158cdd36df70b9d4..95f39a26eac82c5fd08cfc3476f3a90dde385a03 100755 (executable)
--- 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