feat(gate): check.sh --brief prints a red lane's first error lines only
This commit is contained in:
+34
-4
@@ -7,6 +7,8 @@
|
||||
#
|
||||
# bash scripts/check.sh every lane (what a release requires, before e2e and the CVE scan)
|
||||
# bash scripts/check.sh lint the static lanes only: no tests, no build, no audits
|
||||
# … --brief (either mode) a lane's output only when it fails, and only its first
|
||||
# error lines — for an agent, whose context the full log would flood
|
||||
#
|
||||
# Each lane runs even when an earlier one failed, and the summary names every red one: a gate that
|
||||
# stops at the first failure hides the second until the first is fixed. The backend lanes run in the
|
||||
@@ -14,8 +16,15 @@
|
||||
# type checker or auditor without the real packages reports nonsense.
|
||||
set -u
|
||||
cd "$(dirname "$0")/.." || exit 2
|
||||
mode="${1:-all}"
|
||||
case "$mode" in all | lint) ;; *) echo "usage: scripts/check.sh [lint]" >&2; exit 2 ;; esac
|
||||
mode=all
|
||||
brief=0
|
||||
for arg in "$@"; do
|
||||
case "$arg" in
|
||||
all | lint) mode="$arg" ;;
|
||||
--brief) brief=1 ;;
|
||||
*) echo "usage: scripts/check.sh [lint] [--brief]" >&2; exit 2 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
export MSYS_NO_PATHCONV=1 # Git Bash: do not rewrite the in-container paths below
|
||||
TESTCOMPOSE=backend/docker-compose.test.yml
|
||||
@@ -23,8 +32,29 @@ failed=()
|
||||
lane() { # lane <name> <command…> — run it, remember a failure, never stop
|
||||
local name="$1"
|
||||
shift
|
||||
echo ">> $name…"
|
||||
"$@" || failed+=("$name")
|
||||
if [ "$brief" = 0 ]; then
|
||||
echo ">> $name…"
|
||||
"$@" || failed+=("$name")
|
||||
return 0
|
||||
fi
|
||||
local out
|
||||
out="$(mktemp)"
|
||||
if "$@" >"$out" 2>&1; then
|
||||
echo ">> $name: ok"
|
||||
else
|
||||
failed+=("$name")
|
||||
echo ">> $name: FAILED"
|
||||
brief_excerpt "$out"
|
||||
fi
|
||||
rm -f "$out"
|
||||
}
|
||||
# The lines that say what broke: the first 20 error-looking ones, each with the two lines after it
|
||||
# (knip names the file on the line after "Unused files"); a log with none of them (a tool that
|
||||
# words its failures some other way) shows its tail instead, which is where a summary sits.
|
||||
brief_excerpt() {
|
||||
local hits
|
||||
hits="$(grep -E -i -A 2 -m 20 'error|fail|✗|×|warn|would reformat|unused|vulnerab|found [0-9]' "$1")"
|
||||
if [ -n "$hits" ]; then printf '%s\n' "$hits"; else tail -n 20 "$1"; fi
|
||||
}
|
||||
|
||||
# --- static lanes ------------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user