|
1 | | -.PHONY: help test lint format typecheck ci-check act-local act-lint act-test clean |
| 1 | +# Color output |
| 2 | +BLUE := \033[0;34m |
| 3 | +GREEN := \033[0;32m |
| 4 | +YELLOW := \033[1;33m |
| 5 | +RED := \033[0;31m |
| 6 | +NC := \033[0m # No Color |
| 7 | + |
| 8 | +# act configuration |
| 9 | +CONTAINER_ARCH := linux/amd64 |
| 10 | +ACT_IMAGE := catthehacker/ubuntu:act-22.04 |
| 11 | + |
| 12 | +.PHONY: help test lint format typecheck ci-check act-local act-lint act-test clean check-docker |
2 | 13 |
|
3 | 14 | help: ## Show this help message |
4 | | - @echo "Available commands:" |
5 | | - @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}' |
| 15 | + @echo "$(BLUE)Available commands:$(NC)" |
| 16 | + @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " $(GREEN)%-20s$(NC) %s\n", $$1, $$2}' |
6 | 17 |
|
7 | 18 | # Local testing (fast, no Docker) |
8 | 19 | test: ## Run tests locally |
9 | | - uv run pytest tests/ -v |
| 20 | + @echo "$(BLUE)Running test suite...$(NC)" |
| 21 | + @uv run pytest tests/ -v |
| 22 | + @echo "$(GREEN)✓ All tests passed$(NC)" |
| 23 | + |
| 24 | +test-quick: ## Run tests with minimal output |
| 25 | + @echo "$(BLUE)Running test suite (quick mode)...$(NC)" |
| 26 | + @uv run pytest tests/ -q --tb=line |
| 27 | + @echo "$(GREEN)✓ All tests passed$(NC)" |
10 | 28 |
|
11 | 29 | lint: ## Run linting checks |
12 | | - uv run ruff check xbooster/ tests/ |
| 30 | + @echo "$(BLUE)Linting with ruff...$(NC)" |
| 31 | + @uv run ruff check xbooster/ tests/ |
| 32 | + @echo "$(GREEN)✓ Lint passed$(NC)" |
13 | 33 |
|
14 | 34 | format: ## Format code with ruff |
15 | | - uv run ruff format xbooster/ tests/ |
| 35 | + @echo "$(BLUE)Formatting code with ruff...$(NC)" |
| 36 | + @uv run ruff format xbooster/ tests/ |
| 37 | + @echo "$(GREEN)✓ Code formatted$(NC)" |
16 | 38 |
|
17 | 39 | format-check: ## Check code formatting |
18 | | - uv run ruff format --check xbooster/ tests/ |
| 40 | + @echo "$(BLUE)Checking format with ruff...$(NC)" |
| 41 | + @uv run ruff format --check xbooster/ tests/ |
| 42 | + @echo "$(GREEN)✓ Format check passed$(NC)" |
19 | 43 |
|
20 | 44 | typecheck: ## Run type checking with ty |
21 | | - uv run ty check |
22 | | - |
23 | | -ci-check: lint format-check typecheck ## Run all CI checks locally (fast) |
24 | | - @echo "✅ All CI checks passed!" |
| 45 | + @echo "$(BLUE)Type checking with ty...$(NC)" |
| 46 | + @uv run ty check |
| 47 | + @echo "$(GREEN)✓ Type check passed$(NC)" |
| 48 | + |
| 49 | +ci-check: ## Run all CI checks locally (fast, no Docker) |
| 50 | + @echo "$(BLUE)🔍 Running CI Checks Locally$(NC)" |
| 51 | + @echo "================================" |
| 52 | + @echo "" |
| 53 | + @echo "$(BLUE)[1/4]$(NC) Linting with ruff..." |
| 54 | + @uv run ruff check xbooster/ tests/ |
| 55 | + @echo "$(GREEN)✓$(NC) Lint passed" |
| 56 | + @echo "" |
| 57 | + @echo "$(BLUE)[2/4]$(NC) Checking format with ruff..." |
| 58 | + @uv run ruff format --check xbooster/ tests/ |
| 59 | + @echo "$(GREEN)✓$(NC) Format check passed" |
| 60 | + @echo "" |
| 61 | + @echo "$(BLUE)[3/4]$(NC) Type checking with ty..." |
| 62 | + @uv run ty check |
| 63 | + @echo "$(GREEN)✓$(NC) Type check passed" |
| 64 | + @echo "" |
| 65 | + @echo "$(BLUE)[4/4]$(NC) Running test suite..." |
| 66 | + @uv run pytest tests/ -q --tb=line |
| 67 | + @echo "$(GREEN)✓$(NC) All tests passed" |
| 68 | + @echo "" |
| 69 | + @echo "================================" |
| 70 | + @echo "$(GREEN)✨ All CI checks passed!$(NC)" |
| 71 | + |
| 72 | +# Docker/act utilities |
| 73 | +check-docker: ## Check if Docker is running |
| 74 | + @if ! docker info > /dev/null 2>&1; then \ |
| 75 | + echo "$(RED)Error: Docker is not running$(NC)"; \ |
| 76 | + echo "Please start Docker Desktop and try again."; \ |
| 77 | + exit 1; \ |
| 78 | + fi |
25 | 79 |
|
26 | 80 | # act-based testing (uses Docker) |
27 | | -act-local: ## Run lightweight local workflow with act |
28 | | - act -W .github/workflows/local-test.yml |
29 | | - |
30 | | -act-lint: ## Run only lint job with act |
31 | | - act -W .github/workflows/ci.yml --job lint |
32 | | - |
33 | | -act-typecheck: ## Run only type-check job with act |
34 | | - act -W .github/workflows/ci.yml --job type-check |
35 | | - |
36 | | -act-test: ## Run only one test matrix with act |
37 | | - act -W .github/workflows/ci.yml --job test --matrix python-version:3.11 --matrix xgboost-version:3.0.5 |
| 81 | +act-local: check-docker ## Run lightweight local workflow with act (recommended) |
| 82 | + @echo "$(BLUE)Running lightweight local workflow...$(NC)" |
| 83 | + @echo "$(YELLOW)Memory usage: ~1.5GB$(NC)" |
| 84 | + @act -W .github/workflows/local-test.yml --container-architecture $(CONTAINER_ARCH) |
| 85 | + @echo "" |
| 86 | + @echo "$(GREEN)✓ act completed successfully$(NC)" |
| 87 | + |
| 88 | +act-lint: check-docker ## Run only lint job with act |
| 89 | + @echo "$(BLUE)Running lint job...$(NC)" |
| 90 | + @act -W .github/workflows/ci.yml --job lint --container-architecture $(CONTAINER_ARCH) |
| 91 | + @echo "" |
| 92 | + @echo "$(GREEN)✓ act completed successfully$(NC)" |
| 93 | + |
| 94 | +act-typecheck: check-docker ## Run only type-check job with act |
| 95 | + @echo "$(BLUE)Running type-check job...$(NC)" |
| 96 | + @act -W .github/workflows/ci.yml --job type-check --container-architecture $(CONTAINER_ARCH) |
| 97 | + @echo "" |
| 98 | + @echo "$(GREEN)✓ act completed successfully$(NC)" |
| 99 | + |
| 100 | +act-test: check-docker ## Run one test matrix with act (Python 3.11 + XGBoost 3.0.5) |
| 101 | + @echo "$(BLUE)Running test matrix (Python 3.11, XGBoost 3.0.5)...$(NC)" |
| 102 | + @echo "$(YELLOW)Memory usage: ~2GB$(NC)" |
| 103 | + @act -W .github/workflows/ci.yml --job test \ |
| 104 | + --matrix python-version:3.11 \ |
| 105 | + --matrix xgboost-version:3.0.5 \ |
| 106 | + --container-architecture $(CONTAINER_ARCH) |
| 107 | + @echo "" |
| 108 | + @echo "$(GREEN)✓ act completed successfully$(NC)" |
38 | 109 |
|
39 | 110 | act-list: ## List all available workflows and jobs |
40 | | - act -l |
| 111 | + @echo "$(BLUE)Available workflows and jobs:$(NC)" |
| 112 | + @act -l |
41 | 113 |
|
42 | 114 | # Utility commands |
43 | 115 | clean: ## Clean up build artifacts and caches |
44 | | - rm -rf build/ dist/ *.egg-info .pytest_cache .ruff_cache |
45 | | - find . -type d -name __pycache__ -exec rm -rf {} + |
| 116 | + @echo "$(BLUE)Cleaning build artifacts...$(NC)" |
| 117 | + @rm -rf build/ dist/ *.egg-info .pytest_cache .ruff_cache |
| 118 | + @find . -type d -name __pycache__ -exec rm -rf {} + |
| 119 | + @echo "$(GREEN)✓ Cleaned$(NC)" |
46 | 120 |
|
47 | 121 | install: ## Install dependencies |
48 | | - uv sync --dev |
| 122 | + @echo "$(BLUE)Installing dependencies...$(NC)" |
| 123 | + @uv sync --dev |
| 124 | + @echo "$(GREEN)✓ Dependencies installed$(NC)" |
49 | 125 |
|
50 | 126 | build: ## Build package |
51 | | - uv build |
| 127 | + @echo "$(BLUE)Building package...$(NC)" |
| 128 | + @uv build |
| 129 | + @echo "$(GREEN)✓ Package built$(NC)" |
52 | 130 |
|
53 | 131 | version: ## Show current version |
54 | 132 | @uv run python -c "from xbooster import __version__; print(f'xBooster v{__version__}')" |
0 commit comments