Skip to content

Commit edfb5ba

Browse files
committed
chore: update Makefile to use printf and dynamic workers
1 parent d07c354 commit edfb5ba

1 file changed

Lines changed: 44 additions & 33 deletions

File tree

Makefile

Lines changed: 44 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,84 @@
11
.DEFAULT_GOAL := help
22
.PHONY: help install lint format typecheck quality fixtures test all
33

4-
# Colors for output
4+
# Colors (ANSI)
55
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))))")
1019

1120
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"
1928
@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"
2433

2534
install: ## Install balatrobot and all dependencies (including dev)
26-
@echo "$(YELLOW)Installing all dependencies...$(RESET)"
35+
@$(PRINT) "$(YELLOW)Installing all dependencies...$(RESET)"
2736
uv sync --group dev --group test
2837

2938
lint: ## Run ruff linter (check only)
30-
@echo "$(YELLOW)Running ruff linter...$(RESET)"
39+
@$(PRINT) "$(YELLOW)Running ruff linter...$(RESET)"
3140
ruff check --fix --select I .
3241
ruff check --fix .
3342

3443
format: ## Run ruff and mdformat formatters
35-
@echo "$(YELLOW)Running ruff formatter...$(RESET)"
44+
@$(PRINT) "$(YELLOW)Running ruff formatter...$(RESET)"
3645
ruff check --select I --fix .
3746
ruff format .
38-
@echo "$(YELLOW)Running mdformat formatter...$(RESET)"
47+
@$(PRINT) "$(YELLOW)Running mdformat formatter...$(RESET)"
3948
mdformat ./docs README.md CLAUDE.md
4049
@if command -v stylua >/dev/null 2>&1; then \
41-
echo "$(YELLOW)Running stylua formatter...$(RESET)"; \
50+
$(PRINT) "$(YELLOW)Running stylua formatter...$(RESET)"; \
4251
stylua src/lua; \
4352
else \
44-
echo "$(BLUE)Skipping stylua formatter (stylua not found)$(RESET)"; \
53+
$(PRINT) "$(BLUE)Skipping stylua formatter (stylua not found)$(RESET)"; \
4554
fi
4655

4756
typecheck: ## Run type checker
48-
@echo "$(YELLOW)Running Python type checker...$(RESET)"
57+
@$(PRINT) "$(YELLOW)Running Python type checker...$(RESET)"
4958
@ty check
5059
@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; \
5363
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)"; \
5565
fi
5666

5767
quality: lint typecheck format ## Run all code quality checks
58-
@echo "$(GREEN)✓ All checks completed$(RESET)"
68+
@$(PRINT) "$(GREEN)✓ All checks completed$(RESET)"
5969

6070
fixtures: ## Generate fixtures
61-
@echo "$(YELLOW)Starting Balatro...$(RESET)"
71+
@$(PRINT) "$(YELLOW)Starting Balatro...$(RESET)"
6272
balatrobot --fast --debug
63-
@echo "$(YELLOW)Generating all fixtures...$(RESET)"
73+
@$(PRINT) "$(YELLOW)Generating all fixtures...$(RESET)"
6474
python tests/fixtures/generate.py
6575

6676
test: ## Run all tests
67-
@echo "$(YELLOW)Running tests/cli...$(RESET)"
77+
@$(PRINT) "$(YELLOW)Running tests/cli...$(RESET)"
6878
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+
7182

7283
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

Comments
 (0)