.PHONY: run dev test test-local test-coverage test-e2e test-e2e-hub test-e2e-quick lint format typecheck validate clean install

# Use venv binaries if available
VENV := .venv
PYTHON := $(VENV)/bin/python
PIP := $(VENV)/bin/pip
PYTEST := $(VENV)/bin/pytest
RUFF := $(VENV)/bin/ruff
MYPY := $(VENV)/bin/mypy
TEXTUAL := $(VENV)/bin/textual

run:
	$(PYTHON) -m styrene

dev:
	$(TEXTUAL) run --dev dev.py

test:
	docker build -f Dockerfile.integration -t styrene-integration-tests .
	docker run --rm styrene-integration-tests

test-local:
	$(PYTEST) tests/ -v --ignore=tests/e2e/

test-coverage:
	$(PYTEST) tests/ --cov=src/styrene --cov-report=html --cov-report=term-missing

# E2E tests (require real network)
test-e2e:
	$(PYTEST) tests/e2e/ -v -m "e2e"

test-e2e-hub:
	$(PYTEST) tests/e2e/test_hub_connectivity.py -v

test-e2e-quick:
	$(PYTEST) tests/e2e/ -v -m "e2e and not slow"

lint:
	$(RUFF) check .

format:
	$(RUFF) format .

typecheck:
	$(MYPY) src/

validate: lint typecheck test

clean:
	rm -rf .pytest_cache .mypy_cache .ruff_cache __pycache__ src/styrene/__pycache__
	find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true

install:
	$(PIP) install -e ".[dev]"
