Files
Michele Dolfi 7292ce0078 ci: switch to ty and prek, and add PR fast checks (#873)
Replace mypy with ty and use prek to run the hooks. Keep the existing
Ruff rules and the compat projector and docs hooks. Set Ruff
force-exclude so that tests/data stays excluded when files are passed
by name, and add a Makefile with the common targets.

Add a pull_request_target workflow that runs Ruff and ty on the changed
files of a PR without maintainer approval. Move the lint into its own
job, run pytest in the test job instead of a hook, pin the GitHub
actions and add an All Green check job.

Signed-off-by: Michele Dolfi <dol@zurich.ibm.com>
2026-10-19 15:59:54 +02:00

48 lines
1.5 KiB
Makefile

.PHONY: help setup hooks-install check validate validate-all fix typecheck test
PY_DIRS := docling_core tests examples packages/dclq .github/scripts
help: ## Show available targets.
@awk 'BEGIN {FS = ":.*##"; print "Available targets:"} /^[a-zA-Z0-9_.-]+:.*##/ {printf " %-14s %s\n", $$1, $$2}' $(MAKEFILE_LIST)
setup: ## Install CI-style development environment.
uv sync --frozen --all-extras --all-packages
hooks-install: ## Install git hooks via prek.
uv run prek install
check: ## Run read-only local checks.
uv run ruff format --check --config=pyproject.toml $(PY_DIRS)
uv run ruff check --config=pyproject.toml $(PY_DIRS)
uv run --no-sync ty check
uv run --no-sync python scripts/check_compat_projectors.py
uv lock --locked
validate: ## Run hooks on the current changeset.
@files="$$( \
{ \
git diff --name-only --diff-filter=ACMR; \
git diff --cached --name-only --diff-filter=ACMR; \
git ls-files --others --exclude-standard; \
} | sort -u \
)"; \
if [ -z "$$files" ]; then \
echo "No changed files to validate."; \
else \
printf '%s\n' "$$files" | xargs uv run prek run --files; \
fi
validate-all: ## Run hooks on all files.
uv run prek run --all-files
fix: ## Run Ruff auto-format and fixers.
uv run ruff format --config=pyproject.toml $(PY_DIRS)
uv run ruff check --fix --config=pyproject.toml $(PY_DIRS)
typecheck: ## Run ty.
uv run --no-sync ty check
test: ## Run the test suite.
uv run pytest --cov=docling_core --cov-report=xml tests
uv run pytest packages/dclq/tests