git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] ci: add support for macOS to GitLab CI
@ 2024-01-15 11:44 Patrick Steinhardt
  2024-01-15 11:44 ` [PATCH 1/3] ci: make p4 setup on macOS more robust Patrick Steinhardt
                   ` (3 more replies)
  0 siblings, 4 replies; 17+ messages in thread
From: Patrick Steinhardt @ 2024-01-15 11:44 UTC (permalink / raw)
  To: git

[-- Attachment #1: Type: text/plain, Size: 989 bytes --]

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
-- 
2.43.GIT


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 1/3] ci: make p4 setup on macOS more robust
  2024-01-15 11:44 [PATCH 0/3] ci: add support for macOS to GitLab CI Patrick Steinhardt
@ 2024-01-15 11:44 ` Patrick Steinhardt
  2024-01-18  7:19   ` Matthias Aßhauer
  2024-01-15 11:45 ` [PATCH 2/3] Makefile: detect new Homebrew location for ARM-based Macs Patrick Steinhardt
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 17+ messages in thread
From: Patrick Steinhardt @ 2024-01-15 11:44 UTC (permalink / raw)
  To: git

[-- Attachment #1: Type: text/plain, Size: 1725 bytes --]

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.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 ci/install-dependencies.sh | 10 ++++------
 ci/lib.sh                  |  3 +++
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/ci/install-dependencies.sh b/ci/install-dependencies.sh
index 4f407530d3..b4e22de3cb 100755
--- a/ci/install-dependencies.sh
+++ b/ci/install-dependencies.sh
@@ -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
diff --git a/ci/lib.sh b/ci/lib.sh
index c749b21366..f631206a44 100755
--- a/ci/lib.sh
+++ b/ci/lib.sh
@@ -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
 
-- 
2.43.GIT


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 2/3] Makefile: detect new Homebrew location for ARM-based Macs
  2024-01-15 11:44 [PATCH 0/3] ci: add support for macOS to GitLab CI Patrick Steinhardt
  2024-01-15 11:44 ` [PATCH 1/3] ci: make p4 setup on macOS more robust Patrick Steinhardt
@ 2024-01-15 11:45 ` Patrick Steinhardt
  2024-01-15 11:45 ` [PATCH 3/3] ci: add macOS jobs to GitLab CI Patrick Steinhardt
  2024-01-18 10:22 ` [PATCH v2 0/5] ci: add support for macOS " Patrick Steinhardt
  3 siblings, 0 replies; 17+ messages in thread
From: Patrick Steinhardt @ 2024-01-15 11:45 UTC (permalink / raw)
  To: git

[-- Attachment #1: Type: text/plain, Size: 1625 bytes --]

With 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).

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 config.mak.uname | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/config.mak.uname b/config.mak.uname
index 3bb03f423a..dacc95172d 100644
--- a/config.mak.uname
+++ b/config.mak.uname
@@ -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
-- 
2.43.GIT


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 3/3] ci: add macOS jobs to GitLab CI
  2024-01-15 11:44 [PATCH 0/3] ci: add support for macOS to GitLab CI Patrick Steinhardt
  2024-01-15 11:44 ` [PATCH 1/3] ci: make p4 setup on macOS more robust Patrick Steinhardt
  2024-01-15 11:45 ` [PATCH 2/3] Makefile: detect new Homebrew location for ARM-based Macs Patrick Steinhardt
@ 2024-01-15 11:45 ` Patrick Steinhardt
  2024-01-16 14:58   ` Phillip Wood
  2024-01-18 10:22 ` [PATCH v2 0/5] ci: add support for macOS " Patrick Steinhardt
  3 siblings, 1 reply; 17+ messages in thread
From: Patrick Steinhardt @ 2024-01-15 11:45 UTC (permalink / raw)
  To: git

[-- Attachment #1: Type: text/plain, Size: 2672 bytes --]

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.

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.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 .gitlab-ci.yml | 26 +++++++++++++++++++++++++-
 ci/lib.sh      |  9 ++++++++-
 2 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 793243421c..9748970798 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -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:
diff --git a/ci/lib.sh b/ci/lib.sh
index f631206a44..d5dd2f2697 100755
--- a/ci/lib.sh
+++ b/ci/lib.sh
@@ -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;;
 	*)
-- 
2.43.GIT


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [PATCH 3/3] ci: add macOS jobs to GitLab CI
  2024-01-15 11:45 ` [PATCH 3/3] ci: add macOS jobs to GitLab CI Patrick Steinhardt
@ 2024-01-16 14:58   ` Phillip Wood
  2024-01-17  7:34     ` Patrick Steinhardt
  0 siblings, 1 reply; 17+ messages in thread
From: Phillip Wood @ 2024-01-16 14:58 UTC (permalink / raw)
  To: Patrick Steinhardt, git

Hi Patrick

On 15/01/2024 11:45, Patrick Steinhardt wrote:
> 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.

> 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)

nit: regcomp(3)?

Best Wishes

Phillip

> 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 <ps@pks.im>
> ---
>   .gitlab-ci.yml | 26 +++++++++++++++++++++++++-
>   ci/lib.sh      |  9 ++++++++-
>   2 files changed, 33 insertions(+), 2 deletions(-)
> 
> diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
> index 793243421c..9748970798 100644
> --- a/.gitlab-ci.yml
> +++ b/.gitlab-ci.yml
> @@ -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:
> diff --git a/ci/lib.sh b/ci/lib.sh
> index f631206a44..d5dd2f2697 100755
> --- a/ci/lib.sh
> +++ b/ci/lib.sh
> @@ -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;;
>   	*)

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 3/3] ci: add macOS jobs to GitLab CI
  2024-01-16 14:58   ` Phillip Wood
@ 2024-01-17  7:34     ` Patrick Steinhardt
  0 siblings, 0 replies; 17+ messages in thread
From: Patrick Steinhardt @ 2024-01-17  7:34 UTC (permalink / raw)
  To: phillip.wood; +Cc: git

[-- Attachment #1: Type: text/plain, Size: 1133 bytes --]

On Tue, Jan 16, 2024 at 02:58:53PM +0000, Phillip Wood wrote:
> Hi Patrick
> 
> On 15/01/2024 11:45, Patrick Steinhardt wrote:
> > 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.

> > 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)
> 
> nit: regcomp(3)?

Indeed, thanks!

Patrick

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/3] ci: make p4 setup on macOS more robust
  2024-01-15 11:44 ` [PATCH 1/3] ci: make p4 setup on macOS more robust Patrick Steinhardt
@ 2024-01-18  7:19   ` Matthias Aßhauer
  2024-01-18  9:44     ` Patrick Steinhardt
  0 siblings, 1 reply; 17+ messages in thread
From: Matthias Aßhauer @ 2024-01-18  7:19 UTC (permalink / raw)
  To: Patrick Steinhardt; +Cc: git



On Mon, 15 Jan 2024, Patrick Steinhardt wrote:

> 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.
>
> Signed-off-by: Patrick Steinhardt <ps@pks.im>
> ---
> ci/install-dependencies.sh | 10 ++++------
> ci/lib.sh                  |  3 +++
> 2 files changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/ci/install-dependencies.sh b/ci/install-dependencies.sh
> index 4f407530d3..b4e22de3cb 100755
> --- a/ci/install-dependencies.sh
> +++ b/ci/install-dependencies.sh
> @@ -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

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?

> +	popd
>
> 	if test -n "$CC_PACKAGE"
> 	then
> diff --git a/ci/lib.sh b/ci/lib.sh
> index c749b21366..f631206a44 100755
> --- a/ci/lib.sh
> +++ b/ci/lib.sh
> @@ -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
>
> -- 
> 2.43.GIT
>
>

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/3] ci: make p4 setup on macOS more robust
  2024-01-18  7:19   ` Matthias Aßhauer
@ 2024-01-18  9:44     ` Patrick Steinhardt
  0 siblings, 0 replies; 17+ messages in thread
From: Patrick Steinhardt @ 2024-01-18  9:44 UTC (permalink / raw)
  To: Matthias Aßhauer; +Cc: git

[-- Attachment #1: Type: text/plain, Size: 2286 bytes --]

On Thu, Jan 18, 2024 at 08:19:10AM +0100, Matthias Aßhauer wrote:
> 
> 
> On Mon, 15 Jan 2024, Patrick Steinhardt wrote:
> 
> > 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.
> > 
> > Signed-off-by: Patrick Steinhardt <ps@pks.im>
> > ---
> > ci/install-dependencies.sh | 10 ++++------
> > ci/lib.sh                  |  3 +++
> > 2 files changed, 7 insertions(+), 6 deletions(-)
> > 
> > diff --git a/ci/install-dependencies.sh b/ci/install-dependencies.sh
> > index 4f407530d3..b4e22de3cb 100755
> > --- a/ci/install-dependencies.sh
> > +++ b/ci/install-dependencies.sh
> > @@ -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
> 
> 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?

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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH v2 0/5] ci: add support for macOS to GitLab CI
  2024-01-15 11:44 [PATCH 0/3] ci: add support for macOS to GitLab CI Patrick Steinhardt
                   ` (2 preceding siblings ...)
  2024-01-15 11:45 ` [PATCH 3/3] ci: add macOS jobs to GitLab CI Patrick Steinhardt
@ 2024-01-18 10:22 ` Patrick Steinhardt
  2024-01-18 10:22   ` [PATCH v2 1/5] t7527: decrease likelihood of racing with fsmonitor daemon Patrick Steinhardt
                     ` (5 more replies)
  3 siblings, 6 replies; 17+ messages in thread
From: Patrick Steinhardt @ 2024-01-18 10:22 UTC (permalink / raw)
  To: git; +Cc: Phillip Wood, Matthias Aßhauer

[-- Attachment #1: Type: text/plain, Size: 5172 bytes --]

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.

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.
    +
         Signed-off-by: Patrick Steinhardt <ps@pks.im>
     
      ## 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.
     
         Signed-off-by: Patrick Steinhardt <ps@pks.im>
     
    @@ .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
-- 
2.43.GIT


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH v2 1/5] t7527: decrease likelihood of racing with fsmonitor daemon
  2024-01-18 10:22 ` [PATCH v2 0/5] ci: add support for macOS " Patrick Steinhardt
@ 2024-01-18 10:22   ` Patrick Steinhardt
  2024-01-18 10:22   ` [PATCH v2 2/5] Makefile: detect new Homebrew location for ARM-based Macs Patrick Steinhardt
                     ` (4 subsequent siblings)
  5 siblings, 0 replies; 17+ messages in thread
From: Patrick Steinhardt @ 2024-01-18 10:22 UTC (permalink / raw)
  To: git; +Cc: Phillip Wood, Matthias Aßhauer

[-- Attachment #1: Type: text/plain, Size: 1768 bytes --]

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.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 t/t7527-builtin-fsmonitor.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/t/t7527-builtin-fsmonitor.sh b/t/t7527-builtin-fsmonitor.sh
index 78503158fd..363f9dc0e4 100755
--- a/t/t7527-builtin-fsmonitor.sh
+++ b/t/t7527-builtin-fsmonitor.sh
@@ -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
-- 
2.43.GIT


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v2 2/5] Makefile: detect new Homebrew location for ARM-based Macs
  2024-01-18 10:22 ` [PATCH v2 0/5] ci: add support for macOS " Patrick Steinhardt
  2024-01-18 10:22   ` [PATCH v2 1/5] t7527: decrease likelihood of racing with fsmonitor daemon Patrick Steinhardt
@ 2024-01-18 10:22   ` Patrick Steinhardt
  2024-01-18 10:22   ` [PATCH v2 3/5] ci: handle TEST_OUTPUT_DIRECTORY when printing test failures Patrick Steinhardt
                     ` (3 subsequent siblings)
  5 siblings, 0 replies; 17+ messages in thread
From: Patrick Steinhardt @ 2024-01-18 10:22 UTC (permalink / raw)
  To: git; +Cc: Phillip Wood, Matthias Aßhauer

[-- Attachment #1: Type: text/plain, Size: 1625 bytes --]

With 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).

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 config.mak.uname | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/config.mak.uname b/config.mak.uname
index 3bb03f423a..dacc95172d 100644
--- a/config.mak.uname
+++ b/config.mak.uname
@@ -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
-- 
2.43.GIT


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v2 3/5] ci: handle TEST_OUTPUT_DIRECTORY when printing test failures
  2024-01-18 10:22 ` [PATCH v2 0/5] ci: add support for macOS " Patrick Steinhardt
  2024-01-18 10:22   ` [PATCH v2 1/5] t7527: decrease likelihood of racing with fsmonitor daemon Patrick Steinhardt
  2024-01-18 10:22   ` [PATCH v2 2/5] Makefile: detect new Homebrew location for ARM-based Macs Patrick Steinhardt
@ 2024-01-18 10:22   ` Patrick Steinhardt
  2024-01-18 10:22   ` [PATCH v2 4/5] ci: make p4 setup on macOS more robust Patrick Steinhardt
                     ` (2 subsequent siblings)
  5 siblings, 0 replies; 17+ messages in thread
From: Patrick Steinhardt @ 2024-01-18 10:22 UTC (permalink / raw)
  To: git; +Cc: Phillip Wood, Matthias Aßhauer

[-- Attachment #1: Type: text/plain, Size: 989 bytes --]

The 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.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 ci/print-test-failures.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ci/print-test-failures.sh b/ci/print-test-failures.sh
index c33ad4e3a2..b1f80aeac3 100755
--- a/ci/print-test-failures.sh
+++ b/ci/print-test-failures.sh
@@ -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
-- 
2.43.GIT


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v2 4/5] ci: make p4 setup on macOS more robust
  2024-01-18 10:22 ` [PATCH v2 0/5] ci: add support for macOS " Patrick Steinhardt
                     ` (2 preceding siblings ...)
  2024-01-18 10:22   ` [PATCH v2 3/5] ci: handle TEST_OUTPUT_DIRECTORY when printing test failures Patrick Steinhardt
@ 2024-01-18 10:22   ` Patrick Steinhardt
  2024-01-18 10:23   ` [PATCH v2 5/5] ci: add macOS jobs to GitLab CI Patrick Steinhardt
  2024-01-21 14:50   ` [PATCH v2 0/5] ci: add support for macOS " Phillip Wood
  5 siblings, 0 replies; 17+ messages in thread
From: Patrick Steinhardt @ 2024-01-18 10:22 UTC (permalink / raw)
  To: git; +Cc: Phillip Wood, Matthias Aßhauer

[-- Attachment #1: Type: text/plain, Size: 2153 bytes --]

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.

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 <ps@pks.im>
---
 ci/install-dependencies.sh | 10 ++++------
 ci/lib.sh                  |  3 +++
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/ci/install-dependencies.sh b/ci/install-dependencies.sh
index 4f407530d3..b4e22de3cb 100755
--- a/ci/install-dependencies.sh
+++ b/ci/install-dependencies.sh
@@ -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
diff --git a/ci/lib.sh b/ci/lib.sh
index c749b21366..f631206a44 100755
--- a/ci/lib.sh
+++ b/ci/lib.sh
@@ -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
 
-- 
2.43.GIT


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v2 5/5] ci: add macOS jobs to GitLab CI
  2024-01-18 10:22 ` [PATCH v2 0/5] ci: add support for macOS " Patrick Steinhardt
                     ` (3 preceding siblings ...)
  2024-01-18 10:22   ` [PATCH v2 4/5] ci: make p4 setup on macOS more robust Patrick Steinhardt
@ 2024-01-18 10:23   ` Patrick Steinhardt
  2024-01-21 14:50   ` [PATCH v2 0/5] ci: add support for macOS " Phillip Wood
  5 siblings, 0 replies; 17+ messages in thread
From: Patrick Steinhardt @ 2024-01-18 10:23 UTC (permalink / raw)
  To: git; +Cc: Phillip Wood, Matthias Aßhauer

[-- Attachment #1: Type: text/plain, Size: 3142 bytes --]

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>
---
 .gitlab-ci.yml | 34 +++++++++++++++++++++++++++++++++-
 ci/lib.sh      |  9 ++++++++-
 2 files changed, 41 insertions(+), 2 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 793243421c..43bfbd8834 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -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:
diff --git a/ci/lib.sh b/ci/lib.sh
index f631206a44..d5dd2f2697 100755
--- a/ci/lib.sh
+++ b/ci/lib.sh
@@ -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;;
 	*)
-- 
2.43.GIT


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [PATCH v2 0/5] ci: add support for macOS to GitLab CI
  2024-01-18 10:22 ` [PATCH v2 0/5] ci: add support for macOS " Patrick Steinhardt
                     ` (4 preceding siblings ...)
  2024-01-18 10:23   ` [PATCH v2 5/5] ci: add macOS jobs to GitLab CI Patrick Steinhardt
@ 2024-01-21 14:50   ` Phillip Wood
  2024-01-22  6:14     ` Patrick Steinhardt
  2024-01-22 15:44     ` Junio C Hamano
  5 siblings, 2 replies; 17+ messages in thread
From: Phillip Wood @ 2024-01-21 14:50 UTC (permalink / raw)
  To: Patrick Steinhardt, git; +Cc: Matthias Aßhauer

Hi Patrick

On 18/01/2024 10:22, Patrick Steinhardt wrote:
> 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.
> 
> 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

> 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.
>      +
>           Signed-off-by: Patrick Steinhardt <ps@pks.im>
>       
>        ## 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.
>       
>           Signed-off-by: Patrick Steinhardt <ps@pks.im>
>       
>      @@ .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

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v2 0/5] ci: add support for macOS to GitLab CI
  2024-01-21 14:50   ` [PATCH v2 0/5] ci: add support for macOS " Phillip Wood
@ 2024-01-22  6:14     ` Patrick Steinhardt
  2024-01-22 15:44     ` Junio C Hamano
  1 sibling, 0 replies; 17+ messages in thread
From: Patrick Steinhardt @ 2024-01-22  6:14 UTC (permalink / raw)
  To: phillip.wood; +Cc: git, Matthias Aßhauer

[-- Attachment #1: Type: text/plain, Size: 1299 bytes --]

On Sun, Jan 21, 2024 at 02:50:05PM +0000, Phillip Wood wrote:
> Hi Patrick
> 
> On 18/01/2024 10:22, Patrick Steinhardt wrote:
> > 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.
> > 
> > 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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v2 0/5] ci: add support for macOS to GitLab CI
  2024-01-21 14:50   ` [PATCH v2 0/5] ci: add support for macOS " Phillip Wood
  2024-01-22  6:14     ` Patrick Steinhardt
@ 2024-01-22 15:44     ` Junio C Hamano
  1 sibling, 0 replies; 17+ messages in thread
From: Junio C Hamano @ 2024-01-22 15:44 UTC (permalink / raw)
  To: Phillip Wood; +Cc: Patrick Steinhardt, git, Matthias Aßhauer

Phillip Wood <phillip.wood123@gmail.com> writes:

> 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.


^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2024-01-22 15:44 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-15 11:44 [PATCH 0/3] ci: add support for macOS to GitLab CI Patrick Steinhardt
2024-01-15 11:44 ` [PATCH 1/3] ci: make p4 setup on macOS more robust Patrick Steinhardt
2024-01-18  7:19   ` Matthias Aßhauer
2024-01-18  9:44     ` Patrick Steinhardt
2024-01-15 11:45 ` [PATCH 2/3] Makefile: detect new Homebrew location for ARM-based Macs Patrick Steinhardt
2024-01-15 11:45 ` [PATCH 3/3] ci: add macOS jobs to GitLab CI Patrick Steinhardt
2024-01-16 14:58   ` Phillip Wood
2024-01-17  7:34     ` Patrick Steinhardt
2024-01-18 10:22 ` [PATCH v2 0/5] ci: add support for macOS " Patrick Steinhardt
2024-01-18 10:22   ` [PATCH v2 1/5] t7527: decrease likelihood of racing with fsmonitor daemon Patrick Steinhardt
2024-01-18 10:22   ` [PATCH v2 2/5] Makefile: detect new Homebrew location for ARM-based Macs Patrick Steinhardt
2024-01-18 10:22   ` [PATCH v2 3/5] ci: handle TEST_OUTPUT_DIRECTORY when printing test failures Patrick Steinhardt
2024-01-18 10:22   ` [PATCH v2 4/5] ci: make p4 setup on macOS more robust Patrick Steinhardt
2024-01-18 10:23   ` [PATCH v2 5/5] ci: add macOS jobs to GitLab CI Patrick Steinhardt
2024-01-21 14:50   ` [PATCH v2 0/5] ci: add support for macOS " Phillip Wood
2024-01-22  6:14     ` Patrick Steinhardt
2024-01-22 15:44     ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).