chore(gate): every lane reports how long it took, and a run can log the times for comparison
This commit is contained in:
@@ -1307,21 +1307,39 @@
|
||||
"export MSYS_NO_PATHCONV=1 # Git Bash: do not rewrite the in-container paths below",
|
||||
"TESTCOMPOSE=backend/docker-compose.test.yml",
|
||||
"failed=()",
|
||||
"timings=()",
|
||||
"ms() { date +%s%3N; }",
|
||||
"secs() { awk -v t=\"$1\" 'BEGIN { printf \"%.1f\", t / 1000 }'; }",
|
||||
"took=\"\"",
|
||||
"timed() { # timed <name> <ok|red> <start-ms> — sets $took (no subshell: it must add to $timings)",
|
||||
" took=\"$(secs $(($(ms) - $3)))\"",
|
||||
" timings+=(\"$(printf '%8s s %s' \"$took\" \"$1\")$([ \"$2\" = red ] && echo ' (red)')\")",
|
||||
" if [ -n \"${GATE_TIMES_FILE:-}\" ]; then",
|
||||
" printf '%s\\t%s\\t%s\\t%s\\t%s\\t%s\\n' \"$(date -u +%FT%TZ)\" \"$mode\" \"$1\" \"$took\" \"$2\" \\",
|
||||
" \"$(git rev-parse --short 'HEAD^{tree}' 2>/dev/null)\" >>\"$GATE_TIMES_FILE\"",
|
||||
" fi",
|
||||
" return 0",
|
||||
"}",
|
||||
"lane() { # lane <name> <command…> — run it, remember a failure, never stop",
|
||||
" local name=\"$1\"",
|
||||
" local name=\"$1\" t0 result=ok",
|
||||
" shift",
|
||||
" t0=\"$(ms)\"",
|
||||
" if [ \"$brief\" = 0 ]; then",
|
||||
" echo \">> $name…\"",
|
||||
" \"$@\" || failed+=(\"$name\")",
|
||||
" \"$@\" || { failed+=(\"$name\"); result=red; }",
|
||||
" timed \"$name\" \"$result\" \"$t0\"",
|
||||
" echo \"<< $name: $took s\"",
|
||||
" return 0",
|
||||
" fi",
|
||||
" local out",
|
||||
" out=\"$(mktemp)\"",
|
||||
" if \"$@\" >\"$out\" 2>&1; then",
|
||||
" echo \">> $name: ok\"",
|
||||
" timed \"$name\" ok \"$t0\"",
|
||||
" echo \">> $name: ok ($took s)\"",
|
||||
" else",
|
||||
" failed+=(\"$name\")",
|
||||
" echo \">> $name: FAILED\"",
|
||||
" timed \"$name\" red \"$t0\"",
|
||||
" echo \">> $name: FAILED ($took s)\"",
|
||||
" brief_excerpt \"$out\"",
|
||||
" fi",
|
||||
" rm -f \"$out\"",
|
||||
@@ -1361,6 +1379,7 @@
|
||||
" return 1",
|
||||
"}",
|
||||
"frontend() { (cd frontend && \"$@\"); }",
|
||||
"gate_t0=\"$(ms)\"",
|
||||
"lane \"ruff\" ruff_check",
|
||||
"lane \"ruff format --check\" ruff_format",
|
||||
"lane \"basedpyright (new errors only)\" basedpyright",
|
||||
@@ -1387,6 +1406,9 @@
|
||||
" lane \"pip-audit (backend lock)\" pip_audit",
|
||||
" lane \"npm audit (production dependencies)\" frontend npm audit --omit=dev --audit-level=high",
|
||||
"fi",
|
||||
"echo \">> lane times:\"",
|
||||
"printf '%s\\n' \"${timings[@]}\"",
|
||||
"echo \"$(printf '%8s' \"$(secs $(($(ms) - gate_t0)))\") s total\"",
|
||||
"if [ ${#failed[@]} -eq 0 ]; then",
|
||||
" echo \">> gate ($mode): green ✓\"",
|
||||
" exit 0",
|
||||
|
||||
Reference in New Issue
Block a user