ci: add support for macOS to GitLab CI
cover ci: add support for macOS to GitLab CI
Hi,
this patch series extends GitLab CI to also support macOS. Besides extending test coverage for GitLab users, this change also has the added benefit that the macOS runners at GitLab are based on Apple silicon, which to the best of my knowledge is not something we're currently testing on.
This patch series builds on top of ps/gitlab-ci-static-analysis (currently at cd69c635a1 (ci: add job performing static analysis on GitLab CI, 2023-12-28)) to avoid a conflict.
Patrick
Patrick Steinhardt (3):
ci: make p4 setup on macOS more robust
Makefile: detect new Homebrew location for ARM-based Macs
ci: add macOS jobs to GitLab CI
.gitlab-ci.yml | 26 +++++++++++++++++++++++++- ci/install-dependencies.sh | 10 ++++------ ci/lib.sh | 12 +++++++++++- config.mak.uname | 13 +++++++++++++ 4 files changed, 53 insertions(+), 8 deletions(-)
base-commit: cd69c635a1a62b0c8bfdbf221778be8a512ad048
Signature · 1 line
2.43.GIT
PATCH 1/3 ci: make p4 setup on macOS more robust
When setting up Perforce on macOS we put both p4 and p4d into "$HOME/bin". On GitHub CI this directory is indeed contained in the PATH environment variable and thus there is no need for additional setup than to put the binaries there. But GitLab CI does not do this, and thus our Perforce-based tests would be skipped there even though we download the binaries.
Refactor the setup code to become more robust by downloading binaries into a separate directory which we then manually append to our PATH. This matches what we do on Linux-based jobs.
--- ci/install-dependencies.sh | 10 ++++------ ci/lib.sh | 3 +++ 2 files changed, 7 insertions(+), 6 deletions(-)
ci/install-dependencies.sh +4 -6
@@ -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
ci/lib.sh +3 -0
@@ -344,6 +344,9 @@ macos-*) then MAKEFLAGS="$MAKEFLAGS APPLE_COMMON_CRYPTO_SHA1=Yes" fi + + P4_PATH="$HOME/custom/p4" + export PATH="$P4_PATH:$PATH" ;; esac
Signature · 1 line
2.43.GIT
PATCH 2/3 Makefile: detect new Homebrew location for ARM-based Macs
In reply to Patrick SteinhardtWith the introduction of the ARM-based Macs the default location for Homebrew has changed from "/usr/local" to "/opt/homebrew". We only handle the former location though, which means that unless the user has manually configured required search paths we won't be able to locate it.
Improve upon this by adding relevant paths to our CFLAGS and LDFLAGS as well as detecting the location of msgfmt(1).
--- config.mak.uname | 13 +++++++++++++ 1 file changed, 13 insertions(+)
config.mak.uname +13 -0
@@ -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
Signature · 1 line
2.43.GIT
PATCH 3/3 ci: add macOS jobs to GitLab CI
In reply to Patrick SteinhardtAdd two macOS-based jobs to GitLab CI, one for Clang and one for GCC. This matches equivalent jobs we have for GitHub Workflows, except that we use macOS 14 instead of macOS 13.
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(1) works when matching NUL bytes. Cross-checking with the respective GitHub job shows though that this is not an issue unique to the GitLab CI job as it passes in the same way there.
Further note that we do not include the equivalent for the "osx-gcc" job that we use with GitHub Workflows. This is because the runner for macOS on GitLab is running on Apple M1 machines and thus uses the "arm64" architecture. GCC does not support this platform yet.
--- .gitlab-ci.yml | 26 +++++++++++++++++++++++++- ci/lib.sh | 9 ++++++++- 2 files changed, 33 insertions(+), 2 deletions(-)
.gitlab-ci.yml +25 -1
@@ -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,30 @@ test: - t/failed-test-artifacts when: on_failure +test:osx: + image: $image + tags: + - saas-macos-medium-m1 + before_script: + - ./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 + 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:
ci/lib.sh +8 -1
@@ -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;; *)
Signature · 1 line
2.43.GIT
Re: [PATCH 3/3] ci: add macOS jobs to GitLab CI
Hi Patrick
Quoted 1 line · Patrick Steinhardt
Add two macOS-based jobs to GitLab CI, one for Clang and one for GCC.
This doesn't match whats in the rest of the commit message where you explain why there is no gcc job. The patch itself looks good to me and it is nice that we'll now be testing on arm64 with the GitLab runners.
Quoted 9 lines
This matches equivalent jobs we have for GitHub Workflows, except that we use macOS 14 instead of macOS 13.
Note that one test marked as
test_must_failis surprisingly passing:
t7815-grep-binary.sh(Wstat: 0 Tests: 22 Failed: 0)
TODO passed: 12This seems to boil down to an unexpected difference in how regcomp(1)
nit: regcomp(3)?
Best Wishes
Phillip
Quoted 79 lines
works when matching NUL bytes. Cross-checking with the respective GitHub job shows though that this is not an issue unique to the GitLab CI job as it passes in the same way there.
Further note that we do not include the equivalent for the "osx-gcc" job that we use with GitHub Workflows. This is because the runner for macOS on GitLab is running on Apple M1 machines and thus uses the "arm64" architecture. GCC does not support this platform yet.
Signed-off-by Patrick Steinhardt <[email protected]>--- .gitlab-ci.yml | 26 +++++++++++++++++++++++++- ci/lib.sh | 9 ++++++++- 2 files changed, 33 insertions(+), 2 deletions(-).gitlab-ci.yml +25
-1@@ -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,30 @@ test: - t/failed-test-artifacts when: on_failure +test:osx: + image: $image + tags: + - saas-macos-medium-m1 + before_script: + - ./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 + 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:ci/lib.sh +8
-1@@ -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;; *)
Re: [PATCH 3/3] ci: add macOS jobs to GitLab CI
Quoted 8 lines · Phillip Wood
Hi Patrick
Quoted 1 line · Patrick Steinhardt
Add two macOS-based jobs to GitLab CI, one for Clang and one for GCC.
This doesn't match whats in the rest of the commit message where you explain why there is no gcc job. The patch itself looks good to me and it is nice that we'll now be testing on arm64 with the GitLab runners.
Oops. In my first iterations I still had an osx-gcc job, but I could not get it passing due to the architectural difficulties explained in the message, so I ended up removing it. This sentence is thus a leftover from previous iterations.
Quoted 11 lines
Quoted 9 lines
This matches equivalent jobs we have for GitHub Workflows, except that we use macOS 14 instead of macOS 13.
Note that one test marked as
test_must_failis surprisingly passing:
t7815-grep-binary.sh(Wstat: 0 Tests: 22 Failed: 0)
TODO passed: 12This seems to boil down to an unexpected difference in how regcomp(1)
nit: regcomp(3)?
Indeed, thanks!
Patrick
Re: [PATCH 1/3] ci: make p4 setup on macOS more robust
In reply to Patrick SteinhardtQuoted 27 lines · Patrick Steinhardt
When setting up Perforce on macOS we put both
p4andp4dinto "$HOME/bin". On GitHub CI this directory is indeed contained in the PATH environment variable and thus there is no need for additional setup than to put the binaries there. But GitLab CI does not do this, and thus our Perforce-based tests would be skipped there even though we download the binaries.Refactor the setup code to become more robust by downloading binaries into a separate directory which we then manually append to our PATH. This matches what we do on Linux-based jobs.
Signed-off-by Patrick Steinhardt <[email protected]>---
ci/install-dependencies.sh| 10 ++++------ci/lib.sh| 3 +++2 files changed, 7 insertions(+), 6 deletions(-)ci/install-dependencies.sh +0
-2@@ -37,15 +37,13 @@ macos-*) test -z "$BREW_INSTALL_PACKAGES" || brew install $BREW_INSTALL_PACKAGES brew link --force gettext - mkdir -p $HOME/bin - (
ci/install-dependencies.sh macos-*) · line 48
Quoted 10 lines
ci/install-dependencies.sh +3
-4- 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
Didn't this put "$HOME/bin" on the PATH? And isn't the main premise of this patch that "$HOME/bin" is not on the PATH? or is the issue mainly about where we modify and export PATH and was masked by GitHub Actions already having "$HOME/bin" on the PATH?
Quoted 22 lines
ci/install-dependencies.sh +1
-0+ popd if test -n "$CC_PACKAGE" thenci/lib.sh +3
-0@@ -344,6 +344,9 @@ macos-*) then MAKEFLAGS="$MAKEFLAGS APPLE_COMMON_CRYPTO_SHA1=Yes" fi + + P4_PATH="$HOME/custom/p4" + export PATH="$P4_PATH:$PATH" ;;esac
Signature · 1 line
2.43.GIT
Re: [PATCH 1/3] ci: make p4 setup on macOS more robust
Quoted 38 lines · Matthias Aßhauer
Quoted 34 lines · Patrick Steinhardt
When setting up Perforce on macOS we put both
p4andp4dinto "$HOME/bin". On GitHub CI this directory is indeed contained in the PATH environment variable and thus there is no need for additional setup than to put the binaries there. But GitLab CI does not do this, and thus our Perforce-based tests would be skipped there even though we download the binaries.Refactor the setup code to become more robust by downloading binaries into a separate directory which we then manually append to our PATH. This matches what we do on Linux-based jobs.
Signed-off-by Patrick Steinhardt <[email protected]>---
ci/install-dependencies.sh| 10 ++++------ci/lib.sh| 3 +++2 files changed, 7 insertions(+), 6 deletions(-)ci/install-dependencies.sh +3
-3@@ -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
Quoted 8 lines
ci/install-dependencies.sh macos-*) · line 48
Quoted 3 lines
ci/install-dependencies.sh +0
-3- ) - PATH="$PATH:${HOME}/bin" - export PATHDidn't this put "$HOME/bin" on the PATH? And isn't the main premise of this patch that "$HOME/bin" is not on the PATH?
or is the issue mainly about where we modify and export PATH and was masked by GitHub Actions already having "$HOME/bin" on the PATH?
Yes and no. While these lines put it in PATH, this only works inside of "ci/install-dependencies.sh". When we call "ci/run-build-and-test.sh" we do not source this script though, which means that "$HOME/bin" will not be part of PATH during the actual test run unless it was already added by the CI.
I'll update the commit message to explain this better.
Patrick
v2 cover ci: add support for macOS to GitLab CI
In reply to Patrick SteinhardtHi,
this is the second version of my patch series that adds a macOS job to GitLab CI. Changes compared to v1:
- Added a fix for a flaky test in t7527 that caused the pipeline to fail in ~50% of all runs.
- Improved some commit messages.
- Tests now write test data into a RAMDisk. This speeds up tests and fixes some hung pipelines I was seeing.
Thanks for your reviews so far!
Patrick
Patrick Steinhardt (5):
t7527: decrease likelihood of racing with fsmonitor daemon
Makefile: detect new Homebrew location for ARM-based Macs
ci: handle TEST_OUTPUT_DIRECTORY when printing test failures
ci: make p4 setup on macOS more robust
ci: add macOS jobs to GitLab CI
.gitlab-ci.yml | 34 +++++++++++++++++++++++++++++++++- ci/install-dependencies.sh | 10 ++++------ ci/lib.sh | 12 +++++++++++- ci/print-test-failures.sh | 2 +- config.mak.uname | 13 +++++++++++++ t/t7527-builtin-fsmonitor.sh | 2 +- 6 files changed, 63 insertions(+), 10 deletions(-)
Range-diff against v1:
-: ---------- > 1: 554b1c8546 t7527: decrease likelihood of racing with fsmonitor daemon 2: 3adb0b7ae8 = 2: 32d8bd1d78 Makefile: detect new Homebrew location for ARM-based Macs -: ---------- > 3: d55da77747 ci: handle TEST_OUTPUT_DIRECTORY when printing test failures 1: a5d725bea7 ! 4: 1ed6e68650 ci: make p4 setup on macOS more robust
@@ Commit message
into a separate directory which we then manually append to our PATH. This matches what we do on Linux-based jobs.
+ Note that it may seem like we already did append "$HOME/bin" to PATH
+ because we're actually removing the lines that adapt PATH. But we only
+ ever adapted the PATH variable in "ci/install-dependencies.sh", and
+ didn't adapt it when running "ci/run-build-and-test.sh". Consequently,
+ the required binaries wouldn't be found during the test run unless the
+ CI platform already had the "$HOME/bin" in PATH right from the start.
+
## ci/install-dependencies.sh ##
3: d196cfd9d0 ! 5: c5ed38f0a6 ci: add macOS jobs to GitLab CI
@@ Metadata
## Commit message ##
ci: add macOS jobs to GitLab CI
- Add two macOS-based jobs to GitLab CI, one for Clang and one for GCC.
- This matches equivalent jobs we have for GitHub Workflows, except that
- we use macOS 14 instead of macOS 13.
+ 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(1)
+ 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 though that this is not an issue unique to the GitLab CI job
- as it passes in the same way there.
-
- Further note that we do not include the equivalent for the "osx-gcc" job
- that we use with GitHub Workflows. This is because the runner for macOS
- on GitLab is running on Apple M1 machines and thus uses the "arm64"
- architecture. GCC does not support this platform yet.
+ job shows that this is not an issue unique to the GitLab CI job as it
+ passes in the same way there.
@@ .gitlab-ci.yml: test:
+ 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
@@ .gitlab-ci.yml: test:
+ if test "$CI_JOB_STATUS" != 'success'
+ then
+ ./ci/print-test-failures.sh
++ mv "$TEST_OUTPUT_DIRECTORY"/failed-test-artifacts t/
+ fi
+ parallel:
+ matrix:
base-commit: cd69c635a1a62b0c8bfdbf221778be8a512ad048
Signature · 1 line
2.43.GIT
PATCH v2 1/5 t7527: decrease likelihood of racing with fsmonitor daemon
In t7527, we test that the builtin fsmonitor daemon works well in various edge cases. One of these tests is frequently failing because events reported by the fsmonitor--daemon are missing an expected event. This failure is essentially a race condition: we do not wait for the daemon to flush out all events before we ask it to quit. Consequently, it can happen that we miss some expected events.
In other testcases we counteract this race by sending a simple query to the daemon. Quoting a comment:
We run a simple query after modifying the filesystem just to introduce a bit of a delay so that the trace logging from the daemon has time to get flushed to disk.
Now this workaround is not a "proper" fix as we do not wait for all events to have been synchronized in a deterministic way. But this fix seems to be sufficient for all the other tests to pass, so it must not be all that bad.
Convert the failing test to do the same. While the test was previously failing in about 50% of the test runs, I couldn't reproduce the failure after the change anymore.
--- t/t7527-builtin-fsmonitor.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
t/t7527-builtin-fsmonitor.sh +1 -1
@@ -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
Signature · 1 line
2.43.GIT
PATCH v2 2/5 Makefile: detect new Homebrew location for ARM-based Macs
In reply to Patrick SteinhardtWith the introduction of the ARM-based Macs the default location for Homebrew has changed from "/usr/local" to "/opt/homebrew". We only handle the former location though, which means that unless the user has manually configured required search paths we won't be able to locate it.
Improve upon this by adding relevant paths to our CFLAGS and LDFLAGS as well as detecting the location of msgfmt(1).
--- config.mak.uname | 13 +++++++++++++ 1 file changed, 13 insertions(+)
config.mak.uname +13 -0
@@ -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
Signature · 1 line
2.43.GIT
PATCH v2 3/5 ci: handle TEST_OUTPUT_DIRECTORY when printing test failures
In reply to Patrick SteinhardtThe TEST_OUTPUT_DIRECTORY environment variable can be used to instruct the test suite to write test data and test results into a different location than into "t/". The "ci/print-test-failures.sh" script does not know to handle this environment variable though, which means that it will search for test results in the wrong location if it was set.
Update the script to handle TEST_OUTPUT_DIRECTORY so that we can start to set it in our CI.
--- ci/print-test-failures.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
ci/print-test-failures.sh +1 -1
@@ -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
Signature · 1 line
2.43.GIT
PATCH v2 4/5 ci: make p4 setup on macOS more robust
In reply to Patrick SteinhardtWhen setting up Perforce on macOS we put both p4 and p4d into "$HOME/bin". On GitHub CI this directory is indeed contained in the PATH environment variable and thus there is no need for additional setup than to put the binaries there. But GitLab CI does not do this, and thus our Perforce-based tests would be skipped there even though we download the binaries.
Refactor the setup code to become more robust by downloading binaries into a separate directory which we then manually append to our PATH. This matches what we do on Linux-based jobs.
Note that it may seem like we already did append "$HOME/bin" to PATH because we're actually removing the lines that adapt PATH. But we only ever adapted the PATH variable in "ci/install-dependencies.sh", and didn't adapt it when running "ci/run-build-and-test.sh". Consequently, the required binaries wouldn't be found during the test run unless the CI platform already had the "$HOME/bin" in PATH right from the start.
--- ci/install-dependencies.sh | 10 ++++------ ci/lib.sh | 3 +++ 2 files changed, 7 insertions(+), 6 deletions(-)
ci/install-dependencies.sh +4 -6
@@ -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
ci/lib.sh +3 -0
@@ -344,6 +344,9 @@ macos-*) then MAKEFLAGS="$MAKEFLAGS APPLE_COMMON_CRYPTO_SHA1=Yes" fi + + P4_PATH="$HOME/custom/p4" + export PATH="$P4_PATH:$PATH" ;; esac
Signature · 1 line
2.43.GIT
PATCH v2 5/5 ci: add macOS jobs to GitLab CI
In reply to Patrick SteinhardtAdd 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.
--- .gitlab-ci.yml | 34 +++++++++++++++++++++++++++++++++- ci/lib.sh | 9 ++++++++- 2 files changed, 41 insertions(+), 2 deletions(-)
.gitlab-ci.yml +33 -1
@@ -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:
ci/lib.sh +8 -1
@@ -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;; *)
Signature · 1 line
2.43.GIT
Hi Patrick
Quoted 8 lines · Patrick Steinhardt
Hi,
this is the second version of my patch series that adds a macOS job to GitLab CI. Changes compared to v1:
- Added a fix for a flaky test in t7527 that caused the pipeline to fail in ~50% of all runs.
Quoted 6 lines
- Improved some commit messages.
- Tests now write test data into a RAMDisk. This speeds up tests and fixes some hung pipelines I was seeing.
Thanks for your reviews so far!
I've read though all the patches and they seem sensible to me though I'm hardly a macOS expert. I did wonder about the use of pushd/popd in the fourth patch as they are bashisms but that matches what we're doing on Ubuntu already. It's nice to see the GitLab CI running on macOS as well as Linux now.
Best Wishes
Phillip
Quoted 96 lines
Patrick
Patrick Steinhardt (5):
t7527: decrease likelihood of racing with fsmonitor daemon
Makefile: detect new Homebrew location for ARM-based Macs
ci: handleTEST_OUTPUT_DIRECTORYwhen printing test failures
ci: make p4 setup on macOS more robust
ci: add macOS jobs to GitLab CI.gitlab-ci.yml | 34 +++++++++++++++++++++++++++++++++- ci/install-dependencies.sh | 10 ++++------ ci/lib.sh | 12 +++++++++++- ci/print-test-failures.sh | 2 +- config.mak.uname | 13 +++++++++++++ t/t7527-builtin-fsmonitor.sh | 2 +- 6 files changed, 63 insertions(+), 10 deletions(-)Range-diff against v1:
-: ---------- > 1: 554b1c8546 t7527: decrease likelihood of racing with fsmonitor daemon 2: 3adb0b7ae8 = 2: 32d8bd1d78 Makefile: detect new Homebrew location for ARM-based Macs -: ---------- > 3: d55da77747 ci: handle TEST_OUTPUT_DIRECTORY when printing test failures 1: a5d725bea7 ! 4: 1ed6e68650 ci: make p4 setup on macOS more robust@@ Commit message
into a separate directory which we then manually append to our PATH. This matches what we do on Linux-based jobs.+ Note that it may seem like we already did append "$HOME/bin" to PATH
+ because we're actually removing the lines that adapt PATH. But we only
+ ever adapted the PATH variable in "ci/install-dependencies.sh", and
+ didn't adapt it when running "ci/run-build-and-test.sh". Consequently,
+ the required binaries wouldn't be found during the test run unless the
+ CI platform already had the "$HOME/bin" in PATH right from the start.
+Signed-off-by Patrick Steinhardt <[email protected]>##
ci/install-dependencies.sh##
3:d196cfd9d0! 5:c5ed38f0a6ci: add macOS jobs to GitLab CI
@@ Metadata
## Commit message ##
ci: add macOS jobs to GitLab CI- Add two macOS-based jobs to GitLab CI, one for Clang and one for GCC.
- This matches equivalent jobs we have for GitHub Workflows, except that
- we use macOS 14 instead of macOS 13.
+ 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_failis 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(1)
+ 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 though that this is not an issue unique to the GitLab CI job
- as it passes in the same way there.
-
- Further note that we do not include the equivalent for the "osx-gcc" job
- that we use with GitHub Workflows. This is because the runner for macOS
- on GitLab is running on Apple M1 machines and thus uses the "arm64"
- architecture. GCC does not support this platform yet.
+ 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]>@@ .gitlab-ci.yml: test:
+ 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
@@ .gitlab-ci.yml: test:
+ if test "$CI_JOB_STATUS" != 'success'
+ then
+./ci/print-test-failures.sh
++ mv "$TEST_OUTPUT_DIRECTORY"/failed-test-artifacts t/
+ fi
+ parallel:
+ matrix:base-commit:
cd69c635a1a62b0c8bfdbf221778be8a512ad048
Quoted 16 lines · Phillip Wood
Hi Patrick
Quoted 13 lines · Patrick Steinhardt
Hi,
this is the second version of my patch series that adds a macOS job to GitLab CI. Changes compared to v1:
- Added a fix for a flaky test in t7527 that caused the pipeline to fail in ~50% of all runs.
- Improved some commit messages.
- Tests now write test data into a RAMDisk. This speeds up tests and fixes some hung pipelines I was seeing.
Quoted 7 lines
Quoted 1 line
Thanks for your reviews so far!
I've read though all the patches and they seem sensible to me though I'm hardly a macOS expert. I did wonder about the use of pushd/popd in the fourth patch as they are bashisms but that matches what we're doing on Ubuntu already. It's nice to see the GitLab CI running on macOS as well as Linux now.
Yeah, that part is a bit weird, agreed. As you say, I basically copied the code that we use on Ubuntu, and that is intentional because another follow-up patch series will rip out that part and move the shared code into a common "install-p4.sh" script. Like that, we can also easily use this script on the Docker-based Ubuntu jobs.
Thanks for your review!
Patrick
Quoted 7 lines · Phillip Wood
Hi Patrick
...
I've read though all the patches and they seem sensible to me though I'm hardly a macOS expert. I did wonder about the use of pushd/popd in the fourth patch as they are bashisms but that matches what we're doing on Ubuntu already. It's nice to see the GitLab CI running on macOS as well as Linux now.
Thanks, both.