diff --git a/Taskfile.yml b/Taskfile.yml index cea51b3..9742edc 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -24,13 +24,13 @@ vars: PYTHON_PROJECTS: sh: | find "$(git rev-parse --show-toplevel)" \ - -path "*/.venv" -prune -o \ + \( -path "*/.git" -o -path "*/.venv" -o -path "*/target" \) -prune -o \ -name pyproject.toml -print | sort ACTIVE_PYTHON_PROJECTS: sh: | if [ "${TASK_INCLUDE_PYTHON:-}" = "1" ]; then find "$(git rev-parse --show-toplevel)" \ - -path "*/.venv" -prune -o \ + \( -path "*/.git" -o -path "*/.venv" -o -path "*/target" \) -prune -o \ -name pyproject.toml -print | sort fi RUST_CORE_PACKAGES: >- @@ -57,8 +57,12 @@ tasks: exit 1 fi echo "{{.DETECTED_LANGUAGES}}" - if [ -n "{{.PYTHON_PROJECTS}}" ] && [ -z "{{.ACTIVE_PYTHON_PROJECTS}}" ]; then - echo "Python manifests detected; set TASK_INCLUDE_PYTHON=1 to include them in build/test/lint." + if [ -n "{{.PYTHON_PROJECTS}}" ]; then + echo "Python projects:" + printf '%s\n' "{{.PYTHON_PROJECTS}}" + if [ -z "{{.ACTIVE_PYTHON_PROJECTS}}" ]; then + echo "Set TASK_INCLUDE_PYTHON=1 to include Python projects in build/test/lint." + fi fi check: @@ -113,7 +117,13 @@ tasks: if [ -n "{{.ACTIVE_PYTHON_PROJECTS}}" ]; then printf '%s\n' "{{.ACTIVE_PYTHON_PROJECTS}}" | while IFS= read -r pyproject; do project_dir="$(dirname "${pyproject}")" - (cd "${project_dir}" && uv run pytest) + if [ -d "${project_dir}/tests" ] || find "${project_dir}" \ + -maxdepth 1 \ + -name 'test_*.py' -print -quit | grep -q .; then + (cd "${project_dir}" && uv run --with pytest pytest) + else + echo "Skipping Python tests in ${project_dir}; no top-level tests found." + fi done elif [ -n "{{.PYTHON_PROJECTS}}" ]; then echo "Skipping Python tests by default; set TASK_INCLUDE_PYTHON=1 to include Python projects." @@ -144,8 +154,8 @@ tasks: project_dir="$(dirname "${pyproject}")" ( cd "${project_dir}" && - uv run ruff check . && - uv run ruff format --check . + uv run --with ruff ruff check . && + uv run --with ruff ruff format --check . ) done elif [ -n "{{.PYTHON_PROJECTS}}" ]; then