Skip to content

Commit b7a08e9

Browse files
pks-tgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 91839a8 commit b7a08e9

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

ci/lib.sh

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -250,18 +250,26 @@ then
250250
CI_TYPE=gitlab-ci
251251
CI_BRANCH="$CI_COMMIT_REF_NAME"
252252
CI_COMMIT="$CI_COMMIT_SHA"
253-
case "$CI_JOB_IMAGE" in
254-
macos-*)
253+
254+
case "$OS,$CI_JOB_IMAGE" in
255+
Windows_NT,*)
256+
CI_OS_NAME=windows
257+
JOBS=$NUMBER_OF_PROCESSORS
258+
;;
259+
*,macos-*)
255260
# GitLab CI has Python installed via multiple package managers,
256261
# most notably via asdf and Homebrew. Ensure that our builds
257262
# pick up the Homebrew one by prepending it to our PATH as the
258263
# asdf one breaks tests.
259264
export PATH="$(brew --prefix)/bin:$PATH"
260265

261266
CI_OS_NAME=osx
267+
JOBS=$(nproc)
268+
;;
269+
*,alpine:*|*,fedora:*|*,ubuntu:*)
270+
CI_OS_NAME=linux
271+
JOBS=$(nproc)
262272
;;
263-
alpine:*|fedora:*|ubuntu:*)
264-
CI_OS_NAME=linux;;
265273
*)
266274
echo "Could not identify OS image" >&2
267275
env >&2
@@ -272,6 +280,7 @@ then
272280
CI_JOB_ID="$CI_JOB_ID"
273281
CC="${CC_PACKAGE:-${CC:-gcc}}"
274282
DONT_SKIP_TAGS=t
283+
275284
handle_failed_tests () {
276285
create_failed_test_artifacts
277286
return 1
@@ -280,7 +289,6 @@ then
280289
cache_dir="$HOME/none"
281290

282291
distro=$(echo "$CI_JOB_IMAGE" | tr : -)
283-
JOBS=$(nproc)
284292
else
285293
echo "Could not identify CI type" >&2
286294
env >&2

0 commit comments

Comments
 (0)