-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
144 lines (115 loc) · 4.67 KB
/
Copy pathMakefile
File metadata and controls
144 lines (115 loc) · 4.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# Makefile for Blackbox Trading Robot
# ====================================
.PHONY: help install install-dev test lint format run-api run-cli docs docs-build clean db-start db-stop db-init db-logs
# Default target
.DEFAULT_GOAL := help
# Python interpreter
PYTHON := python3
VENV := .venv
BIN := $(VENV)/bin
# Colors for terminal output
BLUE := \033[0;34m
GREEN := \033[0;32m
YELLOW := \033[0;33m
NC := \033[0m # No Color
help: ## Show this help message
@echo "$(BLUE)Blackbox Trading Robot - Available Commands$(NC)"
@echo "============================================="
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "$(GREEN)%-15s$(NC) %s\n", $$1, $$2}'
# =============================================================================
# Installation
# =============================================================================
venv: ## Create virtual environment
@echo "$(BLUE)Creating virtual environment...$(NC)"
$(PYTHON) -m venv $(VENV)
@echo "$(GREEN)Virtual environment created at $(VENV)$(NC)"
install: venv ## Install production dependencies
@echo "$(BLUE)Installing production dependencies...$(NC)"
$(BIN)/pip install --upgrade pip
$(BIN)/pip install -r requirements.txt
$(BIN)/pip install -e .
@echo "$(GREEN)Installation complete!$(NC)"
install-dev: venv ## Install development dependencies
@echo "$(BLUE)Installing development dependencies...$(NC)"
$(BIN)/pip install --upgrade pip
$(BIN)/pip install -r requirements-dev.txt
$(BIN)/pip install -e .
$(BIN)/pre-commit install
@echo "$(GREEN)Development installation complete!$(NC)"
# =============================================================================
# Code Quality
# =============================================================================
test: ## Run tests with coverage
@echo "$(BLUE)Running tests...$(NC)"
$(BIN)/pytest
test-fast: ## Run tests without coverage
@echo "$(BLUE)Running tests (fast mode)...$(NC)"
$(BIN)/pytest --no-cov -q
lint: ## Check code with ruff
@echo "$(BLUE)Checking code with ruff...$(NC)"
$(BIN)/ruff check src/ tests/
$(BIN)/ruff format --check src/ tests/
format: ## Format code with ruff
@echo "$(BLUE)Formatting code...$(NC)"
$(BIN)/ruff check --fix src/ tests/
$(BIN)/ruff format src/ tests/
@echo "$(GREEN)Code formatted!$(NC)"
# =============================================================================
# Run Applications
# =============================================================================
run-api: ## Run the FastAPI server
@echo "$(BLUE)Starting API server at http://localhost:8000$(NC)"
$(BIN)/uvicorn blackbox.api.main:app --reload --host 0.0.0.0 --port 8000
run-cli: ## Run the CLI
@echo "$(BLUE)Running CLI...$(NC)"
$(BIN)/blackbox --help
# =============================================================================
# Documentation
# =============================================================================
docs: ## Serve documentation locally
@echo "$(BLUE)Starting documentation server at http://localhost:8001$(NC)"
$(BIN)/mkdocs serve -a localhost:8001
docs-build: ## Build documentation
@echo "$(BLUE)Building documentation...$(NC)"
$(BIN)/mkdocs build
@echo "$(GREEN)Documentation built in site/$(NC)"
# =============================================================================
# Database
# =============================================================================
db-start: ## Start PostgreSQL with Docker Compose
@echo "$(BLUE)Starting PostgreSQL...$(NC)"
docker-compose up -d db
@echo "$(GREEN)PostgreSQL started on port 5432$(NC)"
db-stop: ## Stop PostgreSQL
@echo "$(BLUE)Stopping PostgreSQL...$(NC)"
docker-compose down
@echo "$(GREEN)PostgreSQL stopped$(NC)"
db-init: ## Initialize database tables
@echo "$(BLUE)Initializing database...$(NC)"
$(BIN)/blackbox db init
@echo "$(GREEN)Database initialized$(NC)"
db-logs: ## Show PostgreSQL logs
docker-compose logs -f db
db-stats: ## Show database statistics
$(BIN)/blackbox db stats
# =============================================================================
# Maintenance
# =============================================================================
clean: ## Clean build artifacts
@echo "$(BLUE)Cleaning build artifacts...$(NC)"
rm -rf build/
rm -rf dist/
rm -rf *.egg-info/
rm -rf src/*.egg-info/
rm -rf .pytest_cache/
rm -rf .ruff_cache/
rm -rf htmlcov/
rm -rf site/
rm -rf .coverage
find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
find . -type f -name "*.pyc" -delete 2>/dev/null || true
@echo "$(GREEN)Clean complete!$(NC)"
clean-all: clean ## Clean everything including venv
@echo "$(YELLOW)Removing virtual environment...$(NC)"
rm -rf $(VENV)
@echo "$(GREEN)Full clean complete!$(NC)"