From e7ce40e7d89342b9fec9143f38395b6df128ec65 Mon Sep 17 00:00:00 2001 From: Anurag Mittal Date: Mon, 23 Dec 2024 01:03:24 +0100 Subject: [PATCH] print command in CI --- .github/scripts/cleanup_cosi_resources.sh | 1 + .github/scripts/e2e_tests_brownfield_use_case.sh | 2 +- .github/scripts/e2e_tests_greenfield_use_case.sh | 7 +++++-- .github/scripts/setup_cosi_resources.sh | 1 + 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/scripts/cleanup_cosi_resources.sh b/.github/scripts/cleanup_cosi_resources.sh index aab2400..49c3f58 100755 --- a/.github/scripts/cleanup_cosi_resources.sh +++ b/.github/scripts/cleanup_cosi_resources.sh @@ -13,6 +13,7 @@ error_handler() { trap 'error_handler' ERR log_and_run() { + echo "Running: $*" | tee -a "$LOG_FILE" "$@" 2>&1 | tee -a "$LOG_FILE" } diff --git a/.github/scripts/e2e_tests_brownfield_use_case.sh b/.github/scripts/e2e_tests_brownfield_use_case.sh index bc4eefc..168da76 100755 --- a/.github/scripts/e2e_tests_brownfield_use_case.sh +++ b/.github/scripts/e2e_tests_brownfield_use_case.sh @@ -22,8 +22,8 @@ error_handler() { # Trap errors and call the error handler trap 'error_handler' ERR -# Log command execution to the log file for debugging log_and_run() { + echo "Running: $*" | tee -a "$LOG_FILE" "$@" 2>&1 | tee -a "$LOG_FILE" } diff --git a/.github/scripts/e2e_tests_greenfield_use_case.sh b/.github/scripts/e2e_tests_greenfield_use_case.sh index 590ca88..8a55171 100755 --- a/.github/scripts/e2e_tests_greenfield_use_case.sh +++ b/.github/scripts/e2e_tests_greenfield_use_case.sh @@ -32,9 +32,12 @@ error_handler() { # Trap errors and call the error handler trap 'error_handler' ERR -# Log command execution to the log file for debugging log_and_run() { - "$@" 2>&1 | tee -a "$LOG_FILE" + echo "Running: $*" | tee -a "$LOG_FILE" + if ! "$@" 2>&1 | tee -a "$LOG_FILE"; then + echo "Error: Command failed - $*" | tee -a "$LOG_FILE" + exit 1 + fi } # Step 1: Create Account in Vault diff --git a/.github/scripts/setup_cosi_resources.sh b/.github/scripts/setup_cosi_resources.sh index db103c0..e42faba 100755 --- a/.github/scripts/setup_cosi_resources.sh +++ b/.github/scripts/setup_cosi_resources.sh @@ -17,6 +17,7 @@ trap 'error_handler' ERR # Log command execution to the log file for debugging log_and_run() { + echo "Running: $*" | tee -a "$LOG_FILE" if ! "$@" 2>&1 | tee -a "$LOG_FILE"; then echo "Error: Command failed - $*" | tee -a "$LOG_FILE" exit 1