git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 3/5] ci: handle Windows-based CI jobs in GitLab CI

From
Patrick Steinhardt <ps@pks.im>
Date
Oct 9, 2024, 13:25 UTC
Message-ID
<cb8c49b14e723221588c798a8f4a000510b1d5b5.1728480039.git.ps@pks.im>
In-Reply-To
<cover.1728480039.git.ps@pks.im>

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>
---
 ci/lib.sh | 18 +++++++++++++-----
 1 file 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
-- 
2.47.0.rc1.33.g90fe3800b9.dirty
Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 6 of 8 in “Wire up Windows-based jobs in GitLab CI”
  1. 0/5 Wire up Windows-based jobs in GitLab CIPatrick Steinhardt, Oct 9, 2024
  2. 1/5 t7300: work around platform-specific behaviour with long paths on MinGWPatrick Steinhardt, Oct 9, 2024
  3. Junio C HamanoOct 9, 2024
  4. Patrick SteinhardtOct 10, 2024
  5. 2/5 ci: create script to set up Git for Windows SDKPatrick Steinhardt, Oct 9, 2024
  6. 3/5 ci: handle Windows-based CI jobs in GitLab CIPatrick Steinhardt, Oct 9, 2024
  7. 4/5 gitlab-ci: introduce stages and dependenciesPatrick Steinhardt, Oct 9, 2024
  8. 5/5 gitlab-ci: exercise Git on WindowsPatrick Steinhardt, Oct 9, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.