diff mbox series

[2/5] ci: make grouping setup more generic

Message ID ec390354f15604eb440bec0d3d0d817441e0f5b2.1698305961.git.ps@pks.im (mailing list archive)
State Superseded
Headers show
Series ci: add GitLab CI definition | expand

Commit Message

Patrick Steinhardt Oct. 26, 2023, 8 a.m. UTC
Make the grouping setup more generic by always calling `begin_group ()`
and `end_group ()` regardless of whether we have stubbed those functions
or not. This ensures we can more readily add support for additional CI
platforms.

Second, this commit changes `end_group ()` to also accept a parameter
that indicates _which_ group should end. This will be required by a
later commit that introduces support for GitLab CI.

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

Patch

diff --git a/ci/lib.sh b/ci/lib.sh
index eb384f4e952..957fd152d9c 100755
--- a/ci/lib.sh
+++ b/ci/lib.sh
@@ -14,12 +14,14 @@  then
 		need_to_end_group=
 		echo '::endgroup::' >&2
 	}
-	trap end_group EXIT
 
 	group () {
 		set +x
-		begin_group "$1"
+
+		group="$1"
 		shift
+		begin_group "$group"
+
 		# work around `dash` not supporting `set -o pipefail`
 		(
 			"$@" 2>&1
@@ -28,11 +30,10 @@  then
 		sed 's/^\(\([^ ]*\):\([0-9]*\):\([0-9]*:\) \)\(error\|warning\): /::\5 file=\2,line=\3::\1/'
 		res=$(cat exit.status)
 		rm exit.status
-		end_group
+
+		end_group "$group"
 		return $res
 	}
-
-	begin_group "CI setup"
 else
 	begin_group () { :; }
 	end_group () { :; }
@@ -44,6 +45,9 @@  else
 	set -x
 fi
 
+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.
 #
@@ -287,5 +291,5 @@  esac
 
 MAKEFLAGS="$MAKEFLAGS CC=${CC:-cc}"
 
-end_group
+end_group "CI setup"
 set -x