# mach — the test legs, named so local and CI cannot drift apart.
#
# There are two, and they are NOT interchangeable:
#
#   make hosted   what GitHub Actions runs. Model-free, no GPU. Skips every
#                 module that imports mlx (tests/conftest.py) — about half the
#                 suite — so a green `hosted` is necessary, never sufficient.
#
#   make metal    what an Apple Silicon runner runs. Everything `hosted` runs
#                 PLUS the kernel/parity/serving suites that need a real GPU.
#                 ~60s on an M-series laptop. This is the leg that catches
#                 numerics and decode-path regressions.

PYTEST ?= .venv/bin/python -m pytest
RUFF   ?= .venv/bin/python -m ruff
MYPY   ?= .venv/bin/python -m mypy
SUITES  = tests/ benchmarks/tests/
TYPECHECK_TARGETS = \
	src/mach/engine/cache_policy.py \
	src/mach/engine/decode_engine.py \
	src/mach/io/model_inspection.py \
	src/mach/io/pack_markers.py \
	src/mach/server/batch_scheduler.py \
	src/mach/server/engine_task.py \
	src/mach/server/production_cli.py \
	src/mach/server/request_limits.py \
	src/mach/server/runtime_state.py \
	src/mach/serving/openai/request.py \
	src/mach/specdec/speculation.py \
	src/mach/vision/image_sources.py

.PHONY: help lint typecheck hosted metal all

help:
	@echo "make lint      ruff, pinned to the version CI uses"
	@echo "make typecheck enforced types for stable request/config modules"
	@echo "make hosted    the model-free leg GitHub Actions runs"
	@echo "make metal     the Apple Silicon leg (hosted + GPU suites)"
	@echo "make all       lint + metal"

lint:
	$(RUFF) check .
	@if [ -f scripts/check_forbidden_terms.py ]; then python3 scripts/check_forbidden_terms.py; fi

typecheck:
	$(MYPY) $(TYPECHECK_TARGETS)

hosted:
	MACH_CI_NO_METAL=1 $(PYTEST) $(SUITES) -m "not metal and not slow" -q

metal:
	$(PYTEST) $(SUITES) -m "not slow" -q

all: lint typecheck metal
