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

[PATCH v2 5/5] ci: add macOS jobs to GitLab CI

From
Patrick Steinhardt <ps@pks.im>
Date
Jan 18, 2024, 10:23 UTC
Message-ID
<c5ed38f0a6378297bde8a63bfe8ff8428cc4c966.1705573336.git.ps@pks.im>
In-Reply-To
<cover.1705573336.git.ps@pks.im>

Add a job to GitLab CI which runs tests on macOS, which matches the equivalent "osx-clang" job that we have for GitHub Workflows. One significant difference though is that this new job runs on Apple M1 machines and thus uses the "arm64" architecture. As GCC does not yet support this comparatively new architecture we cannot easily include an equivalent for the "osx-gcc" job that exists in GitHub Workflows.

Note that one test marked as `test_must_fail` is surprisingly passing:
  t7815-grep-binary.sh                             (Wstat: 0 Tests: 22 Failed: 0)
    TODO passed:   12

This seems to boil down to an unexpected difference in how regcomp(3P) works when matching NUL bytes. Cross-checking with the respective GitHub job shows that this is not an issue unique to the GitLab CI job as it passes in the same way there.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 .gitlab-ci.yml | 34 +++++++++++++++++++++++++++++++++-
 ci/lib.sh      |  9 ++++++++-
 2 files changed, 41 insertions(+), 2 deletions(-)
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 793243421c..43bfbd8834 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -7,7 +7,7 @@ workflow:
     - if: $CI_COMMIT_TAG
     - if: $CI_COMMIT_REF_PROTECTED == "true"
 
-test:
+test:linux:
   image: $image
   before_script:
     - ./ci/install-docker-dependencies.sh
@@ -52,6 +52,38 @@ test:
       - t/failed-test-artifacts
     when: on_failure
 
+test:osx:
+  image: $image
+  tags:
+    - saas-macos-medium-m1
+  variables:
+    TEST_OUTPUT_DIRECTORY: "/Volumes/RAMDisk"
+  before_script:
+    # Create a 4GB RAM disk that we use to store test output on. This small hack
+    # significantly speeds up tests by more than a factor of 2 because the
+    # macOS runners use network-attached storage as disks, which is _really_
+    # slow with the many small writes that our tests do.
+    - sudo diskutil apfs create $(hdiutil attach -nomount ram://8192000) RAMDisk
+    - ./ci/install-dependencies.sh
+  script:
+    - ./ci/run-build-and-tests.sh
+  after_script:
+    - |
+      if test "$CI_JOB_STATUS" != 'success'
+      then
+        ./ci/print-test-failures.sh
+        mv "$TEST_OUTPUT_DIRECTORY"/failed-test-artifacts t/
+      fi
+  parallel:
+    matrix:
+      - jobname: osx-clang
+        image: macos-13-xcode-14
+        CC: clang
+  artifacts:
+    paths:
+      - t/failed-test-artifacts
+    when: on_failure
+
 static-analysis:
   image: ubuntu:22.04
   variables:
diff --git a/ci/lib.sh b/ci/lib.sh
index f631206a44..d5dd2f2697 100755
--- a/ci/lib.sh
+++ b/ci/lib.sh
@@ -252,7 +252,14 @@ then
 	CI_COMMIT="$CI_COMMIT_SHA"
 	case "$CI_JOB_IMAGE" in
 	macos-*)
-		CI_OS_NAME=osx;;
+		# 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
+		# asdf one breaks tests.
+		export PATH="$(brew --prefix)/bin:$PATH"
+
+		CI_OS_NAME=osx
+		;;
 	alpine:*|fedora:*|ubuntu:*)
 		CI_OS_NAME=linux;;
 	*)
-- 
2.43.GIT
Previous: Patrick SteinhardtNext: Phillip Wood
Message 14 of 17 in “ci: add support for macOS to GitLab CI”
  1. 0/3 ci: add support for macOS to GitLab CIPatrick Steinhardt, Jan 15, 2024
  2. 1/3 ci: make p4 setup on macOS more robustPatrick Steinhardt, Jan 15, 2024
  3. Matthias AßhauerJan 18, 2024
  4. Patrick SteinhardtJan 18, 2024
  5. 2/3 Makefile: detect new Homebrew location for ARM-based MacsPatrick Steinhardt, Jan 15, 2024
  6. 3/3 ci: add macOS jobs to GitLab CIPatrick Steinhardt, Jan 15, 2024
  7. Phillip WoodJan 16, 2024
  8. Patrick SteinhardtJan 17, 2024
  9. 0/5 ci: add support for macOS to GitLab CIPatrick Steinhardt, Jan 18, 2024
  10. 1/5 t7527: decrease likelihood of racing with fsmonitor daemonPatrick Steinhardt, Jan 18, 2024
  11. 2/5 Makefile: detect new Homebrew location for ARM-based MacsPatrick Steinhardt, Jan 18, 2024
  12. 3/5 ci: handle TEST_OUTPUT_DIRECTORY when printing test failuresPatrick Steinhardt, Jan 18, 2024
  13. 4/5 ci: make p4 setup on macOS more robustPatrick Steinhardt, Jan 18, 2024
  14. 5/5 ci: add macOS jobs to GitLab CIPatrick Steinhardt, Jan 18, 2024
  15. Phillip WoodJan 21, 2024
  16. Patrick SteinhardtJan 22, 2024
  17. Junio C HamanoJan 22, 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.