From c801f03f5df59cac2916870469589127ab7276cc Mon Sep 17 00:00:00 2001 From: Travis Herbranson Date: Tue, 12 May 2026 07:50:55 -0400 Subject: [PATCH] validate: detect uv projects in deps.sh and tests.sh Preserve pre-existing WIP from master's working tree. When a project has a uv.lock alongside pyproject.toml, run pip-audit and pytest under `uv run --directory $project` so they execute in the project's own managed venv instead of whatever pytest/pip-audit happens to be on PATH. Lifted verbatim from master's uncommitted working tree; committed on this branch as the base for subsequent Bug B (tests.sh SIGPIPE) and Bug C (pip-audit venv) fixes which both modify these regions. --- validate/deps.sh | 7 ++++++- validate/tests.sh | 13 ++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/validate/deps.sh b/validate/deps.sh index 9888dcc..43bde26 100755 --- a/validate/deps.sh +++ b/validate/deps.sh @@ -13,6 +13,7 @@ echo "=== Dependency Audit ===" has_reqtxt=$(find "$TARGET" -maxdepth 2 -name "requirements*.txt" | head -1) has_pyproject=$(find "$TARGET" -maxdepth 2 -name "pyproject.toml" | head -1) +has_uvlock=$(find "$TARGET" -maxdepth 2 -name "uv.lock" | head -1) has_python="${has_reqtxt}${has_pyproject}" has_gomod=$(find "$TARGET" -maxdepth 2 -name "go.mod" | head -1) @@ -28,7 +29,11 @@ if [ -n "$has_python" ]; then fi echo "-- Python (pip-audit) --" - if [ -n "$has_reqtxt" ]; then + if [ -n "$has_uvlock" ]; then + printf " source: %s (uv project)\n" "$has_uvlock" + pyproject_dir=$(dirname "$has_uvlock") + audit_cmd="uv run --directory $pyproject_dir pip-audit" + elif [ -n "$has_reqtxt" ]; then printf " source: %s (requirements file)\n" "$has_reqtxt" audit_cmd="pip-audit -r $has_reqtxt" else diff --git a/validate/tests.sh b/validate/tests.sh index 330f109..cadb2fa 100755 --- a/validate/tests.sh +++ b/validate/tests.sh @@ -25,8 +25,19 @@ if [ -n "$has_python" ]; then exit 2 fi + has_uvlock=$(find "$TARGET" -maxdepth 2 -name "uv.lock" | head -1) + echo "-- Python (pytest --cov) --" - if pytest "$TARGET" --cov --cov-report=term-missing -q 2>/dev/null; then + if [ -n "$has_uvlock" ]; then + printf " mode: uv project\n" + uv_dir=$(dirname "$has_uvlock") + test_cmd="uv run --directory $uv_dir pytest --cov --cov-report=term-missing -q" + else + printf " mode: global pytest\n" + test_cmd="pytest $TARGET --cov --cov-report=term-missing -q" + fi + + if $test_cmd 2>/dev/null; then printf "${GREEN}✓${NC} Python tests passed\n" else printf "${RED}✗${NC} Python tests failed\n"