# Run all CI checks (lint, type-check, test, network-test, dogfood, check-version)
ci: install lint type-check test network-test dogfood check-version

# Run linting checks (ruff check + format check)
lint:
    uv run ruff check src tests
    uv run ruff format --check src tests

# Run type checking with mypy
type-check:
    uv run mypy src

# Run tests with coverage, the way CI runs them.
#
# Over-subscribed because the suite is sleep-bound, not CPU-bound: ~68s of
# wall time for 13s of CPU, since the timeout and process-tree tests wait on
# real clocks. Workers past the core count overlap that waiting rather than
# competing for it.
#
# -n 8 rather than more *because* of coverage: pytest-cov writes one data file
# per worker and combines them at the end, so 24 of them cost more to merge
# than the parallelism saves. Measured on a CI runner, this step was 64s at
# -n 24, 49s at -n 16 and 41s at -n 8. Without coverage, -n 24 is the faster
# setting -- see the `test` job in ci.yml.
test:
    uv run pytest -n 8 --cov=src/testudos --cov-report=term-missing --cov-fail-under=80

# Run the tests that really invoke uv, and so resolve packages from PyPI.
# Deselected from `just test` so their cost is opted into, not paid silently.
network-test:
    uv run pytest -m network -v

# Run testudos on itself (dogfooding)
dogfood:
    uv run testudos run --parallel

# Fix linting issues automatically
fix:
    uv run ruff check --fix src tests
    uv run ruff format src tests

# Check version bump and changelog entry
check-version:
    uv run scripts/check_version_bump.py

# Install dev dependencies
install:
    uv sync --extra dev
