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

# 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.
#
# More workers than cores because part of the suite waits on real clocks --
# the timeout and process-tree tests -- and workers past the core count
# overlap that waiting rather than competing for it.
#
# --dist worksteal because those tests sit together in a few files: the
# default distribution hands a worker a run of consecutive tests, so they
# wait behind each other. About 25s here on a developer's machine; CI's
# two-CPU runner is bound by its CPUs for the rest of the suite and takes
# 55-85s.
#
# -n 8 rather than more because of coverage: pytest-cov writes one data file
# per worker and combines them at the end.
test:
    uv run pytest -n 8 --dist worksteal --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 the CHANGELOG: an entry under [Unreleased], or a release's notes filed
check-changelog:
    uv run scripts/check_changelog.py

# Cut a release: file [Unreleased] under VERSION and bump to it (then open a PR)
release version:
    uv run python scripts/release.py {{version}}

# Record the stable surface after adding to it (docs/STABILITY.md)
stable-surface:
    uv run python tests/test_stability.py --write

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