Skip to content

Commit 56090a3

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

File tree

2 files changed

+41
-2
lines changed

2 files changed

+41
-2
lines changed

.gitlab-ci.yml

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ workflow:
77
- if: $CI_COMMIT_TAG
88
- if: $CI_COMMIT_REF_PROTECTED == "true"
99

10-
test:
10+
test:linux:
1111
image: $image
1212
before_script:
1313
- ./ci/install-docker-dependencies.sh
@@ -52,6 +52,38 @@ test:
5252
- t/failed-test-artifacts
5353
when: on_failure
5454

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+
5587
static-analysis:
5688
image: ubuntu:22.04
5789
variables:

ci/lib.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,14 @@ then
252252
CI_COMMIT="$CI_COMMIT_SHA"
253253
case "$CI_JOB_IMAGE" in
254254
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+
;;
256263
alpine:*|fedora:*|ubuntu:*)
257264
CI_OS_NAME=linux;;
258265
*)

0 commit comments

Comments
 (0)