VENV := .venv
PY := $(VENV)/bin/python

.PHONY: dev test lint validate compose-check all

dev:
	python3 -m venv $(VENV)
	$(VENV)/bin/pip install -q --upgrade pip
	$(VENV)/bin/pip install -q -e "core[dev]"

test:
	$(VENV)/bin/pytest core

lint:
	$(VENV)/bin/ruff check core
	$(VENV)/bin/yamllint -s -c .yamllint.yml config catalog sites deploy/prometheus deploy/alertmanager deploy/litellm deploy/compose platform ontology

validate:
	$(VENV)/bin/knaster validate --root .
	$(VENV)/bin/knaster placement --inventory sites/knaster/inventory.yaml --catalog catalog > /dev/null

compose-check:
	@for d in infra gpu-vllm gpu-llamacpp; do \
	  (cd deploy/compose/$$d && cp .env.example .env.ci && \
	   POSTGRES_PASSWORD=ci VLLM_MODEL=ci SLOT_ALIAS=ci docker compose --env-file .env.ci \
	     --profile embed --profile chat --profile dashboards --profile proxmox config -q; \
	   rc=$$?; rm -f .env.ci; exit $$rc) || exit 1; \
	done; echo "compose ok"

all: lint test validate compose-check
