]> xenbits.xensource.com Git - xen-guest-agent.git/commitdiff
ci: use a dedicated script to isolate complexity of running commands
authorYann Dirson <yann.dirson@vates.fr>
Wed, 29 Nov 2023 16:04:28 +0000 (17:04 +0100)
committerYann Dirson <yann.dirson@vates.fr>
Wed, 29 Nov 2023 17:29:11 +0000 (18:29 +0100)
We're making the build logic more complicated, better have a real
script file to read it in good conditions.

Will also less the log look better, showing build args instead of printf
before the collapsed section.

Signed-off-by: Yann Dirson <yann.dirson@vates.fr>
.gitlab-ci.yml
devscripts/gitlab-ci-runbuild.sh [new file with mode: 0755]

index c021769fd50aeec8c9ebe18ab22f7499b66033b1..2a676ad30ceeca7976afbb16f06b96544858ef67 100644 (file)
@@ -96,10 +96,9 @@ build-linux-everycommit:
     - !reference [.debian-build-template,before_script]
     - printf "\e[0Ksection_end:$(date +%s):before_script[collapsed=true]\r\e[0K\n"
   script:
+    # let git-rebase run the build for each commit
     - git rebase --rebase-merges $CI_MERGE_REQUEST_DIFF_BASE_SHA
-      --exec 'printf "\e[0Ksection_start:$(date +%s):commit-$(git rev-parse --short HEAD)[collapsed=true]\r\e[0K\e[1;33m$(git log -1 --oneline)\e[1;0m\n"'
-      --exec "cargo build ${FEATURES} ${CARGO_FLAGS}"
-      --exec 'printf "\e[0Ksection_end:$(date +%s):commit-$(git rev-parse --short HEAD)\r\e[0K\n"'
+      --exec 'devscripts/gitlab-ci-runbuild.sh cargo build ${FEATURES} ${CARGO_FLAGS}'
 
 build-linux:
   parallel: !reference [.featurematrix,parallel]
diff --git a/devscripts/gitlab-ci-runbuild.sh b/devscripts/gitlab-ci-runbuild.sh
new file mode 100755 (executable)
index 0000000..72c6d5f
--- /dev/null
@@ -0,0 +1,21 @@
+#!/bin/sh
+set -e
+
+# all error output to stdout, so shell tracing markers are kept in
+# suitable ordering with collapsable section markers
+exec 2>&1
+
+FOOTER_ID="commit-$(git rev-parse --short HEAD)"
+COLLAPSED_TITLE="$(git log -1 --oneline)"
+
+# collapsable header
+printf "\e[0Ksection_start:$(date +%s):${FOOTER_ID}[collapsed=true]\r\e[0K\e[1;33m${COLLAPSED_TITLE}\e[1;0m\n"
+# trace, but not outside of collapsed section
+set -x
+
+"$@"
+
+# stop traces before closing collapsed section
+set +x
+# collapsable footer
+printf "\e[0Ksection_end:$(date +%s):${FOOTER_ID}\r\e[0K\n"