# Convenience targets. Use `make help` to list them.

PY ?= python3
PIP ?= $(PY) -m pip
PORT ?= 8088

.PHONY: help install dev test docker-build docker-run smoke

help:
	@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "  \033[36m%-15s\033[0m %s\n", $$1, $$2}'

install: ## Install runtime deps + the package itself
	$(PIP) install -e .

dev: ## Install dev deps + the package
	$(PIP) install -e .[dev]

test: ## Run the test suite
	pytest -v

docker-build: ## Build the container image
	docker build -t claude-code-runner:0.1.0 .

docker-run: ## Run the container with the .env file
	docker run --rm \
		-p $(PORT):8088 \
		--env-file .env \
		claude-code-runner:0.1.0

smoke: ## Quick smoke test against a running runner (uses .env)
	@bash -c 'source .env && curl -sS -X GET http://127.0.0.1:$(PORT)/healthz && echo'
	@echo '---'
	@bash -c 'source .env && curl -sS -X POST http://127.0.0.1:$(PORT)/jobs \
		-H "Authorization: Bearer $$RUNNER_AUTH_TOKEN" \
		-H "Content-Type: application/json" \
		-d @tests/fixtures/sample_job.json'
