ci: add macOS jobs to GitLab CI

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> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Patrick Steinhardt committed Jan 18, 2024 at 11:23 UTC 56090a35ab20c21ef577bd1ed2d9d5b63eb5f649
2 files changed +41 -2
.gitlab-ci.yml
+33 -1
@@ -7,7 +7,7 @@ workflow:
7 - if: $CI_COMMIT_TAG
8 - if: $CI_COMMIT_REF_PROTECTED == "true"
9
10 -test:
10 +test:linux:
11 image: $image
12 before_script:
13 - ./ci/install-docker-dependencies.sh
@@ -52,6 +52,38 @@ test:
52 - t/failed-test-artifacts
53 when: on_failure
54
55 +test:osx:
56 + image: $image
57 + tags:
58 + - saas-macos-medium-m1
59 + variables:
60 + TEST_OUTPUT_DIRECTORY: "/Volumes/RAMDisk"
61 + before_script:
62 + # Create a 4GB RAM disk that we use to store test output on. This small hack
63 + # significantly speeds up tests by more than a factor of 2 because the
64 + # macOS runners use network-attached storage as disks, which is _really_
65 + # slow with the many small writes that our tests do.
66 + - sudo diskutil apfs create $(hdiutil attach -nomount ram://8192000) RAMDisk
67 + - ./ci/install-dependencies.sh
68 + script:
69 + - ./ci/run-build-and-tests.sh
70 + after_script:
71 + - |
72 + if test "$CI_JOB_STATUS" != 'success'
73 + then
74 + ./ci/print-test-failures.sh
75 + mv "$TEST_OUTPUT_DIRECTORY"/failed-test-artifacts t/
76 + fi
77 + parallel:
78 + matrix:
79 + - jobname: osx-clang
80 + image: macos-13-xcode-14
81 + CC: clang
82 + artifacts:
83 + paths:
84 + - t/failed-test-artifacts
85 + when: on_failure
86 +
87 static-analysis:
88 image: ubuntu:22.04
89 variables:
ci/lib.sh
+8 -1
@@ -252,7 +252,14 @@ then
252 CI_COMMIT="$CI_COMMIT_SHA"
253 case "$CI_JOB_IMAGE" in
254 macos-*)
255 - CI_OS_NAME=osx;;
255 + # GitLab CI has Python installed via multiple package managers,
256 + # most notably via asdf and Homebrew. Ensure that our builds
257 + # pick up the Homebrew one by prepending it to our PATH as the
258 + # asdf one breaks tests.
259 + export PATH="$(brew --prefix)/bin:$PATH"
260 +
261 + CI_OS_NAME=osx
262 + ;;
263 alpine:*|fedora:*|ubuntu:*)
264 CI_OS_NAME=linux;;
265 *)