Skip to content

Commit 93bc02f

Browse files
committed
Merge branch 'ps/gitlab-ci-macos'
CI for GitLab learned to drive macOS jobs. * ps/gitlab-ci-macos: ci: add macOS jobs to GitLab CI ci: make p4 setup on macOS more robust ci: handle TEST_OUTPUT_DIRECTORY when printing test failures Makefile: detect new Homebrew location for ARM-based Macs t7527: decrease likelihood of racing with fsmonitor daemon
2 parents c7c0811 + 56090a3 commit 93bc02f

File tree

6 files changed

+63
-10
lines changed

6 files changed

+63
-10
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/install-dependencies.sh

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,13 @@ macos-*)
3737
test -z "$BREW_INSTALL_PACKAGES" ||
3838
brew install $BREW_INSTALL_PACKAGES
3939
brew link --force gettext
40-
mkdir -p $HOME/bin
41-
(
42-
cd $HOME/bin
40+
41+
mkdir -p "$P4_PATH"
42+
pushd "$P4_PATH"
4343
wget -q "$P4WHENCE/bin.macosx1015x86_64/helix-core-server.tgz" &&
4444
tar -xf helix-core-server.tgz &&
4545
sudo xattr -d com.apple.quarantine p4 p4d 2>/dev/null || true
46-
)
47-
PATH="$PATH:${HOME}/bin"
48-
export PATH
46+
popd
4947

5048
if test -n "$CC_PACKAGE"
5149
then

ci/lib.sh

Lines changed: 11 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
*)
@@ -344,6 +351,9 @@ macos-*)
344351
then
345352
MAKEFLAGS="$MAKEFLAGS APPLE_COMMON_CRYPTO_SHA1=Yes"
346353
fi
354+
355+
P4_PATH="$HOME/custom/p4"
356+
export PATH="$P4_PATH:$PATH"
347357
;;
348358
esac
349359

ci/print-test-failures.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# Tracing executed commands would produce too much noise in the loop below.
99
set +x
1010

11-
cd t/
11+
cd "${TEST_OUTPUT_DIRECTORY:-t/}"
1212

1313
if ! ls test-results/*.exit >/dev/null 2>/dev/null
1414
then

config.mak.uname

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,19 @@ ifeq ($(uname_S),Darwin)
158158
ifeq ($(shell test -x /usr/local/opt/gettext/bin/msgfmt && echo y),y)
159159
MSGFMT = /usr/local/opt/gettext/bin/msgfmt
160160
endif
161+
# On newer ARM-based machines the default installation path has changed to
162+
# /opt/homebrew. Include it in our search paths so that the user does not
163+
# have to configure this manually.
164+
#
165+
# Note that we do not employ the same workaround as above where we manually
166+
# add gettext. The issue was fixed more than three years ago by now, and at
167+
# that point there haven't been any ARM-based Macs yet.
168+
else ifeq ($(shell test -d /opt/homebrew/ && echo y),y)
169+
BASIC_CFLAGS += -I/opt/homebrew/include
170+
BASIC_LDFLAGS += -L/opt/homebrew/lib
171+
ifeq ($(shell test -x /opt/homebrew/bin/msgfmt && echo y),y)
172+
MSGFMT = /opt/homebrew/bin/msgfmt
173+
endif
161174
endif
162175

163176
# The builtin FSMonitor on MacOS builds upon Simple-IPC. Both require

t/t7527-builtin-fsmonitor.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -978,7 +978,7 @@ test_expect_success !UNICODE_COMPOSITION_SENSITIVE 'Unicode nfc/nfd' '
978978
mkdir test_unicode/nfd &&
979979
mkdir test_unicode/nfd/d_${utf8_nfd} &&
980980
981-
git -C test_unicode fsmonitor--daemon stop &&
981+
test-tool -C test_unicode fsmonitor-client query --token 0 &&
982982
983983
if test_have_prereq UNICODE_NFC_PRESERVED
984984
then

0 commit comments

Comments
 (0)