From a4ff6b0ccf17da3742a61e8d738ef58e5861df77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20=C5=A0tetiar?= Date: Wed, 29 Oct 2025 19:43:07 +0000 Subject: [PATCH] ci: testbed,cdrouter: improve error visibility with colored logging MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently it's not easy to identify errors in CI job log output, so let's introduce centralized logging helpers with colored output and visual indicators to make errors more prominent. The helpers are consolidated in .gitlab/scripts/helpers.sh and replace inline logging in dut-init scripts. Error messages in cdrouter.yml and testbed.yml now use log_error() for hopefully better visibility in CI logs. References: PCF-2157 Signed-off-by: Petr Štetiar --- .gitlab/cdrouter.yml | 4 ++-- .gitlab/scripts/dut-init/cdrouter-dut-configure-wireless.sh | 6 ++---- .gitlab/scripts/helpers.sh | 4 ++++ .gitlab/testbed.yml | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.gitlab/cdrouter.yml b/.gitlab/cdrouter.yml index dbe52c633c..6cf82eff76 100644 --- a/.gitlab/cdrouter.yml +++ b/.gitlab/cdrouter.yml @@ -146,12 +146,12 @@ - > if test -n "$cdrouter_exit_code"; then - echo "CDRouter exited with $cdrouter_exit_code exit code." + log_error "CDRouter exited with $cdrouter_exit_code exit code." exit "$cdrouter_exit_code" fi if test -n "$cram_exit_code"; then - echo "cram exited with $cram_exit_code exit code." + log_error "cram exited with $cram_exit_code exit code." exit "$cram_exit_code" fi diff --git a/.gitlab/scripts/dut-init/cdrouter-dut-configure-wireless.sh b/.gitlab/scripts/dut-init/cdrouter-dut-configure-wireless.sh index 0e2e1d6d84..cad75ad914 100755 --- a/.gitlab/scripts/dut-init/cdrouter-dut-configure-wireless.sh +++ b/.gitlab/scripts/dut-init/cdrouter-dut-configure-wireless.sh @@ -1,15 +1,13 @@ #!/bin/bash +source .gitlab/scripts/helpers.sh + set -eu # exit on error and undefined variables set -o pipefail # catch errors in pipes radio_2g_path="" ssid_2g_path="" -log_error() { echo -e "\e[91m❌ ERROR: $*\e[0m"; } -log_success() { echo -e "\e[92m✅ $*\e[0m"; } -log_info() { echo -e "\e[93m💡 $*\e[0m"; } - trap 'handle_error $? $LINENO $BASH_LINENO "$BASH_COMMAND" $(printf "::%s" ${FUNCNAME[@]:-})' ERR handle_error() { diff --git a/.gitlab/scripts/helpers.sh b/.gitlab/scripts/helpers.sh index f53833f2c8..32337a75ae 100644 --- a/.gitlab/scripts/helpers.sh +++ b/.gitlab/scripts/helpers.sh @@ -1,5 +1,9 @@ #!/bin/bash +log_error() { echo -e "\e[91m❌ ERROR: $*\e[0m"; } +log_success() { echo -e "\e[92m✅ $*\e[0m"; } +log_info() { echo -e "\e[93m💡 $*\e[0m"; } + # section_start - Start a collapsible section in GitLab CI job logs # # Creates a collapsible section marker in GitLab CI logs that can be expanded diff --git a/.gitlab/testbed.yml b/.gitlab/testbed.yml index f7a0d02368..b2396df612 100644 --- a/.gitlab/testbed.yml +++ b/.gitlab/testbed.yml @@ -107,7 +107,7 @@ local statuses=("${PIPESTATUS[@]}") for status in "${statuses[@]}"; do if [ "$status" -ne 0 ]; then - echo "run_check: $* | FAILED! (status: $status)" >> .run_check_failed + log_error "run_check: $* | FAILED! (status: $status)" | tee -a .run_check_failed fi done }