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
This commit is contained in:
Junio C Hamano 2024-01-26 08:54:47 -08:00
commit 93bc02f8f9
6 changed files with 63 additions and 10 deletions

View file

@ -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:

View file

@ -37,15 +37,13 @@ macos-*)
test -z "$BREW_INSTALL_PACKAGES" ||
brew install $BREW_INSTALL_PACKAGES
brew link --force gettext
mkdir -p $HOME/bin
(
cd $HOME/bin
mkdir -p "$P4_PATH"
pushd "$P4_PATH"
wget -q "$P4WHENCE/bin.macosx1015x86_64/helix-core-server.tgz" &&
tar -xf helix-core-server.tgz &&
sudo xattr -d com.apple.quarantine p4 p4d 2>/dev/null || true
)
PATH="$PATH:${HOME}/bin"
export PATH
popd
if test -n "$CC_PACKAGE"
then

View file

@ -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;;
*)
@ -344,6 +351,9 @@ macos-*)
then
MAKEFLAGS="$MAKEFLAGS APPLE_COMMON_CRYPTO_SHA1=Yes"
fi
P4_PATH="$HOME/custom/p4"
export PATH="$P4_PATH:$PATH"
;;
esac

View file

@ -8,7 +8,7 @@
# Tracing executed commands would produce too much noise in the loop below.
set +x
cd t/
cd "${TEST_OUTPUT_DIRECTORY:-t/}"
if ! ls test-results/*.exit >/dev/null 2>/dev/null
then

View file

@ -158,6 +158,19 @@ ifeq ($(uname_S),Darwin)
ifeq ($(shell test -x /usr/local/opt/gettext/bin/msgfmt && echo y),y)
MSGFMT = /usr/local/opt/gettext/bin/msgfmt
endif
# On newer ARM-based machines the default installation path has changed to
# /opt/homebrew. Include it in our search paths so that the user does not
# have to configure this manually.
#
# Note that we do not employ the same workaround as above where we manually
# add gettext. The issue was fixed more than three years ago by now, and at
# that point there haven't been any ARM-based Macs yet.
else ifeq ($(shell test -d /opt/homebrew/ && echo y),y)
BASIC_CFLAGS += -I/opt/homebrew/include
BASIC_LDFLAGS += -L/opt/homebrew/lib
ifeq ($(shell test -x /opt/homebrew/bin/msgfmt && echo y),y)
MSGFMT = /opt/homebrew/bin/msgfmt
endif
endif
# The builtin FSMonitor on MacOS builds upon Simple-IPC. Both require

View file

@ -978,7 +978,7 @@ test_expect_success !UNICODE_COMPOSITION_SENSITIVE 'Unicode nfc/nfd' '
mkdir test_unicode/nfd &&
mkdir test_unicode/nfd/d_${utf8_nfd} &&
git -C test_unicode fsmonitor--daemon stop &&
test-tool -C test_unicode fsmonitor-client query --token 0 &&
if test_have_prereq UNICODE_NFC_PRESERVED
then