SHELL := /bin/bash

.PHONY: run down logs test smoke

run:
	docker compose up --build

down:
	docker compose down

logs:
	docker compose logs -f

test:
	cd solver-api && npm test
	cd gui-ts && npm test
	./solver-c/test_solver

smoke:
	@echo "Checking API health..."
	@for i in {1..30}; do \
		if curl --fail --silent http://localhost:4400/health > /dev/null; then \
			echo "API healthy"; \
			break; \
		fi; \
		sleep 1; \
		if [ $$i -eq 30 ]; then \
			echo "API did not become healthy in time"; \
			exit 1; \
		fi; \
	done
	@echo "Checking solve endpoint with base case..."
	@curl --fail --silent http://localhost:4400/solve/default > /dev/null && echo "Solve endpoint healthy"
