.PHONY: lint fmt unit quality lock ci_unit_lint ci_unit_lint_clean

lint: ## Run linters, formatter check, type check, and dead-code check
	uv run ruff check .
	uv run ruff format --check .
	uv run ty check stale_pr_review/
	uv run vulture stale_pr_review

fmt: ## Apply lint fixes and formatting
	uv run ruff check --fix .
	uv run ruff format .

unit: ## Run the test suite
	GH_TOKEN=dummy uv run pytest tests/ -v

quality: lint ## Run every commit-stage quality gate (lint, format, type, dead-code, audit)
	uv run pre-commit run --all-files

lock: ## Refresh uv.lock to latest allowed versions (in Docker, no host uv needed)
	docker compose run --rm --build lockfile

# CI/CD entrypoints (consumed by the Jenkinsfile). Run inside Docker so the
# Jenkins agents need neither uv nor a specific Python version installed; the
# unit-lint image (Dockerfile target) provides both. JUnit XML lands in build/
# via the mounted volume in docker-compose.yml.
ci_unit_lint: ci_unit_lint_clean ## Run lint, type-check, dead-code, and tests in CI (Docker)
	mkdir -p build
	chmod a+w build
	docker compose run --rm --build unit-lint

ci_unit_lint_clean: ## Teardown CI build artifacts
	rm -rf build
