|
| 1 | +.DEFAULT_GOAL := help |
| 2 | + |
| 3 | +PORT ?= /dev/ttyACM0 |
| 4 | + |
| 5 | +# --- Development setup --- |
| 6 | + |
| 7 | +.PHONY: install |
| 8 | +install: ## Install dev tools and git hooks |
| 9 | + pip install ruff pytest |
| 10 | + npm install |
| 11 | + |
| 12 | +# --- Linting --- |
| 13 | + |
| 14 | +.PHONY: lint |
| 15 | +lint: ## Run ruff linter |
| 16 | + ruff check |
| 17 | + |
| 18 | +.PHONY: lint-fix |
| 19 | +lint-fix: ## Auto-fix lint issues |
| 20 | + ruff check --fix |
| 21 | + |
| 22 | +# --- Testing --- |
| 23 | + |
| 24 | +.PHONY: test |
| 25 | +test: ## Run all mock tests (no hardware needed) |
| 26 | + python3 -m pytest tests/ -v -k mock |
| 27 | + |
| 28 | +.PHONY: test-hw |
| 29 | +test-hw: ## Run hardware tests (needs board on PORT) |
| 30 | + python3 -m pytest tests/ -v --port $(PORT) -s |
| 31 | + |
| 32 | +.PHONY: test-all |
| 33 | +test-all: ## Run all tests (mock + hardware) |
| 34 | + python3 -m pytest tests/ -v --port $(PORT) -s |
| 35 | + |
| 36 | +.PHONY: test-driver |
| 37 | +test-driver: ## Run tests for one driver (usage: make test-driver DRIVER=hts221) |
| 38 | + python3 -m pytest tests/ -v -k "$(DRIVER)" --port $(PORT) -s |
| 39 | + |
| 40 | +.PHONY: test-examples |
| 41 | +test-examples: ## Validate all example files (syntax + imports) |
| 42 | + python3 -m pytest tests/test_examples.py -v |
| 43 | + |
| 44 | +# --- Hardware --- |
| 45 | + |
| 46 | +.PHONY: repl |
| 47 | +repl: ## Open MicroPython REPL on the board |
| 48 | + mpremote connect $(PORT) |
| 49 | + |
| 50 | +.PHONY: mount |
| 51 | +mount: ## Mount lib/ on the board for live testing |
| 52 | + mpremote connect $(PORT) mount lib/ |
| 53 | + |
| 54 | +# --- Utilities --- |
| 55 | + |
| 56 | +.PHONY: clean |
| 57 | +clean: ## Remove build artifacts and caches |
| 58 | + find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true |
| 59 | + find . -type d -name .pytest_cache -exec rm -rf {} + 2>/dev/null || true |
| 60 | + find . -type d -name .ruff_cache -exec rm -rf {} + 2>/dev/null || true |
| 61 | + |
| 62 | +.PHONY: help |
| 63 | +help: ## Show this help |
| 64 | + @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}' |
0 commit comments