# List available recipes
default:
    @just --list

# Run the full test suite
test:
    uv run pytest

# Lint, format-check and type-check — the same gates CI used to run
check:
    uv run ruff check
    uv run ruff format --check
    uv run ty check

# Everything a change must pass before it merges
verify: check test

# Show what the next release would be, and change nothing.
# Always run this before `release`.
release-preview:
    @uvx --from python-semantic-release semantic-release version --print

# Replaces the old `.github/workflows/release.yml`. That workflow used PyPI
# Trusted Publishing, which broke (issue #140) and left `main` tagged at a
# version that did not exist on PyPI — a failure mode this recipe avoids by
# publishing from the same machine that cut the tag.
#
# Requires PYPI_TOKEN in the environment:
#     set -a && . ~/.pypi && set +a && just release
#
# `verify` runs first and a failure stops the release — the local suite is
# the real gate for this project, so nothing ships that has not passed it.
#
# Bump the version from commit history, tag, build and publish to PyPI
release: verify
    #!/usr/bin/env bash
    set -euo pipefail
    if [ -z "${PYPI_TOKEN:-}" ]; then
        echo "PYPI_TOKEN is not set. Load it first:" >&2
        echo "    set -a && . ~/.pypi && set +a" >&2
        exit 1
    fi
    if [ -n "$(git status --porcelain)" ]; then
        echo "Working tree is dirty — commit or stash before releasing." >&2
        exit 1
    fi
    uvx --from python-semantic-release semantic-release version
    rm -rf dist
    uv build
    UV_PUBLISH_TOKEN="${PYPI_TOKEN}" uv publish
    git push --follow-tags
    @echo "Released. Verify with: curl -s https://pypi.org/pypi/curu-infra/json | jq -r .info.version"

# Was `.github/workflows/smoke.yml`, running nightly at 03:00 UTC. That
# schedule provisioned a real pod every night whether or not anything had
# changed — a standing cost for a signal nobody was reading. Spec 029 US2
# always specified this local path (`RUNPOD_API_KEY`-gated, skips cleanly
# without it); removing the schedule makes it the only trigger.
#
# Run it when provisioning changes, not on a timer:
#     set -a && . ~/.env && set +a && just smoke
#
# Live provisioning smoke test — provisions a REAL RunPod pod and BILLS
smoke:
    uv run pytest tests/integration/test_smoke.py -v
