-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathMakefile
More file actions
158 lines (133 loc) · 3.87 KB
/
Makefile
File metadata and controls
158 lines (133 loc) · 3.87 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
.PHONY: setup install dev test lint format type-check coverage clean docs serve-docs help
# Default target
help:
@echo "UCAI Development Commands"
@echo "================================"
@echo ""
@echo "Setup:"
@echo " make setup - Create virtual environment and install all dependencies"
@echo " make install - Install package in development mode"
@echo " make dev - Install with development dependencies"
@echo ""
@echo "Testing:"
@echo " make test - Run all tests"
@echo " make test-unit - Run unit tests only"
@echo " make test-int - Run integration tests only"
@echo " make coverage - Run tests with coverage report"
@echo ""
@echo "Code Quality:"
@echo " make lint - Run linter (ruff)"
@echo " make format - Format code (ruff format)"
@echo " make type-check - Run type checker (mypy)"
@echo " make check - Run all checks (lint + type-check + test)"
@echo ""
@echo "Documentation:"
@echo " make docs - Build documentation"
@echo " make serve-docs - Serve documentation locally"
@echo ""
@echo "Other:"
@echo " make clean - Remove build artifacts"
@echo " make build - Build package"
@echo " make publish - Publish to PyPI (requires credentials)"
# Python and pip
PYTHON := python3
PIP := $(PYTHON) -m pip
PYTEST := $(PYTHON) -m pytest
# Directories
SRC_DIR := src/abi_to_mcp
TEST_DIR := tests
DOCS_DIR := docs
# Setup virtual environment and install dependencies
setup:
@echo "Creating virtual environment..."
$(PYTHON) -m venv .venv
@echo "Activating and installing dependencies..."
. .venv/bin/activate && $(PIP) install --upgrade pip
. .venv/bin/activate && $(PIP) install -e ".[dev,docs]"
@echo ""
@echo "Setup complete! Activate with: source .venv/bin/activate"
# Install in development mode
install:
$(PIP) install -e .
# Install with dev dependencies
dev:
$(PIP) install -e ".[dev]"
# Run all tests
test:
$(PYTEST) $(TEST_DIR) -v
# Run unit tests only
test-unit:
$(PYTEST) $(TEST_DIR)/unit -v
# Run integration tests only
test-int:
$(PYTEST) $(TEST_DIR)/integration -v
# Run specific test file
test-file:
@if [ -z "$(FILE)" ]; then \
echo "Usage: make test-file FILE=tests/unit/test_parser/test_abi_parser.py"; \
else \
$(PYTEST) $(FILE) -v; \
fi
# Run tests with coverage
coverage:
$(PYTEST) $(TEST_DIR) --cov=$(SRC_DIR) --cov-report=html --cov-report=term-missing
@echo ""
@echo "Coverage report: htmlcov/index.html"
# Run linter
lint:
$(PYTHON) -m ruff check $(SRC_DIR) $(TEST_DIR)
# Fix linting issues automatically
lint-fix:
$(PYTHON) -m ruff check --fix $(SRC_DIR) $(TEST_DIR)
# Format code
format:
$(PYTHON) -m ruff format $(SRC_DIR) $(TEST_DIR)
# Check formatting without changing
format-check:
$(PYTHON) -m ruff format --check $(SRC_DIR) $(TEST_DIR)
# Run type checker
type-check:
$(PYTHON) -m mypy $(SRC_DIR)
# Run all checks
check: lint type-check test
@echo ""
@echo "All checks passed!"
# Build documentation
docs:
cd $(DOCS_DIR) && mkdocs build
# Serve documentation locally
serve-docs:
cd $(DOCS_DIR) && mkdocs serve
# Clean build artifacts
clean:
rm -rf build/
rm -rf dist/
rm -rf *.egg-info/
rm -rf .pytest_cache/
rm -rf .mypy_cache/
rm -rf .ruff_cache/
rm -rf htmlcov/
rm -rf .coverage
find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
find . -type f -name "*.pyc" -delete
# Build package
build: clean
$(PYTHON) -m build
# Publish to PyPI
publish: build
$(PYTHON) -m twine upload dist/*
# Run pre-commit hooks
pre-commit:
pre-commit run --all-files
# Install pre-commit hooks
pre-commit-install:
pre-commit install
# Generate a test MCP server (for development)
test-generate:
$(PYTHON) -m abi_to_mcp generate tests/fixtures/abis/erc20.json \
-o /tmp/test-erc20-mcp \
-a 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48 \
-n mainnet
@echo ""
@echo "Generated server at: /tmp/test-erc20-mcp"
@ls -la /tmp/test-erc20-mcp/