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.
This commit is contained in:
parent
172f426ccd
commit
c801f03f5d
@ -13,6 +13,7 @@ echo "=== Dependency Audit ==="
|
|||||||
|
|
||||||
has_reqtxt=$(find "$TARGET" -maxdepth 2 -name "requirements*.txt" | head -1)
|
has_reqtxt=$(find "$TARGET" -maxdepth 2 -name "requirements*.txt" | head -1)
|
||||||
has_pyproject=$(find "$TARGET" -maxdepth 2 -name "pyproject.toml" | 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_python="${has_reqtxt}${has_pyproject}"
|
||||||
has_gomod=$(find "$TARGET" -maxdepth 2 -name "go.mod" | head -1)
|
has_gomod=$(find "$TARGET" -maxdepth 2 -name "go.mod" | head -1)
|
||||||
|
|
||||||
@ -28,7 +29,11 @@ if [ -n "$has_python" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo "-- Python (pip-audit) --"
|
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"
|
printf " source: %s (requirements file)\n" "$has_reqtxt"
|
||||||
audit_cmd="pip-audit -r $has_reqtxt"
|
audit_cmd="pip-audit -r $has_reqtxt"
|
||||||
else
|
else
|
||||||
|
|||||||
@ -25,8 +25,19 @@ if [ -n "$has_python" ]; then
|
|||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
has_uvlock=$(find "$TARGET" -maxdepth 2 -name "uv.lock" | head -1)
|
||||||
|
|
||||||
echo "-- Python (pytest --cov) --"
|
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"
|
printf "${GREEN}✓${NC} Python tests passed\n"
|
||||||
else
|
else
|
||||||
printf "${RED}✗${NC} Python tests failed\n"
|
printf "${RED}✗${NC} Python tests failed\n"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user