|
| 1 | +.PHONY: pr install lint type-check test integration-test proto-check clean help |
| 2 | + |
| 3 | +# Run all PR checks locally |
| 4 | +pr: install proto-check lint type-check test integration-test |
| 5 | + @echo "All PR checks passed!" |
| 6 | + |
| 7 | +# Install dependencies |
| 8 | +install: |
| 9 | + @echo "Installing dependencies..." |
| 10 | + uv sync --extra dev |
| 11 | + |
| 12 | +# Check if proto files need to be regenerated |
| 13 | +proto-check: |
| 14 | + @echo "Checking proto files..." |
| 15 | + uv run python scripts/generate_proto.py |
| 16 | + @if [ -n "$$(git status --porcelain 2>&1)" ]; then \ |
| 17 | + echo "Warning: Proto files have changes. Please review and commit:"; \ |
| 18 | + git status --porcelain; \ |
| 19 | + echo ""; \ |
| 20 | + echo "To see the diff, run: git diff"; \ |
| 21 | + exit 1; \ |
| 22 | + fi |
| 23 | + @echo "Proto files are up to date" |
| 24 | + |
| 25 | +# Run linter |
| 26 | +lint: |
| 27 | + @echo "Running Ruff linter..." |
| 28 | + uv tool run ruff check |
| 29 | + |
| 30 | +# Run type checker |
| 31 | +type-check: |
| 32 | + @echo "Running mypy type checker..." |
| 33 | + uv tool run mypy cadence/ |
| 34 | + |
| 35 | +# Run unit tests |
| 36 | +test: |
| 37 | + @echo "Running unit tests..." |
| 38 | + uv run pytest -v |
| 39 | + |
| 40 | +# Run integration tests |
| 41 | +integration-test: |
| 42 | + @echo "Running integration tests..." |
| 43 | + uv run pytest -v --integration-tests |
| 44 | + |
| 45 | +# Clean generated files and caches |
| 46 | +clean: |
| 47 | + @echo "Cleaning up..." |
| 48 | + find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true |
| 49 | + find . -type f -name "*.pyc" -delete 2>/dev/null || true |
| 50 | + find . -type d -name "*.egg-info" -exec rm -rf {} + 2>/dev/null || true |
| 51 | + |
| 52 | +# Show help |
| 53 | +help: |
| 54 | + @echo "Available targets:" |
| 55 | + @echo " make pr - Run all PR checks (recommended before submitting PR)" |
| 56 | + @echo " make install - Install dependencies" |
| 57 | + @echo " make proto-check - Check if proto files are up to date" |
| 58 | + @echo " make lint - Run Ruff linter" |
| 59 | + @echo " make type-check - Run mypy type checker" |
| 60 | + @echo " make test - Run unit tests" |
| 61 | + @echo " make integration-test - Run integration tests" |
| 62 | + @echo " make clean - Remove generated files and caches" |
| 63 | + @echo " make help - Show this help message" |
| 64 | + |
0 commit comments