feat(gate): check.sh --brief prints a red lane's first error lines only

This commit is contained in:
2026-10-04 20:09:58 +02:00
parent bc856ab2af
commit 27f48b7a8b
2 changed files with 64 additions and 9 deletions
+30 -5
View File
@@ -1436,7 +1436,8 @@
"e2e/helpers.ts",
"e2e/nav.spec.ts",
"e2e/player.spec.ts",
"e2e/settings.spec.ts"
"e2e/settings.spec.ts",
"e2e/speed.measure.ts"
],
"js configs": ["eslint.config.js", "postcss.config.js"],
"lib tests": [
@@ -2309,16 +2310,40 @@
"scripts/check.sh": [
"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 ;;",
" esac",
"done",
"export MSYS_NO_PATHCONV=1 # Git Bash: do not rewrite the in-container paths below",
"TESTCOMPOSE=backend/docker-compose.test.yml",
"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\"",
"}",
"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",
"}",
"ruff_pinned() {",
" local pin host",
+34 -4
View File
@@ -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 ------------------------------------------------------------------------------------