release 1.13.10: global SUMMARY at end of multi-phase runs

Persist GLOBAL_PASS/FAIL/WARN/INFO/BLOCK in TALER_MON_STATE across
check_*.sh processes. Multi-phase never prints a phase SUMMARY box
(only ERRORS/BLOCKERS mid-run); parent progress_finish + summary_global
prints one whole-run totals stand after all phases.
This commit is contained in:
Hernâni Marques 2026-07-19 04:09:35 +02:00
parent 80638ddea0
commit 40850f1080
No known key found for this signature in database
4 changed files with 139 additions and 73 deletions

191
lib.sh
View file

@ -527,7 +527,13 @@ TEST_GROUP=""
TEST_N=0
LAST_TID=""
# Global / progress: may continue across check_*.sh processes via TALER_MON_STATE
# GLOBAL_*_N = whole-run status totals (multi-phase summary at parent end)
GLOBAL_N="${GLOBAL_N:-0}"
GLOBAL_PASS_N="${GLOBAL_PASS_N:-0}"
GLOBAL_FAIL_N="${GLOBAL_FAIL_N:-0}"
GLOBAL_WARN_N="${GLOBAL_WARN_N:-0}"
GLOBAL_INFO_N="${GLOBAL_INFO_N:-0}"
GLOBAL_BLOCK_N="${GLOBAL_BLOCK_N:-0}"
LAST_GLOBAL=""
PROGRESS_DONE="${PROGRESS_DONE:-0}"
PROGRESS_TOTAL="${PROGRESS_TOTAL:-0}"
@ -537,14 +543,28 @@ _mon_state_load() {
[ -n "${TALER_MON_STATE:-}" ] && [ -f "${TALER_MON_STATE}" ] || return 0
# shellcheck disable=SC1090
. "${TALER_MON_STATE}"
: "${GLOBAL_N:=0}"
: "${GLOBAL_PASS_N:=0}"
: "${GLOBAL_FAIL_N:=0}"
: "${GLOBAL_WARN_N:=0}"
: "${GLOBAL_INFO_N:=0}"
: "${GLOBAL_BLOCK_N:=0}"
: "${PROGRESS_DONE:=0}"
: "${PROGRESS_TOTAL:=0}"
: "${PROGRESS_LAST_SHOWN:=0}"
}
_mon_state_save() {
[ -n "${TALER_MON_STATE:-}" ] || return 0
{
printf 'GLOBAL_N=%s\n' "$GLOBAL_N"
printf 'PROGRESS_DONE=%s\n' "$PROGRESS_DONE"
printf 'PROGRESS_TOTAL=%s\n' "$PROGRESS_TOTAL"
printf 'PROGRESS_LAST_SHOWN=%s\n' "$PROGRESS_LAST_SHOWN"
printf 'GLOBAL_N=%s\n' "${GLOBAL_N:-0}"
printf 'GLOBAL_PASS_N=%s\n' "${GLOBAL_PASS_N:-0}"
printf 'GLOBAL_FAIL_N=%s\n' "${GLOBAL_FAIL_N:-0}"
printf 'GLOBAL_WARN_N=%s\n' "${GLOBAL_WARN_N:-0}"
printf 'GLOBAL_INFO_N=%s\n' "${GLOBAL_INFO_N:-0}"
printf 'GLOBAL_BLOCK_N=%s\n' "${GLOBAL_BLOCK_N:-0}"
printf 'PROGRESS_DONE=%s\n' "${PROGRESS_DONE:-0}"
printf 'PROGRESS_TOTAL=%s\n' "${PROGRESS_TOTAL:-0}"
printf 'PROGRESS_LAST_SHOWN=%s\n' "${PROGRESS_LAST_SHOWN:-0}"
} >"${TALER_MON_STATE}"
}
_mon_state_load
@ -783,6 +803,8 @@ ok() {
_take_tid
_msg_line "$BG_OK" "OK" "$G" "$label" "$detail"
PASS_N=$((PASS_N + 1))
GLOBAL_PASS_N=$((GLOBAL_PASS_N + 1))
_mon_state_save
}
# component-scoped error: err bank "what failed" "why / HTTP / path"
err() {
@ -790,7 +812,9 @@ err() {
_take_tid
_msg_line "$BG_ERR" "ERROR" "$R" "${comp}: ${msg}" "$detail"
FAIL_N=$((FAIL_N + 1))
GLOBAL_FAIL_N=$((GLOBAL_FAIL_N + 1))
ERRORS+=("${LAST_TID:+$LAST_TID }[$comp] $msg${detail:+ · $detail}")
_mon_state_save
}
# fail "what failed" ["why / HTTP code / path"]
fail() {
@ -798,7 +822,9 @@ fail() {
_take_tid
_msg_line "$BG_ERR" "ERROR" "$R" "$label" "$detail"
FAIL_N=$((FAIL_N + 1))
GLOBAL_FAIL_N=$((GLOBAL_FAIL_N + 1))
ERRORS+=("${LAST_TID:+$LAST_TID }$label${detail:+ · $detail}")
_mon_state_save
}
warn() {
# warn "what is soft-bad" ["why still ok to continue"]
@ -819,6 +845,8 @@ warn() {
fi
_msg_line "$BG_WARN" "WARN" "$Y" "$head" "$detail"
WARN_N=$((WARN_N + 1))
GLOBAL_WARN_N=$((GLOBAL_WARN_N + 1))
_mon_state_save
}
info() {
# info "topic" ["concrete fact / value / next step"]
@ -826,6 +854,8 @@ info() {
_take_tid
_msg_line "$BG_INFO" "INFO" "$C" "$label" "$detail"
INFO_N=$((INFO_N + 1))
GLOBAL_INFO_N=$((GLOBAL_INFO_N + 1))
_mon_state_save
}
blocker() {
# Hard stop on pay/withdraw path: blocker "step" "why it cannot continue"
@ -834,7 +864,10 @@ blocker() {
_msg_line "$BG_BLK" "BLOCKER" "$M" "${step}" "$msg"
BLOCKERS+=("${LAST_TID:+$LAST_TID }[$step] $msg")
FAIL_N=$((FAIL_N + 1))
GLOBAL_FAIL_N=$((GLOBAL_FAIL_N + 1))
GLOBAL_BLOCK_N=$((GLOBAL_BLOCK_N + 1))
ERRORS+=("BLOCKER ${LAST_TID:+$LAST_TID }[$step] $msg")
_mon_state_save
}
section() {
# Boxed section header (3 lines when colour on)
@ -860,13 +893,94 @@ section() {
fi
}
# Print SUMMARY totals box for given counts (phase-local or global).
# $1=pass $2=fail $3=warn $4=info $5=block
_summary_totals_box() {
local pass_n="$1" fail_n="$2" warn_n="$3" info_n="$4" blk_n="$5"
if [ "${BOX:-0}" = "1" ]; then
printf -- '\n%s┌ %s ┐%s\n' "$BG_SEC" "$(i18n_tag SUMMARY)" "$N"
_sum_badge() { # $1=bg $2=tag $3=fg $4=n
local _tg
_tg=$(i18n_tag "$2")
printf -- ' %s┌ %-5s┐%s %s%4d%s\n' "$1" "$_tg" "$N" "$3" "$4" "$N"
}
_sum_badge "$BG_OK" "OK" "$G" "$pass_n"
[ "$fail_n" -gt 0 ] && _sum_badge "$BG_ERR" "ERROR" "$R" "$fail_n"
[ "$warn_n" -gt 0 ] && _sum_badge "$BG_WARN" "WARN" "$Y" "$warn_n"
[ "$info_n" -gt 0 ] && _sum_badge "$BG_INFO" "INFO" "$C" "$info_n"
[ "$blk_n" -gt 0 ] && _sum_badge "$BG_BLK" "BLOCK" "$M" "$blk_n"
else
printf -- '\n[ %s ]\n' "$(i18n_tag SUMMARY)"
printf -- ' [ %-5s ] %s%4d%s\n' "$(i18n_tag OK)" "$G" "$pass_n" "$N"
[ "$fail_n" -gt 0 ] && printf -- ' [ %-5s ] %s%4d%s\n' "$(i18n_tag ERROR)" "$R" "$fail_n" "$N"
[ "$warn_n" -gt 0 ] && printf -- ' [ %-5s ] %s%4d%s\n' "$(i18n_tag WARN)" "$Y" "$warn_n" "$N"
[ "$info_n" -gt 0 ] && printf -- ' [ %-5s ] %s%4d%s\n' "$(i18n_tag INFO)" "$C" "$info_n" "$N"
[ "$blk_n" -gt 0 ] && printf -- ' [ %-5s ] %s%4d%s\n' "$(i18n_tag BLOCK)" "$M" "$blk_n" "$N"
fi
# one-line rollup (bold label, severity-coloured counts)
printf -- ' %stotals:%s %s%d OK%s' "$B" "$N" "$G" "$pass_n" "$N"
[ "$fail_n" -gt 0 ] && printf -- ' · %s%d ERROR%s' "$R" "$fail_n" "$N"
[ "$warn_n" -gt 0 ] && printf -- ' · %s%d WARN%s' "$Y" "$warn_n" "$N"
[ "$info_n" -gt 0 ] && printf -- ' · %s%d INFO%s' "$C" "$info_n" "$N"
[ "$blk_n" -gt 0 ] && printf -- ' · %s%d BLOCKER%s' "$M" "$blk_n" "$N"
printf '\n'
# overall verdict
if [ "$fail_n" -eq 0 ] && [ "$blk_n" -eq 0 ] && [ "$warn_n" -eq 0 ]; then
if [ "${BOX:-0}" = "1" ]; then
printf -- ' %s┌ OK ┐%s %sall clear%s\n' "$BG_OK" "$N" "$G" "$N"
else
printf -- ' %s[ OK ] all clear%s\n' "$G" "$N"
fi
elif [ "$fail_n" -eq 0 ] && [ "$blk_n" -eq 0 ]; then
if [ "${BOX:-0}" = "1" ]; then
printf -- ' %s┌ WARN ┐%s %swarnings only (no hard fail)%s\n' "$BG_WARN" "$N" "$Y" "$N"
else
printf -- ' %s[ WARN ] warnings only (no hard fail)%s\n' "$Y" "$N"
fi
else
local _fail_msg
_fail_msg=$(i18n_text 'failed — see list above')
if [ "${BOX:-0}" = "1" ]; then
printf -- ' %s┌ ERROR ┐%s %s%s%s\n' "$BG_ERR" "$N" "$R" "$_fail_msg" "$N"
else
printf -- ' %s[ ERROR ] %s%s\n' "$R" "$_fail_msg" "$N"
fi
fi
}
# Whole-run SUMMARY from TALER_MON_STATE (parent after all phases).
# Multi-phase: phases never print SUMMARY totals; only this does.
summary_global() {
_mon_state_load
local pass_n="${GLOBAL_PASS_N:-0}"
local fail_n="${GLOBAL_FAIL_N:-0}"
local warn_n="${GLOBAL_WARN_N:-0}"
local info_n="${GLOBAL_INFO_N:-0}"
local blk_n="${GLOBAL_BLOCK_N:-0}"
# Progress bar + numbered checks already printed by progress_finish when present.
if [ "${GLOBAL_N:-0}" -gt 0 ]; then
if [ "${PROGRESS_TOTAL:-0}" -gt 0 ]; then
printf -- '%s %s #001…#%03d · %d/%d %s%s\n' \
"$D" "$(i18n_text 'numbered checks:')" "$GLOBAL_N" \
"${PROGRESS_DONE:-0}" "$PROGRESS_TOTAL" \
"$(i18n_text '(global done/total)')" "$N"
else
printf -- '%s %s #001…#%03d%s\n' \
"$D" "$(i18n_text 'numbered checks this run:')" "$GLOBAL_N" "$N"
fi
fi
_summary_totals_box "$pass_n" "$fail_n" "$warn_n" "$info_n" "$blk_n"
[ "$fail_n" -eq 0 ]
}
summary() {
local blk_n=${#BLOCKERS[@]}
# Multi-phase runs: no intermediate progress bar / numbered checks / SUMMARY box
# (v1.13.9+). Solo check_*.sh still full summary. Parent sets TALER_MON_MULTI_PHASE=1
# and only the last phase gets PROGRESS_FINAL=1. Mid-run still lists ERRORS/BLOCKERS.
# Multi-phase runs: never print phase SUMMARY / progress standings (v1.13.10+).
# Parent prints one global SUMMARY via summary_global after progress_finish.
# Solo check_*.sh (TALER_MON_MULTI_PHASE unset/0) still full summary.
# Phase still lists ERRORS/BLOCKERS so mid-run failures stay visible.
local _full=1
if [ "${TALER_MON_MULTI_PHASE:-0}" = "1" ] && [ "${PROGRESS_FINAL:-0}" != "1" ]; then
if [ "${TALER_MON_MULTI_PHASE:-0}" = "1" ]; then
_full=0
fi
@ -874,12 +988,6 @@ summary() {
if [ "$_full" = "1" ]; then
# Progress snapshot — whole-run snap also in progress_finish.
if [ "${PROGRESS_OFF:-0}" != "1" ] && [ "${PROGRESS_DONE:-0}" -gt 0 ]; then
if [ "${PROGRESS_FINAL:-0}" = "1" ]; then
if [ "${PROGRESS_TOTAL:-0}" -gt 0 ] && [ "$PROGRESS_DONE" -ne "$PROGRESS_TOTAL" ]; then
PROGRESS_TOTAL=$PROGRESS_DONE
_mon_state_save
fi
fi
_progress_rebalance
_progress_bar_line "$PROGRESS_DONE" "$PROGRESS_TOTAL"
fi
@ -918,58 +1026,13 @@ summary() {
done
fi
# Coloured totals — only at full/final summary (not mid multi-phase)
# Coloured totals — only at full phase summary (solo script / single-phase)
if [ "$_full" != "1" ]; then
return 0
fi
if [ "${BOX:-0}" = "1" ]; then
printf -- '\n%s┌ %s ┐%s\n' "$BG_SEC" "$(i18n_tag SUMMARY)" "$N"
_sum_badge() { # $1=bg $2=tag $3=fg $4=n
local _tg
_tg=$(i18n_tag "$2")
printf -- ' %s┌ %-5s┐%s %s%4d%s\n' "$1" "$_tg" "$N" "$3" "$4" "$N"
}
_sum_badge "$BG_OK" "OK" "$G" "$PASS_N"
[ "$FAIL_N" -gt 0 ] && _sum_badge "$BG_ERR" "ERROR" "$R" "$FAIL_N"
[ "$WARN_N" -gt 0 ] && _sum_badge "$BG_WARN" "WARN" "$Y" "$WARN_N"
[ "$INFO_N" -gt 0 ] && _sum_badge "$BG_INFO" "INFO" "$C" "$INFO_N"
[ "$blk_n" -gt 0 ] && _sum_badge "$BG_BLK" "BLOCK" "$M" "$blk_n"
else
printf -- '\n[ %s ]\n' "$(i18n_tag SUMMARY)"
printf -- ' [ %-5s ] %s%4d%s\n' "$(i18n_tag OK)" "$G" "$PASS_N" "$N"
[ "$FAIL_N" -gt 0 ] && printf -- ' [ %-5s ] %s%4d%s\n' "$(i18n_tag ERROR)" "$R" "$FAIL_N" "$N"
[ "$WARN_N" -gt 0 ] && printf -- ' [ %-5s ] %s%4d%s\n' "$(i18n_tag WARN)" "$Y" "$WARN_N" "$N"
[ "$INFO_N" -gt 0 ] && printf -- ' [ %-5s ] %s%4d%s\n' "$(i18n_tag INFO)" "$C" "$INFO_N" "$N"
[ "$blk_n" -gt 0 ] && printf -- ' [ %-5s ] %s%4d%s\n' "$(i18n_tag BLOCK)" "$M" "$blk_n" "$N"
fi
# one-line rollup (bold label, severity-coloured counts)
printf -- ' %stotals:%s %s%d OK%s' "$B" "$N" "$G" "$PASS_N" "$N"
[ "$FAIL_N" -gt 0 ] && printf -- ' · %s%d ERROR%s' "$R" "$FAIL_N" "$N"
[ "$WARN_N" -gt 0 ] && printf -- ' · %s%d WARN%s' "$Y" "$WARN_N" "$N"
[ "$INFO_N" -gt 0 ] && printf -- ' · %s%d INFO%s' "$C" "$INFO_N" "$N"
[ "$blk_n" -gt 0 ] && printf -- ' · %s%d BLOCKER%s' "$M" "$blk_n" "$N"
printf '\n'
# overall verdict
if [ "$FAIL_N" -eq 0 ] && [ "$blk_n" -eq 0 ] && [ "$WARN_N" -eq 0 ]; then
if [ "${BOX:-0}" = "1" ]; then
printf -- ' %s┌ OK ┐%s %sall clear%s\n' "$BG_OK" "$N" "$G" "$N"
else
printf -- ' %s[ OK ] all clear%s\n' "$G" "$N"
fi
elif [ "$FAIL_N" -eq 0 ] && [ "$blk_n" -eq 0 ]; then
if [ "${BOX:-0}" = "1" ]; then
printf -- ' %s┌ WARN ┐%s %swarnings only (no hard fail)%s\n' "$BG_WARN" "$N" "$Y" "$N"
else
printf -- ' %s[ WARN ] warnings only (no hard fail)%s\n' "$Y" "$N"
fi
else
_fail_msg=$(i18n_text 'failed — see list above')
if [ "${BOX:-0}" = "1" ]; then
printf -- ' %s┌ ERROR ┐%s %s%s%s\n' "$BG_ERR" "$N" "$R" "$_fail_msg" "$N"
else
printf -- ' %s[ ERROR ] %s%s\n' "$R" "$_fail_msg" "$N"
fi
# Still fail the phase exit when this phase had errors (set -e + trailing summary)
[ "$FAIL_N" -eq 0 ]
return
fi
_summary_totals_box "$PASS_N" "$FAIL_N" "$WARN_N" "$INFO_N" "$blk_n"
[ "$FAIL_N" -eq 0 ]
}