# [PATCH v3 1/4] gitlab-ci: update macOS images to Sonoma

6 messages from 2024-12-12 to 2024-12-12. Participants: Patrick Steinhardt, Toon Claes.
Thread: https://gitlist.dev/t/62628

## Patrick Steinhardt, 2024-12-12 06:47

Subject: [PATCH v3 1/4] gitlab-ci: update macOS images to Sonoma
Message-ID: <20241212-pks-ci-section-fixes-v3-1-d9fe6baee21e@pks.im>
URL: https://gitlist.dev/e/20241212-pks-ci-section-fixes-v3-1-d9fe6baee21e%40pks.im
In-Reply-To: <20241212-pks-ci-section-fixes-v3-0-d9fe6baee21e@pks.im>

```
The macOS Ventura images we use for GitLab CI runners have been
deprecated. Update them to macOS 14, aka Sonoma.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 .gitlab-ci.yml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 526ecfe030a43e0a5a83ddd35cb7c96d46ab2485..61c56ccac8fdc940075d91dd4cb0b54ee33d5199 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -99,10 +99,10 @@ test:osx:
   parallel:
     matrix:
       - jobname: osx-clang
-        image: macos-13-xcode-14
+        image: macos-14-xcode-15
         CC: clang
       - jobname: osx-reftable
-        image: macos-13-xcode-14
+        image: macos-14-xcode-15
         CC: clang
   artifacts:
     paths:

-- 
2.47.1.447.ga7e8429e30.dirty


```

## Patrick Steinhardt, 2024-12-12 06:47

Subject: [PATCH v3 0/4] Random improvements to GitLab CI
Message-ID: <20241212-pks-ci-section-fixes-v3-0-d9fe6baee21e@pks.im>
URL: https://gitlist.dev/e/20241212-pks-ci-section-fixes-v3-0-d9fe6baee21e%40pks.im
In-Reply-To: <20241206-pks-ci-section-fixes-v1-0-7ab1b69e3648@pks.im>

```
Hi,

this small patch series includes a couple of more-or-less random
improvements to GitLab CI.

Changes in v2:
- Use "%s" to inject variable data into section headers instead of
  converting to echo.
- Link to v1: https://lore.kernel.org/r/20241206-pks-ci-section-fixes-v1-0-7ab1b69e3648@pks.im

Changes in v3:
- Wrap overly long lines.
- Fix a word swap in a commit message.
- Link to v2: https://lore.kernel.org/r/20241210-pks-ci-section-fixes-v2-0-e087cfd174f4@pks.im

Thanks!

Patrick

---
Patrick Steinhardt (4):
      gitlab-ci: update macOS images to Sonoma
      ci/lib: remove duplicate trap to end "CI setup" group
      ci/lib: do not interpret escape sequences in `group ()` arguments
      ci/lib: fix "CI setup" sections with GitLab CI

 .gitlab-ci.yml |  4 ++--
 ci/lib.sh      | 11 ++++++-----
 2 files changed, 8 insertions(+), 7 deletions(-)

Range-diff versus v2:

1:  e504aa4a1f = 1:  633af36640 gitlab-ci: update macOS images to Sonoma
2:  021ac694ef = 2:  6b6c6b2937 ci/lib: remove duplicate trap to end "CI setup" group
3:  6e355e22d7 ! 3:  bd54f8e1b6 ci/lib: do not interpret escape sequences in `group ()` arguments
    @@ Commit message
         We use printf to set up sections with GitLab CI, which requires us to
         print a bunch of escape sequences via printf. The group name is
         controlled by the user and is expanded directly into the formatting
    -    string, which may cause problems in case the argument controls escape
    +    string, which may cause problems in case the argument contains escape
         sequences or formatting directives.
     
         Fix this potential issue by using formatting directives to pass variable
    @@ ci/lib.sh: elif test true = "$GITLAB_CI"
      	begin_group () {
      		need_to_end_group=t
     -		printf "\e[0Ksection_start:$(date +%s):$(echo "$1" | tr ' ' _)[collapsed=true]\r\e[0K$1\n"
    -+		printf '\e[0Ksection_start:%s:%s[collapsed=true]\r\e[0K%s\n' "$(date +%s)" "$(echo "$1" | tr ' ' _)" "$1"
    ++		printf '\e[0Ksection_start:%s:%s[collapsed=true]\r\e[0K%s\n' \
    ++			"$(date +%s)" "$(echo "$1" | tr ' ' _)" "$1"
      		trap "end_group '$1'" EXIT
      		set -x
      	}
    @@ ci/lib.sh: then
      		set +x
      		need_to_end_group=
     -		printf "\e[0Ksection_end:$(date +%s):$(echo "$1" | tr ' ' _)\r\e[0K\n"
    -+		printf '\e[0Ksection_end:%s:%s\r\e[0K\n' "$(date +%s)" "$(echo "$1" | tr ' ' _)"
    ++		printf '\e[0Ksection_end:%s:%s\r\e[0K\n' \
    ++			"$(date +%s)" "$(echo "$1" | tr ' ' _)"
      		trap - EXIT
      	}
      else
4:  bae2071e47 = 4:  41ad98d633 ci/lib: fix "CI setup" sections with GitLab CI

---
base-commit: e66fd72e972df760a53c3d6da023c17adfc426d6
change-id: 20241206-pks-ci-section-fixes-1bb91ceb50b8


```

## Patrick Steinhardt, 2024-12-12 06:47

Subject: [PATCH v3 2/4] ci/lib: remove duplicate trap to end "CI setup" group
Message-ID: <20241212-pks-ci-section-fixes-v3-2-d9fe6baee21e@pks.im>
URL: https://gitlist.dev/e/20241212-pks-ci-section-fixes-v3-2-d9fe6baee21e%40pks.im
In-Reply-To: <20241212-pks-ci-section-fixes-v3-0-d9fe6baee21e@pks.im>

```
We exlicitly trap on EXIT in order to end the "CI setup" group. This
isn't necessary though given that `begin_group ()` already sets up the
trap for us.

Remove the duplicate trap.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 ci/lib.sh | 1 -
 1 file changed, 1 deletion(-)

diff --git a/ci/lib.sh b/ci/lib.sh
index 930f98d7228166c37c236beb062b14675fb68ef3..a54601be923bf475ba1a9cafd98bb1cb71a10255 100755
--- a/ci/lib.sh
+++ b/ci/lib.sh
@@ -56,7 +56,6 @@ group () {
 }
 
 begin_group "CI setup"
-trap "end_group 'CI setup'" EXIT
 
 # Set 'exit on error' for all CI scripts to let the caller know that
 # something went wrong.

-- 
2.47.1.447.ga7e8429e30.dirty


```

## Patrick Steinhardt, 2024-12-12 06:47

Subject: [PATCH v3 4/4] ci/lib: fix "CI setup" sections with GitLab CI
Message-ID: <20241212-pks-ci-section-fixes-v3-4-d9fe6baee21e@pks.im>
URL: https://gitlist.dev/e/20241212-pks-ci-section-fixes-v3-4-d9fe6baee21e%40pks.im
In-Reply-To: <20241212-pks-ci-section-fixes-v3-0-d9fe6baee21e@pks.im>

```
Whenever we source "ci/lib.sh" we wrap the directives in a separate
group so that they can easily be collapsed in the web UI. And as we
source the script multiple times during a single CI run we thus end up
with the same section name reused multiple times, as well.

This is broken on GitLab CI though, where reusing the same group name is
not supported. The consequence is that only the last of these sections
can be collapsed.

Fix this issue by including the name of the sourcing script in the
group's name.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 ci/lib.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ci/lib.sh b/ci/lib.sh
index d403ada911722af554df6255e5cd3fa01b56fd22..5440eb6dc02784c03a5e4919f97dd7f07881f5c7 100755
--- a/ci/lib.sh
+++ b/ci/lib.sh
@@ -57,7 +57,7 @@ group () {
 	return $res
 }
 
-begin_group "CI setup"
+begin_group "CI setup via $(basename $0)"
 
 # Set 'exit on error' for all CI scripts to let the caller know that
 # something went wrong.
@@ -395,5 +395,5 @@ esac
 
 MAKEFLAGS="$MAKEFLAGS CC=${CC:-cc}"
 
-end_group "CI setup"
+end_group "CI setup via $(basename $0)"
 set -x

-- 
2.47.1.447.ga7e8429e30.dirty


```

## Patrick Steinhardt, 2024-12-12 06:47

Subject: [PATCH v3 3/4] ci/lib: do not interpret escape sequences in `group ()` arguments
Message-ID: <20241212-pks-ci-section-fixes-v3-3-d9fe6baee21e@pks.im>
URL: https://gitlist.dev/e/20241212-pks-ci-section-fixes-v3-3-d9fe6baee21e%40pks.im
In-Reply-To: <20241212-pks-ci-section-fixes-v3-0-d9fe6baee21e@pks.im>

```
We use printf to set up sections with GitLab CI, which requires us to
print a bunch of escape sequences via printf. The group name is
controlled by the user and is expanded directly into the formatting
string, which may cause problems in case the argument contains escape
sequences or formatting directives.

Fix this potential issue by using formatting directives to pass variable
data.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 ci/lib.sh | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/ci/lib.sh b/ci/lib.sh
index a54601be923bf475ba1a9cafd98bb1cb71a10255..d403ada911722af554df6255e5cd3fa01b56fd22 100755
--- a/ci/lib.sh
+++ b/ci/lib.sh
@@ -18,7 +18,8 @@ elif test true = "$GITLAB_CI"
 then
 	begin_group () {
 		need_to_end_group=t
-		printf "\e[0Ksection_start:$(date +%s):$(echo "$1" | tr ' ' _)[collapsed=true]\r\e[0K$1\n"
+		printf '\e[0Ksection_start:%s:%s[collapsed=true]\r\e[0K%s\n' \
+			"$(date +%s)" "$(echo "$1" | tr ' ' _)" "$1"
 		trap "end_group '$1'" EXIT
 		set -x
 	}
@@ -27,7 +28,8 @@ then
 		test -n "$need_to_end_group" || return 0
 		set +x
 		need_to_end_group=
-		printf "\e[0Ksection_end:$(date +%s):$(echo "$1" | tr ' ' _)\r\e[0K\n"
+		printf '\e[0Ksection_end:%s:%s\r\e[0K\n' \
+			"$(date +%s)" "$(echo "$1" | tr ' ' _)"
 		trap - EXIT
 	}
 else

-- 
2.47.1.447.ga7e8429e30.dirty


```

## Toon Claes, 2024-12-12 11:57

Subject: Re: [PATCH v3 0/4] Random improvements to GitLab CI
Message-ID: <87v7vpi05s.fsf@iotcl.com>
URL: https://gitlist.dev/e/87v7vpi05s.fsf%40iotcl.com
In-Reply-To: <20241212-pks-ci-section-fixes-v3-0-d9fe6baee21e@pks.im>

```
Patrick Steinhardt <ps@pks.im> writes:

> Hi,
>
> this small patch series includes a couple of more-or-less random
> improvements to GitLab CI.
>
> Changes in v2:
> - Use "%s" to inject variable data into section headers instead of
>   converting to echo.
> - Link to v1: https://lore.kernel.org/r/20241206-pks-ci-section-fixes-v1-0-7ab1b69e3648@pks.im
>
> Changes in v3:
> - Wrap overly long lines.
> - Fix a word swap in a commit message.
> - Link to v2: https://lore.kernel.org/r/20241210-pks-ci-section-fixes-v2-0-e087cfd174f4@pks.im

Thanks, all looks good to me.

--
Toon

```
