-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
181 lines (138 loc) · 5.82 KB
/
Copy pathMakefile
File metadata and controls
181 lines (138 loc) · 5.82 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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
.PHONY: help install install-dev clean test test-unit test-integration test-e2e test-all
.PHONY: lint format type-check quality coverage pre-push
.PHONY: docker-up docker-down docker-logs docker-clean
.PHONY: dbt-run dbt-test dbt-docs dbt-clean
.PHONY: ingest-binance ingest-kraken ingest-now
.PHONY: api api-dev
.PHONY: docs demo
.DEFAULT_GOAL := help
# Colors for output
BLUE := \033[0;34m
GREEN := \033[0;32m
YELLOW := \033[0;33m
RED := \033[0;31m
NC := \033[0m # No Color
##@ General
help: ## Display this help
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make $(BLUE)<target>$(NC)\n"} /^[a-zA-Z_-]+:.*?##/ { printf " $(BLUE)%-20s$(NC) %s\n", $$1, $$2 } /^##@/ { printf "\n$(YELLOW)%s$(NC)\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
##@ Development Setup
install: ## Install production dependencies with uv
@echo "$(GREEN)Installing production dependencies...$(NC)"
uv pip install -e .
install-dev: ## Install development dependencies with uv
@echo "$(GREEN)Installing development dependencies...$(NC)"
uv pip install -e ".[dev]"
pre-commit install
clean: ## Clean build artifacts and cache
@echo "$(YELLOW)Cleaning build artifacts...$(NC)"
rm -rf build/ dist/ *.egg-info
rm -rf .pytest_cache .coverage htmlcov coverage.xml
rm -rf .mypy_cache .ruff_cache
find . -type d -name __pycache__ -exec rm -rf {} +
find . -type f -name "*.pyc" -delete
##@ Testing
test: test-unit ## Run unit tests (default)
test-unit: ## Run unit tests only (no Docker required)
@echo "$(GREEN)Running unit tests...$(NC)"
pytest -m unit -v
test-integration: ## Run integration tests (requires Docker)
@echo "$(GREEN)Running integration tests...$(NC)"
pytest -m integration -v
test-e2e: ## Run end-to-end tests
@echo "$(GREEN)Running end-to-end tests...$(NC)"
pytest -m e2e -v
test-all: ## Run all tests
@echo "$(GREEN)Running all tests...$(NC)"
pytest -v
coverage: ## Generate test coverage report
@echo "$(GREEN)Generating coverage report...$(NC)"
pytest --cov=src/refdata --cov-report=html --cov-report=term
@echo "$(GREEN)Coverage report generated: htmlcov/index.html$(NC)"
##@ Code Quality
lint: ## Run ruff linter
@echo "$(GREEN)Running ruff linter...$(NC)"
ruff check src/ tests/
format: ## Format code with black and isort
@echo "$(GREEN)Formatting code...$(NC)"
black src/ tests/
isort src/ tests/
ruff check --fix src/ tests/
type-check: ## Run mypy type checker
@echo "$(GREEN)Running mypy type checker...$(NC)"
mypy src/refdata
quality: lint type-check ## Run all quality checks
@echo "$(GREEN)All quality checks passed!$(NC)"
pre-push: ## Run all pre-push checks (format, lint, type-check, unit tests)
@echo "$(GREEN)Running pre-push checks...$(NC)"
@./scripts/pre-push-checks.sh
##@ Docker Infrastructure
docker-up: ## Start all Docker services
@echo "$(GREEN)Starting Docker services...$(NC)"
docker compose -f infrastructure/compose/docker-compose.refdata.yml up -d
@echo "$(GREEN)Services started. Waiting for health checks...$(NC)"
@sleep 5
docker compose -f infrastructure/compose/docker-compose.refdata.yml ps
docker-down: ## Stop all Docker services
@echo "$(YELLOW)Stopping Docker services...$(NC)"
docker compose -f infrastructure/compose/docker-compose.refdata.yml down
docker-logs: ## Tail Docker service logs
docker compose -f infrastructure/compose/docker-compose.refdata.yml logs -f
docker-clean: docker-down ## Stop services and remove volumes
@echo "$(RED)Removing Docker volumes...$(NC)"
docker compose -f infrastructure/compose/docker-compose.refdata.yml down -v
@echo "$(YELLOW)All volumes removed$(NC)"
##@ DBT
dbt-run: ## Run DBT models
@echo "$(GREEN)Running DBT transformations...$(NC)"
cd dbt && dbt run --profiles-dir .
dbt-test: ## Run DBT tests
@echo "$(GREEN)Running DBT tests...$(NC)"
cd dbt && dbt test --profiles-dir .
dbt-docs: ## Generate DBT documentation
@echo "$(GREEN)Generating DBT documentation...$(NC)"
cd dbt && dbt docs generate --profiles-dir .
cd dbt && dbt docs serve --profiles-dir . --port 8080
dbt-clean: ## Clean DBT artifacts
cd dbt && dbt clean
##@ Ingestion
ingest-binance: ## Run Binance ingestion job
@echo "$(GREEN)Ingesting Binance data...$(NC)"
python -m refdata.cli.ingest --source binance
ingest-kraken: ## Run Kraken ingestion job
@echo "$(GREEN)Ingesting Kraken data...$(NC)"
python -m refdata.cli.ingest --source kraken
ingest-now: ## Run all ingestion jobs immediately
@echo "$(GREEN)Running all ingestion jobs...$(NC)"
python -m refdata.cli.ingest --source all
##@ API
api: ## Start FastAPI production server
@echo "$(GREEN)Starting FastAPI server...$(NC)"
uvicorn refdata.api.main:app --host 0.0.0.0 --port 8001
api-dev: ## Start FastAPI development server with auto-reload
@echo "$(GREEN)Starting FastAPI development server...$(NC)"
uvicorn refdata.api.main:app --host 0.0.0.0 --port 8001 --reload
##@ Documentation
docs: ## Build all documentation
@echo "$(GREEN)Building documentation...$(NC)"
@echo "$(BLUE)ADRs:$(NC) docs/architecture/ADR-*.md"
@echo "$(BLUE)API Docs:$(NC) http://localhost:8001/docs (start API first)"
@echo "$(BLUE)DBT Docs:$(NC) Run 'make dbt-docs' to view"
demo: ## Run end-to-end demo
@echo "$(GREEN)Running end-to-end demo...$(NC)"
@echo "$(BLUE)1. Starting services...$(NC)"
@make docker-up
@echo "$(BLUE)2. Running ingestion...$(NC)"
@make ingest-now
@echo "$(BLUE)3. Running DBT transformations...$(NC)"
@make dbt-run
@echo "$(BLUE)4. Starting API...$(NC)"
@echo "$(YELLOW)API available at: http://localhost:8001$(NC)"
@make api
##@ Initialization
init-infra: ## Initialize infrastructure (Iceberg catalog, Schema Registry)
@echo "$(GREEN)Initializing infrastructure...$(NC)"
python scripts/init_iceberg_catalog.py
python scripts/register_schemas.py
@echo "$(GREEN)Infrastructure initialized!$(NC)"
setup: install-dev docker-up init-infra ## Complete first-time setup
@echo "$(GREEN)Setup complete! Run 'make demo' to test the platform.$(NC)"