-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
129 lines (106 loc) · 4.73 KB
/
Makefile
File metadata and controls
129 lines (106 loc) · 4.73 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
.PHONY: help format lint typecheck test test-type-checks regenerate-schemas pre-push ci-local clean install-dev check-schema-drift
# Detect Python and use venv if available
PYTHON := $(shell if [ -f .venv/bin/python ]; then echo .venv/bin/python; else echo python3; fi)
PIP := $(shell if [ -f .venv/bin/pip ]; then echo .venv/bin/pip; else echo pip3; fi)
PYTEST := $(shell if [ -f .venv/bin/pytest ]; then echo .venv/bin/pytest; else echo pytest; fi)
BLACK := $(shell if [ -f .venv/bin/black ]; then echo .venv/bin/black; else echo black; fi)
RUFF := $(shell if [ -f .venv/bin/ruff ]; then echo .venv/bin/ruff; else echo ruff; fi)
MYPY := $(shell if [ -f .venv/bin/mypy ]; then echo .venv/bin/mypy; else echo mypy; fi)
help: ## Show this help message
@echo 'Usage: make [target]'
@echo ''
@echo 'Available targets:'
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}'
install-dev: ## Install package in development mode with dev dependencies
$(PIP) install -e ".[dev]"
format: ## Format code with black (excludes generated files)
$(BLACK) src/ tests/ scripts/
@echo "✓ Code formatted successfully (_generated.py excluded via pyproject.toml)"
lint: ## Run linter (ruff) on source code
$(RUFF) check src/ tests/
@echo "✓ Linting passed"
typecheck: ## Run type checker (mypy) on source code
$(MYPY) src/adcp/
@echo "✓ Type checking passed"
test: ## Run test suite with coverage
$(PYTEST) tests/ -v --cov=src/adcp --cov-report=term-missing
@echo "✓ All tests passed"
test-fast: ## Run tests without coverage (faster)
$(PYTEST) tests/ -v
@echo "✓ All tests passed"
test-type-checks: ## Run adopter-pattern type-check suite (mypy --strict, zero type: ignore allowed)
$(MYPY) --strict tests/type_checks/
@echo "✓ Adopter type-checks passed"
test-generation: ## Run only code generation tests
$(PYTEST) tests/test_code_generation.py -v
@echo "✓ Code generation tests passed"
regenerate-registry: ## Regenerate registry types from OpenAPI spec
@echo "Generating registry types from OpenAPI spec..."
$(PYTHON) scripts/generate_registry_types.py
@echo "✓ Registry types regenerated"
regenerate-schemas: ## Download latest schemas and skills from bundle, then regenerate models
@echo "Downloading latest schemas and skills..."
$(PYTHON) scripts/sync_schemas.py
@echo "Fixing schema references..."
$(PYTHON) scripts/fix_schema_refs.py
@echo "Bundling schemas into package..."
$(PYTHON) scripts/bundle_schemas.py
@echo "Generating Pydantic models..."
$(PYTHON) scripts/generate_types.py
@echo "Consolidating exports..."
$(PYTHON) scripts/consolidate_exports.py
@echo "Generating ergonomic coercion..."
$(PYTHON) scripts/generate_ergonomic_coercion.py
@echo "✓ Schemas regenerated successfully"
validate-generated: ## Validate generated code (syntax and imports)
@echo "Validating generated code..."
@$(PYTHON) -m py_compile src/adcp/types/_generated.py
@echo "✓ Generated code validation passed"
pre-push: format lint typecheck test validate-generated ## Run all checks before pushing (format, lint, typecheck, test, validate)
@echo ""
@echo "================================"
@echo "✓ All pre-push checks passed!"
@echo "================================"
@echo ""
@echo "Safe to push to remote."
ci-local: lint typecheck test validate-generated ## Run CI checks locally (without formatting)
@echo ""
@echo "================================"
@echo "✓ All CI checks passed!"
@echo "================================"
clean: ## Clean generated files and caches
rm -rf build/
rm -rf dist/
rm -rf *.egg-info
rm -rf .pytest_cache/
rm -rf .mypy_cache/
rm -rf .ruff_cache/
rm -rf .coverage
rm -rf htmlcov/
find . -type d -name __pycache__ -exec rm -rf {} +
find . -type f -name "*.pyc" -delete
@echo "✓ Cleaned all generated files and caches"
build: ## Build distribution packages
$(PYTHON) scripts/bundle_schemas.py
python -m build
@echo "✓ Distribution packages built"
# Development workflow commands
quick-check: lint test-fast ## Quick check (lint + fast tests) for rapid iteration
@echo "✓ Quick check passed"
full-check: pre-push ## Alias for pre-push (full check before committing)
# Schema workflow
check-schema-drift: ## Check if schemas are out of sync with upstream
@echo "Checking for schema drift..."
@$(PYTHON) scripts/sync_schemas.py --no-skills
@$(PYTHON) scripts/fix_schema_refs.py
@$(PYTHON) scripts/generate_types.py
@if git diff --exit-code src/adcp/types/_generated.py schemas/cache/; then \
echo "✓ Schemas are up-to-date"; \
else \
echo "✗ Schemas are out of date!"; \
echo "Run: make regenerate-schemas"; \
git diff src/adcp/types/_generated.py; \
exit 1; \
fi
# Help users understand what to run
.DEFAULT_GOAL := help