# Makefile

.PHONY: test typecheck sync-schema sync-example check dist publish dist-clean deploy smoke

test:
	.venv/bin/pytest

typecheck:
	.venv/bin/ty check

sync-schema:
	cp src/examen/artifact/schema.json skill/examen/artifact-schema.json

sync-example:
	cp tests/fixtures/example_quiz_small.json skill/examen/examples/example_quiz.json

check: sync-schema sync-example typecheck test

# --- Launch targets ---------------------------------------------------------

# Build wheel + sdist into dist/. Used by `publish`.
dist: dist-clean
	python3 -m venv .venv-build
	.venv-build/bin/pip install --upgrade pip build twine
	.venv-build/bin/python -m build
	.venv-build/bin/twine check dist/*

# Remove prior build artifacts.
dist-clean:
	rm -rf dist build src/examen.egg-info .venv-build

# Publish to PyPI. Requires twine auth (token in keychain or ~/.pypirc).
# Run `make dist` first; this target deliberately does NOT auto-build so a
# stale dist/ never gets uploaded by accident.
publish:
	@test -d dist || (echo "ERROR: run 'make dist' first"; exit 1)
	.venv-build/bin/twine upload dist/*

# Deploy the hosted demo to Fly.io. Requires `fly auth login` to have been run.
deploy:
	fly deploy

# Run the automated smoke test against the hosted demo.
# Override URL: `make smoke URL=https://staging.example.com`
smoke:
	./scripts/smoke-hosted-demo.sh $(URL)
