@biffo/cli 0.383.0 → 0.384.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -154,10 +154,26 @@ fi
|
|
|
154
154
|
# deliberate escape hatch AGENTS.md section 7 requires for loosening a gate --
|
|
155
155
|
# in the open, not by reaching for `--no-verify` and skipping every other check
|
|
156
156
|
# too.
|
|
157
|
+
#
|
|
158
|
+
# Pre-push ONLY, the lane is also SCOPED to the diff (see verify.sh): the full
|
|
159
|
+
# suite outgrew the fleet's 900s push timeout, and CI still runs all of it as
|
|
160
|
+
# the required check. `BIFFO_PGTEST_PREPUSH=1` marks this as a pre-push run
|
|
161
|
+
# (smaller budget); `BIFFO_PGTEST_CHANGED_FILES` names the changed paths;
|
|
162
|
+
# `BIFFO_PGTEST_SCOPE=none` means the diff is provably irrelevant, so the lane
|
|
163
|
+
# is not run. A hand-run `biffo verify` sets none of these and runs everything.
|
|
157
164
|
if [ -z "${BIFFO_SKIP_PGTEST:-}" ] && [ -n "$REFS_FILE" ]; then
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
165
|
+
PGTEST_LIST_FILE=$(mktemp) || PGTEST_LIST_FILE=""
|
|
166
|
+
trap 'rm -f "$REFS_FILE" "$PGTEST_LIST_FILE"' EXIT HUP INT TERM
|
|
167
|
+
export BIFFO_PGTEST_PREPUSH=1
|
|
168
|
+
BIFFO_PGTEST_DIFF_LIST_FILE="$PGTEST_LIST_FILE" sh scripts/biffo.sh pgtest-diff-check <"$REFS_FILE"
|
|
169
|
+
pgtest_status=$?
|
|
170
|
+
case "$pgtest_status" in
|
|
171
|
+
0)
|
|
172
|
+
export BIFFO_PGTEST_DIFF_RELEVANT=1
|
|
173
|
+
[ -n "$PGTEST_LIST_FILE" ] && export BIFFO_PGTEST_CHANGED_FILES="$PGTEST_LIST_FILE"
|
|
174
|
+
;;
|
|
175
|
+
1) export BIFFO_PGTEST_SCOPE=none ;;
|
|
176
|
+
esac
|
|
161
177
|
fi
|
|
162
178
|
|
|
163
179
|
# Through the version-pinned CLI since #1109, so a repo cannot run a gate two
|
|
@@ -154,10 +154,26 @@ fi
|
|
|
154
154
|
# deliberate escape hatch AGENTS.md section 7 requires for loosening a gate --
|
|
155
155
|
# in the open, not by reaching for `--no-verify` and skipping every other check
|
|
156
156
|
# too.
|
|
157
|
+
#
|
|
158
|
+
# Pre-push ONLY, the lane is also SCOPED to the diff (see verify.sh): the full
|
|
159
|
+
# suite outgrew the fleet's 900s push timeout, and CI still runs all of it as
|
|
160
|
+
# the required check. `BIFFO_PGTEST_PREPUSH=1` marks this as a pre-push run
|
|
161
|
+
# (smaller budget); `BIFFO_PGTEST_CHANGED_FILES` names the changed paths;
|
|
162
|
+
# `BIFFO_PGTEST_SCOPE=none` means the diff is provably irrelevant, so the lane
|
|
163
|
+
# is not run. A hand-run `biffo verify` sets none of these and runs everything.
|
|
157
164
|
if [ -z "${BIFFO_SKIP_PGTEST:-}" ] && [ -n "$REFS_FILE" ]; then
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
165
|
+
PGTEST_LIST_FILE=$(mktemp) || PGTEST_LIST_FILE=""
|
|
166
|
+
trap 'rm -f "$REFS_FILE" "$PGTEST_LIST_FILE"' EXIT HUP INT TERM
|
|
167
|
+
export BIFFO_PGTEST_PREPUSH=1
|
|
168
|
+
BIFFO_PGTEST_DIFF_LIST_FILE="$PGTEST_LIST_FILE" sh scripts/biffo.sh pgtest-diff-check <"$REFS_FILE"
|
|
169
|
+
pgtest_status=$?
|
|
170
|
+
case "$pgtest_status" in
|
|
171
|
+
0)
|
|
172
|
+
export BIFFO_PGTEST_DIFF_RELEVANT=1
|
|
173
|
+
[ -n "$PGTEST_LIST_FILE" ] && export BIFFO_PGTEST_CHANGED_FILES="$PGTEST_LIST_FILE"
|
|
174
|
+
;;
|
|
175
|
+
1) export BIFFO_PGTEST_SCOPE=none ;;
|
|
176
|
+
esac
|
|
161
177
|
fi
|
|
162
178
|
|
|
163
179
|
# Through the version-pinned CLI since #1109, so a repo cannot run a gate two
|
package/package.json
CHANGED
|
@@ -89,7 +89,14 @@ while read -r _local_ref local_sha _remote_ref remote_sha; do
|
|
|
89
89
|
continue
|
|
90
90
|
fi
|
|
91
91
|
|
|
92
|
-
|
|
92
|
+
changed=$(git diff --name-only "$range" 2>/dev/null)
|
|
93
|
+
# Hand the changed paths to the hook so verify.sh can SCOPE the pre-push
|
|
94
|
+
# pg-test lane to this diff instead of running the whole suite. Optional:
|
|
95
|
+
# nothing is written unless the caller names a file.
|
|
96
|
+
if [ -n "${BIFFO_PGTEST_DIFF_LIST_FILE:-}" ] && [ -n "$changed" ]; then
|
|
97
|
+
printf '%s\n' "$changed" >>"$BIFFO_PGTEST_DIFF_LIST_FILE"
|
|
98
|
+
fi
|
|
99
|
+
if printf '%s\n' "$changed" | grep -qE "$PATTERN"; then
|
|
93
100
|
echo hit >>"$RESULT_FILE"
|
|
94
101
|
fi
|
|
95
102
|
done
|
package/scripts/verify.sh
CHANGED
|
@@ -908,7 +908,20 @@ fi
|
|
|
908
908
|
# tests already passing before the kill, so it was slow, not failing
|
|
909
909
|
# (tabsii-com/tabsii-platform#1463). Same doubling; not re-measured to
|
|
910
910
|
# completion, so re-measure and tighten this comment when it next finishes.
|
|
911
|
-
|
|
911
|
+
#
|
|
912
|
+
# Pre-push (#2420): the fleet kills a push at 900s, so a 960s lane budget could
|
|
913
|
+
# never report -- the push died first. The pre-push gate (`.githooks/pre-push`
|
|
914
|
+
# exports BIFFO_PGTEST_PREPUSH=1) therefore runs a diff-SCOPED module set under
|
|
915
|
+
# a budget strictly below 900s, and the full suite stays with CI and a
|
|
916
|
+
# hand-run `biffo verify` (960s, unchanged). Do not raise the pre-push number:
|
|
917
|
+
# scope the set instead.
|
|
918
|
+
PG_PREPUSH_BUDGET_SECONDS=600
|
|
919
|
+
if [ -n "${BIFFO_PGTEST_PREPUSH:-}" ]; then
|
|
920
|
+
PG_TEST_BUDGET_SECONDS="${BIFFO_VERIFY_PG_BUDGET:-$PG_PREPUSH_BUDGET_SECONDS}"
|
|
921
|
+
else
|
|
922
|
+
PG_TEST_BUDGET_SECONDS="${BIFFO_VERIFY_PG_BUDGET:-960}"
|
|
923
|
+
fi
|
|
924
|
+
PG_SCOPED_DESC=""
|
|
912
925
|
PG_TEST_DSN="${BIFFO_TEST_PG_DSN:-${TABSII_TEST_PG_DSN:-}}"
|
|
913
926
|
|
|
914
927
|
# `.claude/worktrees` is excluded alongside `.worktrees`, and finding out why
|
|
@@ -1153,6 +1166,11 @@ pg_test_run() {
|
|
|
1153
1166
|
echo "so nothing below is a verdict on your change. Do not go looking for a"
|
|
1154
1167
|
echo "bug on this evidence."
|
|
1155
1168
|
echo ""
|
|
1169
|
+
if [ -n "$PG_SCOPED_DESC" ]; then
|
|
1170
|
+
echo "This was the pre-push SCOPED set (the full suite runs in CI):"
|
|
1171
|
+
printf '%s\n' "$PG_SCOPED_DESC"
|
|
1172
|
+
echo ""
|
|
1173
|
+
fi
|
|
1156
1174
|
echo "Most likely the lane has simply outgrown its budget. Re-run with more:"
|
|
1157
1175
|
echo " BIFFO_VERIFY_PG_BUDGET=$((PG_TEST_BUDGET_SECONDS * 2)) sh scripts/verify.sh"
|
|
1158
1176
|
echo ""
|
|
@@ -1195,6 +1213,64 @@ pg_test_run() {
|
|
|
1195
1213
|
return 0
|
|
1196
1214
|
}
|
|
1197
1215
|
|
|
1216
|
+
# Pre-push scoping (#2420). Given the pushed diff's changed paths and the full
|
|
1217
|
+
# discovered module list, print the modules worth running now, one per line:
|
|
1218
|
+
# 1. every changed *_pg.py test file;
|
|
1219
|
+
# 2. the smoke set the repo declares in scripts/pg-test-smoke.txt (one path
|
|
1220
|
+
# per line, `#` comments allowed);
|
|
1221
|
+
# 3. for each changed db/imports/**.sql, the modules that mention a table it
|
|
1222
|
+
# CREATEs or ALTERs (grep over table names).
|
|
1223
|
+
# Runs in a subshell, so the human-readable "why" is rebuilt into
|
|
1224
|
+
# PG_SCOPED_DESC by the caller via pg_scope_describe.
|
|
1225
|
+
pg_scope_tables() {
|
|
1226
|
+
# table names created/altered in the changed SQL, schema/quotes stripped
|
|
1227
|
+
while IFS= read -r _f; do
|
|
1228
|
+
case "$_f" in
|
|
1229
|
+
*/db/imports/*.sql | db/imports/*.sql) [ -f "$_f" ] || continue ;;
|
|
1230
|
+
*) continue ;;
|
|
1231
|
+
esac
|
|
1232
|
+
grep -iE '^[[:space:]]*(create|alter)[[:space:]]+table' "$_f" 2>/dev/null \
|
|
1233
|
+
| sed -E 's/--.*//; s/"//g' \
|
|
1234
|
+
| sed -E 's/^[[:space:]]*[Cc][Rr][Ee][Aa][Tt][Ee][[:space:]]+[Tt][Aa][Bb][Ll][Ee][[:space:]]+([Ii][Ff][[:space:]]+[Nn][Oo][Tt][[:space:]]+[Ee][Xx][Ii][Ss][Tt][Ss][[:space:]]+)?//; s/^[[:space:]]*[Aa][Ll][Tt][Ee][Rr][[:space:]]+[Tt][Aa][Bb][Ll][Ee][[:space:]]+([Ii][Ff][[:space:]]+[Ee][Xx][Ii][Ss][Tt][Ss][[:space:]]+)?([Oo][Nn][Ll][Yy][[:space:]]+)?//' \
|
|
1235
|
+
| awk '{print $1}' | sed -E 's/\(.*//; s/.*\.//; s/[;,]//g' | grep -E '^[A-Za-z_][A-Za-z0-9_]*$'
|
|
1236
|
+
done <"$1" | sort -u
|
|
1237
|
+
}
|
|
1238
|
+
|
|
1239
|
+
pg_scope_modules() {
|
|
1240
|
+
_sc_changed="$1"
|
|
1241
|
+
_sc_all="$2"
|
|
1242
|
+
{
|
|
1243
|
+
# 1. changed *_pg.py files that exist and were discovered
|
|
1244
|
+
grep -E '_pg\.py$' "$_sc_changed" 2>/dev/null | while IFS= read -r _f; do
|
|
1245
|
+
printf '%s\n' "$_sc_all" | grep -Fx -- "$_f"
|
|
1246
|
+
done
|
|
1247
|
+
# 2. declared smoke set
|
|
1248
|
+
if [ -f scripts/pg-test-smoke.txt ]; then
|
|
1249
|
+
sed 's/#.*//; s/^[[:space:]]*//; s/[[:space:]]*$//' scripts/pg-test-smoke.txt | grep -v '^$' \
|
|
1250
|
+
| while IFS= read -r _f; do
|
|
1251
|
+
[ -f "$_f" ] && printf '%s\n' "$_f"
|
|
1252
|
+
done
|
|
1253
|
+
fi
|
|
1254
|
+
# 3. modules referencing a table the changed DDL creates or alters
|
|
1255
|
+
_sc_tables=$(pg_scope_tables "$_sc_changed")
|
|
1256
|
+
if [ -n "$_sc_tables" ]; then
|
|
1257
|
+
printf '%s\n' "$_sc_all" | while IFS= read -r _m; do
|
|
1258
|
+
[ -f "$_m" ] && printf '%s\n' "$_sc_tables" | grep -qwFf - "$_m" 2>/dev/null && printf '%s\n' "$_m"
|
|
1259
|
+
done
|
|
1260
|
+
fi
|
|
1261
|
+
} | grep -v '^$' | sort -u
|
|
1262
|
+
}
|
|
1263
|
+
|
|
1264
|
+
pg_scope_describe() {
|
|
1265
|
+
_sd_changed="$1"
|
|
1266
|
+
_sd_all="$2"
|
|
1267
|
+
printf 'selected because changed: %s\n' \
|
|
1268
|
+
"$(grep -E '_pg\.py$' "$_sd_changed" 2>/dev/null | while IFS= read -r _f; do printf '%s\n' "$_sd_all" | grep -Fx -- "$_f"; done | tr '\n' ' ')"
|
|
1269
|
+
[ -f scripts/pg-test-smoke.txt ] && printf 'selected as declared smoke set: scripts/pg-test-smoke.txt\n'
|
|
1270
|
+
_sd_tables=$(pg_scope_tables "$_sd_changed" | tr '\n' ' ')
|
|
1271
|
+
[ -n "$_sd_tables" ] && printf 'selected because they reference tables from changed DDL: %s\n' "$_sd_tables"
|
|
1272
|
+
}
|
|
1273
|
+
|
|
1198
1274
|
_pg_modules=$(pg_test_modules)
|
|
1199
1275
|
|
|
1200
1276
|
# Print the denominator, not just the verdict -- a discovery step that finds
|
|
@@ -1334,7 +1410,28 @@ else
|
|
|
1334
1410
|
"CI runs these as a required check; nothing local is checking them."
|
|
1335
1411
|
fi
|
|
1336
1412
|
else
|
|
1337
|
-
|
|
1413
|
+
_pg_run_modules="$_pg_modules"
|
|
1414
|
+
_pg_skip_lane=""
|
|
1415
|
+
if [ -z "$LIST" ] && [ -n "${BIFFO_PGTEST_PREPUSH:-}" ]; then
|
|
1416
|
+
if [ "${BIFFO_PGTEST_SCOPE:-}" = "none" ]; then
|
|
1417
|
+
_pg_skip_lane=1
|
|
1418
|
+
_pg_skip_msg="pre-push diff touches no db/imports/** or *_pg.py path (CI runs the full suite)"
|
|
1419
|
+
elif [ -n "${BIFFO_PGTEST_CHANGED_FILES:-}" ] && [ -f "$BIFFO_PGTEST_CHANGED_FILES" ]; then
|
|
1420
|
+
_pg_scoped=$(pg_scope_modules "$BIFFO_PGTEST_CHANGED_FILES" "$_pg_modules")
|
|
1421
|
+
if [ -z "$_pg_scoped" ]; then
|
|
1422
|
+
_pg_skip_lane=1
|
|
1423
|
+
_pg_skip_msg="pre-push scope selected no modules (no changed *_pg.py, no scripts/pg-test-smoke.txt entries, no referencing tests); CI runs the full suite"
|
|
1424
|
+
else
|
|
1425
|
+
_pg_run_modules="$_pg_scoped"
|
|
1426
|
+
PG_SCOPED_DESC="$(pg_scope_describe "$BIFFO_PGTEST_CHANGED_FILES" "$_pg_modules")
|
|
1427
|
+
modules: $(printf '%s\n' "$_pg_scoped" | tr '\n' ' ')"
|
|
1428
|
+
fi
|
|
1429
|
+
else
|
|
1430
|
+
printf ' \033[33m%s\033[0m\n' \
|
|
1431
|
+
"pre-push could not tell which paths changed: running the full pg-test suite under the ${PG_TEST_BUDGET_SECONDS}s pre-push budget"
|
|
1432
|
+
fi
|
|
1433
|
+
fi
|
|
1434
|
+
_pg_rel=$(echo "$_pg_run_modules" | sed "s|^$_pg_dir/||" | tr '\n' ' ')
|
|
1338
1435
|
# Not a plain `run_check` call: `pg_test_run` returns THREE states (0 pass,
|
|
1339
1436
|
# 1 real failure, 2 timed out/inconclusive -- see its own comment), and
|
|
1340
1437
|
# `run_check` only ever sees pass/fail, so routing through it would collapse
|
|
@@ -1343,7 +1440,14 @@ else
|
|
|
1343
1440
|
if [ -n "$LIST" ]; then
|
|
1344
1441
|
# shellcheck disable=SC2086
|
|
1345
1442
|
echo pg_test_run "$_pg_dir" "$_pg_rel"
|
|
1443
|
+
elif [ -n "$_pg_skip_lane" ]; then
|
|
1444
|
+
skip pg-test "$_pg_skip_msg"
|
|
1346
1445
|
else
|
|
1446
|
+
if [ "$_pg_run_modules" != "$_pg_modules" ]; then
|
|
1447
|
+
printf '\033[90m pg-test scoped (pre-push): %s of %s module(s), budget %ss; CI and hand-run verify run all\033[0m\n' \
|
|
1448
|
+
"$(printf '%s\n' "$_pg_run_modules" | grep -c .)" "$(printf '%s\n' "$_pg_modules" | grep -c .)" "$PG_TEST_BUDGET_SECONDS"
|
|
1449
|
+
printf '%s\n' "$PG_SCOPED_DESC" | sed 's/^/ /'
|
|
1450
|
+
fi
|
|
1347
1451
|
_pg_check_start=$(date +%s)
|
|
1348
1452
|
_verify_track_tmp "/tmp/biffo-verify-pg-check.$$"
|
|
1349
1453
|
# shellcheck disable=SC2086
|