[libvirt PATCH v2 04/35] ci: build.sh: Add a wrapper function executing 'shell' commands

Erik Skultety posted 35 patches 1 year, 3 months ago
[libvirt PATCH v2 04/35] ci: build.sh: Add a wrapper function executing 'shell' commands
Posted by Erik Skultety 1 year, 3 months ago
This would normally be not needed at all, but the problem here is the
Shell-in-YAML which GitLab interprets. It outputs every command that
appears as a line in the 'script' segment in a color-coded fashion for
easy identification of problems. Well, that useful feature is lost when
there's indirection and one script calls into another in which case it
would only output the respective script name which would make failure
investigation harder. This simple helper tackles that by echoing the
command to be run by any script/function with a color escape sequence
so that we don't lose track of the *actual* shell commands being run as
part of the GitLab job pipelines. An example of what the output then
might look like:
    [RUN COMMAND]: 'meson compile -C build install-web'

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Erik Skultety <eskultet@redhat.com>:
---
 ci/build.sh | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/ci/build.sh b/ci/build.sh
index 7cf07ba5a8..5883542b45 100644
--- a/ci/build.sh
+++ b/ci/build.sh
@@ -27,3 +27,8 @@ meson setup build --werror -Dsystem=true $MESON_OPTS $MESON_ARGS || \
 (cat build/meson-logs/meson-log.txt && exit 1)
 
 ninja -C build $NINJA_ARGS
+
+run_cmd() {
+    printf "\e[32m[RUN COMMAND]: '%s'\e[0m\n" "$*"
+    $@
+}
-- 
2.41.0
Re: [libvirt PATCH v2 04/35] ci: build.sh: Add a wrapper function executing 'shell' commands
Posted by Daniel P. Berrangé 1 year, 3 months ago
On Mon, Sep 11, 2023 at 03:43:05PM +0200, Erik Skultety wrote:
> This would normally be not needed at all, but the problem here is the
> Shell-in-YAML which GitLab interprets. It outputs every command that
> appears as a line in the 'script' segment in a color-coded fashion for
> easy identification of problems. Well, that useful feature is lost when
> there's indirection and one script calls into another in which case it
> would only output the respective script name which would make failure
> investigation harder. This simple helper tackles that by echoing the
> command to be run by any script/function with a color escape sequence
> so that we don't lose track of the *actual* shell commands being run as
> part of the GitLab job pipelines. An example of what the output then
> might look like:
>     [RUN COMMAND]: 'meson compile -C build install-web'
> 
> Signed-off-by: Erik Skultety <eskultet@redhat.com>
> Erik Skultety <eskultet@redhat.com>:
> ---
>  ci/build.sh | 5 +++++
>  1 file changed, 5 insertions(+)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|