@caddis/cli 0.4.51 → 0.4.52
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.
|
@@ -689,7 +689,49 @@ if [ -f "pyproject.toml" ] || [ -f "requirements.txt" ]; then
|
|
|
689
689
|
echo "[gate] interpreter: $PY"
|
|
690
690
|
py_gate ruff check .
|
|
691
691
|
if py_sources_exist; then py_gate mypy .; else echo "[skip] mypy: no Python sources"; fi
|
|
692
|
-
|
|
692
|
+
# pytest is OPT-IN here (CADDIS_GATE_PYTEST=1). Found 2026-10-10: the full suite took 25-31 min in this
|
|
693
|
+
# hook on a box whose system disk was slow, while CI ran the same suite in 5 min - and a merge needs green
|
|
694
|
+
# CI anyway. A local gate five times slower than the check it stands in for trains people to --no-verify it.
|
|
695
|
+
# When it does run: CADDIS_GATE_TMP moves TMPDIR/TEMP/TMP (tests write to tmp_path; Python reads TMPDIR
|
|
696
|
+
# first, so set all three), CADDIS_GATE_PYTEST_ARGS adds arguments (for example "-n 4" with pytest-xdist;
|
|
697
|
+
# use a number, not "auto"), and a machine-wide lock (CADDIS_GATE_LOCK, mkdir-based, waits up to
|
|
698
|
+
# CADDIS_GATE_LOCK_WAIT seconds, a stale one is taken over after 60 min) lets only ONE pytest gate run at a time, so several repos pushing together cannot
|
|
699
|
+
# pile their suites on the same disk and CI runners.
|
|
700
|
+
if [ "${CADDIS_GATE_PYTEST:-0}" = "1" ]; then
|
|
701
|
+
if [ -n "${CADDIS_GATE_TMP:-}" ]; then
|
|
702
|
+
mkdir -p "$CADDIS_GATE_TMP" 2>/dev/null || true
|
|
703
|
+
export TMPDIR="$CADDIS_GATE_TMP" TEMP="$CADDIS_GATE_TMP" TMP="$CADDIS_GATE_TMP"
|
|
704
|
+
fi
|
|
705
|
+
LOCK="${CADDIS_GATE_LOCK:-${TMPDIR:-${TEMP:-/tmp}}/caddis-pytest-gate.lock}"
|
|
706
|
+
mkdir -p "$(dirname "$LOCK")" 2>/dev/null || true
|
|
707
|
+
lock_wait="${CADDIS_GATE_LOCK_WAIT:-1800}"
|
|
708
|
+
waited=0
|
|
709
|
+
got_lock=0
|
|
710
|
+
while :; do
|
|
711
|
+
if mkdir "$LOCK" 2>/dev/null; then got_lock=1; break; fi
|
|
712
|
+
# A stale lock is removed, then this round still sleeps and counts: if the removal fails (a lock owned
|
|
713
|
+
# by another user), the loop ends at lock_wait instead of spinning forever.
|
|
714
|
+
if [ -n "$(find "$LOCK" -maxdepth 0 -mmin +60 2>/dev/null)" ]; then
|
|
715
|
+
rmdir "$LOCK" 2>/dev/null || true
|
|
716
|
+
fi
|
|
717
|
+
if [ "$waited" -ge "$lock_wait" ]; then break; fi
|
|
718
|
+
if [ "$waited" -eq 0 ]; then echo "[gate] pytest: waiting for another repo's pytest gate ($LOCK)"; fi
|
|
719
|
+
sleep 1
|
|
720
|
+
waited=$((waited + 1))
|
|
721
|
+
done
|
|
722
|
+
if [ "$got_lock" -eq 1 ]; then
|
|
723
|
+
trap 'rmdir "$LOCK" 2>/dev/null || true' EXIT INT TERM
|
|
724
|
+
# shellcheck disable=SC2086 # CADDIS_GATE_PYTEST_ARGS is meant to word-split
|
|
725
|
+
py_gate pytest -q ${CADDIS_GATE_PYTEST_ARGS:-}
|
|
726
|
+
rmdir "$LOCK" 2>/dev/null || true
|
|
727
|
+
trap - EXIT INT TERM
|
|
728
|
+
else
|
|
729
|
+
echo "[gate] pytest: another pytest gate holds $LOCK for over ${lock_wait}s - cannot run, so the gate fails" >&2
|
|
730
|
+
fail=1
|
|
731
|
+
fi
|
|
732
|
+
else
|
|
733
|
+
echo "[skip] pytest: runs in CI (set CADDIS_GATE_PYTEST=1 to run it here)"
|
|
734
|
+
fi
|
|
693
735
|
fi
|
|
694
736
|
fi
|
|
695
737
|
if [ -f "package.json" ] && command -v npm >/dev/null 2>&1; then
|
package/bundles/manifest.json
CHANGED
package/package.json
CHANGED