# SPDX-FileCopyrightText: 2026 David Seaward and contributors
# SPDX-License-Identifier: Apache-2.0

_default:
    @just --list

# Prepare Python development environment
bootstrap:
    uv sync --all-extras
    uv run prek install --overwrite

# Remove all build artefacts
clean:
    rm -rf *.egg-info
    rm -rf .pytest_cache
    rm -rf dist
    rm -rf build
    rm -f .coverage
    find . -name "__pycache__" -type d -exec rm -rf {} +

# Fix or warn about linting errors
lint:
    uv run prek run --all-files

# Run tests and generate coverage report
test:
    uv run coverage run -m pytest
    uv run coverage report | tee coverage.txt
    @echo
    @git diff --compact-summary --exit-code || (echo "Uncommitted changes." && exit 1)

# Clean, lint, test, then generate new build artefacts
build: clean lint test
    uv build --clear

# Publish a GitLab release
publish:
    uv run carmine commitver-prompt
    glab auth status
    glab release create "$(uv run carmine commitver)" --ref main --notes "Release $(uv run carmine commitver)"
