|
1 | 1 | .DEFAULT_GOAL := help |
2 | 2 | .PHONY: help install lint format typecheck quality fixtures test all |
3 | 3 |
|
4 | | -# Colors for output |
| 4 | +# Colors (ANSI) |
5 | 5 | YELLOW := \033[33m |
6 | | -GREEN := \033[32m |
7 | | -BLUE := \033[34m |
8 | | -RED := \033[31m |
9 | | -RESET := \033[0m |
| 6 | +GREEN := \033[32m |
| 7 | +BLUE := \033[34m |
| 8 | +RED := \033[31m |
| 9 | +RESET := \033[0m |
| 10 | + |
| 11 | +# Print helper |
| 12 | +PRINT = printf "%b\n" |
| 13 | + |
| 14 | +# Max pytest-xdist workers |
| 15 | +MAX_XDIST ?= 6 |
| 16 | + |
| 17 | +# Compute worker count using Python (cross-platform) |
| 18 | +XDIST_WORKERS := $(shell MAX_XDIST=$(MAX_XDIST) python -c "import multiprocessing as mp, os; print(min(mp.cpu_count(), int(os.environ.get('MAX_XDIST', 6))))") |
10 | 19 |
|
11 | 20 | help: ## Show this help message |
12 | | - @echo "$(BLUE)BalatroBot Development Makefile$(RESET)" |
13 | | - @echo "" |
14 | | - @echo "$(YELLOW)Available targets:$(RESET)" |
15 | | - @printf " $(GREEN)%-18s$(RESET) %s\n" "help" "Show this help message" |
16 | | - @printf " $(GREEN)%-18s$(RESET) %s\n" "install" "Install balatrobot and all dependencies (including dev)" |
17 | | - @printf " $(GREEN)%-18s$(RESET) %s\n" "lint" "Run ruff linter (check only)" |
18 | | - @printf " $(GREEN)%-18s$(RESET) %s\n" "format" "Run ruff and mdformat formatters" |
| 21 | + @$(PRINT) "$(BLUE)BalatroBot Development Makefile$(RESET)" |
| 22 | + @$(PRINT) "" |
| 23 | + @$(PRINT) "$(YELLOW)Available targets:$(RESET)" |
| 24 | + @printf " $(GREEN)%-18s$(RESET) %s\n" "help" "Show this help message" |
| 25 | + @printf " $(GREEN)%-18s$(RESET) %s\n" "install" "Install balatrobot and all dependencies (including dev)" |
| 26 | + @printf " $(GREEN)%-18s$(RESET) %s\n" "lint" "Run ruff linter (check only)" |
| 27 | + @printf " $(GREEN)%-18s$(RESET) %s\n" "format" "Run ruff and mdformat formatters" |
19 | 28 | @printf " $(GREEN)%-18s$(RESET) %s\n" "typecheck" "Run type checker" |
20 | | - @printf " $(GREEN)%-18s$(RESET) %s\n" "quality" "Run all code quality checks" |
21 | | - @printf " $(GREEN)%-18s$(RESET) %s\n" "fixtures" "Generate fixtures" |
22 | | - @printf " $(GREEN)%-18s$(RESET) %s\n" "test" "Run all tests" |
23 | | - @printf " $(GREEN)%-18s$(RESET) %s\n" "all" "Run all code quality checks and tests" |
| 29 | + @printf " $(GREEN)%-18s$(RESET) %s\n" "quality" "Run all code quality checks" |
| 30 | + @printf " $(GREEN)%-18s$(RESET) %s\n" "fixtures" "Generate fixtures" |
| 31 | + @printf " $(GREEN)%-18s$(RESET) %s\n" "test" "Run all tests" |
| 32 | + @printf " $(GREEN)%-18s$(RESET) %s\n" "all" "Run all code quality checks and tests" |
24 | 33 |
|
25 | 34 | install: ## Install balatrobot and all dependencies (including dev) |
26 | | - @echo "$(YELLOW)Installing all dependencies...$(RESET)" |
| 35 | + @$(PRINT) "$(YELLOW)Installing all dependencies...$(RESET)" |
27 | 36 | uv sync --group dev --group test |
28 | 37 |
|
29 | 38 | lint: ## Run ruff linter (check only) |
30 | | - @echo "$(YELLOW)Running ruff linter...$(RESET)" |
| 39 | + @$(PRINT) "$(YELLOW)Running ruff linter...$(RESET)" |
31 | 40 | ruff check --fix --select I . |
32 | 41 | ruff check --fix . |
33 | 42 |
|
34 | 43 | format: ## Run ruff and mdformat formatters |
35 | | - @echo "$(YELLOW)Running ruff formatter...$(RESET)" |
| 44 | + @$(PRINT) "$(YELLOW)Running ruff formatter...$(RESET)" |
36 | 45 | ruff check --select I --fix . |
37 | 46 | ruff format . |
38 | | - @echo "$(YELLOW)Running mdformat formatter...$(RESET)" |
| 47 | + @$(PRINT) "$(YELLOW)Running mdformat formatter...$(RESET)" |
39 | 48 | mdformat ./docs README.md CLAUDE.md |
40 | 49 | @if command -v stylua >/dev/null 2>&1; then \ |
41 | | - echo "$(YELLOW)Running stylua formatter...$(RESET)"; \ |
| 50 | + $(PRINT) "$(YELLOW)Running stylua formatter...$(RESET)"; \ |
42 | 51 | stylua src/lua; \ |
43 | 52 | else \ |
44 | | - echo "$(BLUE)Skipping stylua formatter (stylua not found)$(RESET)"; \ |
| 53 | + $(PRINT) "$(BLUE)Skipping stylua formatter (stylua not found)$(RESET)"; \ |
45 | 54 | fi |
46 | 55 |
|
47 | 56 | typecheck: ## Run type checker |
48 | | - @echo "$(YELLOW)Running Python type checker...$(RESET)" |
| 57 | + @$(PRINT) "$(YELLOW)Running Python type checker...$(RESET)" |
49 | 58 | @ty check |
50 | 59 | @if command -v lua-language-server >/dev/null 2>&1 && [ -f .luarc.json ]; then \ |
51 | | - echo "$(YELLOW)Running Lua type checker...$(RESET)"; \ |
52 | | - lua-language-server --check balatrobot.lua src/lua --configpath="$(CURDIR)/.luarc.json" 2>/dev/null; \ |
| 60 | + $(PRINT) "$(YELLOW)Running Lua type checker...$(RESET)"; \ |
| 61 | + lua-language-server --check balatrobot.lua src/lua \ |
| 62 | + --configpath="$(CURDIR)/.luarc.json" 2>/dev/null; \ |
53 | 63 | else \ |
54 | | - echo "$(BLUE)Skipping Lua type checker (lua-language-server not found or .luarc.json missing)$(RESET)"; \ |
| 64 | + $(PRINT) "$(BLUE)Skipping Lua type checker (lua-language-server not found or .luarc.json missing)$(RESET)"; \ |
55 | 65 | fi |
56 | 66 |
|
57 | 67 | quality: lint typecheck format ## Run all code quality checks |
58 | | - @echo "$(GREEN)✓ All checks completed$(RESET)" |
| 68 | + @$(PRINT) "$(GREEN)✓ All checks completed$(RESET)" |
59 | 69 |
|
60 | 70 | fixtures: ## Generate fixtures |
61 | | - @echo "$(YELLOW)Starting Balatro...$(RESET)" |
| 71 | + @$(PRINT) "$(YELLOW)Starting Balatro...$(RESET)" |
62 | 72 | balatrobot --fast --debug |
63 | | - @echo "$(YELLOW)Generating all fixtures...$(RESET)" |
| 73 | + @$(PRINT) "$(YELLOW)Generating all fixtures...$(RESET)" |
64 | 74 | python tests/fixtures/generate.py |
65 | 75 |
|
66 | 76 | test: ## Run all tests |
67 | | - @echo "$(YELLOW)Running tests/cli...$(RESET)" |
| 77 | + @$(PRINT) "$(YELLOW)Running tests/cli...$(RESET)" |
68 | 78 | pytest tests/cli |
69 | | - @echo "$(YELLOW)Running tests/lua...$(RESET)" |
70 | | - pytest -n 6 tests/lua |
| 79 | + @$(PRINT) "$(YELLOW)Running tests/lua with $(XDIST_WORKERS) workers...$(RESET)" |
| 80 | + pytest -n $(XDIST_WORKERS) tests/lua |
| 81 | + |
71 | 82 |
|
72 | 83 | all: lint format typecheck test ## Run all code quality checks and tests |
73 | | - @echo "$(GREEN)✓ All checks completed$(RESET)" |
| 84 | + @$(PRINT) "$(GREEN)✓ All checks completed$(RESET)" |
0 commit comments