# Service build and verification. Run from `service/`.
IMAGE ?= canned-prompts-service
TAG   ?= dev
BASE  ?= http://127.0.0.1:8000
HEAD  := $(shell .venv/bin/alembic heads 2>/dev/null | awk '{print $$1}')

.PHONY: test image smoke migrate run head

test:
	.venv/bin/python -m pytest -q

image:
	cd .. && docker build -f service/Dockerfile -t $(IMAGE):$(TAG) .

head:
	@echo $(HEAD)

migrate:
	.venv/bin/alembic upgrade head

run:
	.venv/bin/uvicorn canned_prompts_service.api:create_app --factory

# The service-level half of a rapp smoke contract. Cluster-level checks
# (NetworkPolicies, external secrets, private-Service-only) belong to
# rapp-canned-prompts, which can call this for the rest.
smoke:
	python3 tools/smoke.py --base $(BASE) --expect-migration $(HEAD)
