1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-10-28 04:49:43 +01:00

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>
This commit is contained in:
Patrick Steinhardt 2024-10-09 15:25:23 +02:00 committed by Junio C Hamano
parent 91839a8827
commit b7a08e947e

View file

@ -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