Skip to content

Commit 6350ffb

Browse files
committed
[gantry] notify more error detials. Update lib-common.
1 parent b3438f9 commit 6350ffb

22 files changed

Lines changed: 748 additions & 621 deletions

.github/workflows/on-pull-request.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ jobs:
9090
sudo apt install -y inotify-tools
9191
- name: Checkout Code
9292
uses: actions/checkout@v7
93-
- name: Run container tests
93+
- name: Run script tests in parallel
9494
run: |
9595
NUM_JOBS=$(ls -1 tests | wc -l)
9696
shellspec -s bash --jobs "${NUM_JOBS}"

.github/workflows/on-push.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ jobs:
9494
sudo apt install -y inotify-tools
9595
- name: Checkout Code
9696
uses: actions/checkout@v7
97-
- name: Run container tests
97+
- name: Run script tests in parallel
9898
run: |
9999
NUM_JOBS=$(ls -1 tests | wc -l)
100100
shellspec -s bash --jobs "${NUM_JOBS}"

.github/workflows/on-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
sudo apt install -y inotify-tools
4444
- name: Checkout Code
4545
uses: actions/checkout@v7
46-
- name: Run tests
46+
- name: Run script tests in parallel
4747
run: |
4848
NUM_JOBS=$(ls -1 tests | wc -l)
4949
shellspec -s bash --jobs "${NUM_JOBS}"

src/lib-common.sh

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -184,13 +184,14 @@ _log_skip_echo_color() {
184184
# Reads from stdin and outputs the sanitized string to stdout
185185
# Sanitize the input string to make it safe to be included in JSON string values.
186186
sanitize_json_string() {
187-
sed -E 's/\\/\\\\/g'\
188-
| sed -E 's/"/\\"/g'\
189-
| sed -E 's/\f/\\f/g'\
190-
| sed -E 's/\t/\\t/g'\
191-
| sed -E 's/\r/\\r/g'\
192-
| sed -E 's/\n/\\n/g'\
193-
| sed -E 's/$/\\n/'\
187+
sed -E \
188+
-e 's/\\/\\\\/g'\
189+
-e 's/"/\\"/g'\
190+
-e 's/\f/\\f/g'\
191+
-e 's/\t/\\t/g'\
192+
-e 's/\r/\\r/g'\
193+
-e 's/\n/\\n/g'\
194+
-e 's/$/\\n/'\
194195
| tr -d '\n'
195196
}
196197

@@ -641,15 +642,19 @@ _all_tasks_reach_state() {
641642
# continue
642643
return 1
643644
fi
644-
# Get return value of the task from the string "task: non-zero exit (1)".
645-
local TASK_RETURN_VALUE=
646-
TASK_RETURN_VALUE=$(echo "${STATES}" | grep "Failed" | sed -n -E 's/.*task: non-zero exit \(([0-9]+)\).*/\1/p')
647-
# Get the first error code.
648-
local RETURN_VALUE=
649-
RETURN_VALUE=$(_get_first_word "${TASK_RETURN_VALUE:-1}")
650-
# break
651-
echo "${RETURN_VALUE}"
652-
return 0
645+
if [ $((NUM_STATES+NUM_FAILS)) = "${NUM_LINES}" ]; then
646+
# Get return value of the task from the string "task: non-zero exit (1)".
647+
local TASK_RETURN_VALUES=
648+
TASK_RETURN_VALUES=$(echo "${STATES}" | grep "Failed" | sed -n -E 's/.*task: non-zero exit \(([0-9]+)\).*/\1/p')
649+
# Get the first error code.
650+
local RETURN_VALUE=
651+
RETURN_VALUE=$(_get_first_word "${TASK_RETURN_VALUES:-1}")
652+
# break
653+
echo "${RETURN_VALUE}"
654+
return 0
655+
fi
656+
# continue
657+
return 1
653658
}
654659

655660
# Usage: wait_service_state <SERVICE_NAME> [WANT_STATE] [timeout in seconds]
@@ -719,11 +724,14 @@ docker_service_remove() {
719724
# Works with the service started (e.g. via docker_global_job) with --detach.
720725
docker_service_follow_logs_wait_complete() {
721726
local SERVICE_NAME="${1}"
727+
local RETURN_VALUE=0
722728
local PID=
723729
docker_service_logs_follow "${SERVICE_NAME}" &
724730
PID="${!}"
725731
wait_service_state "${SERVICE_NAME}" "Complete"
732+
RETURN_VALUE=$?
726733
docker_service_remove "${SERVICE_NAME}" "wait ${PID}"
734+
return "${RETURN_VALUE}"
727735
}
728736

729737
# We do not expect failures when using docker_global_job.

0 commit comments

Comments
 (0)