Makefileโข6.49 kB
# MCP Server Development Makefile
# Provides easy commands for development, testing, and quality assurance
.PHONY: help install test lint format security coverage clean all
# Default target
help:
	@echo "๐ MCP Server Development Commands"
	@echo "=================================="
	@echo ""
	@echo "Setup Commands:"
	@echo "  make install     - Install all dependencies"
	@echo "  make setup-dev   - Setup development environment"
	@echo ""
	@echo "Quality Assurance:"
	@echo "  make test        - Run all tests"
	@echo "  make lint        - Run all linting checks"
	@echo "  make format      - Format code with black and isort"
	@echo "  make security    - Run security checks"
	@echo "  make coverage    - Run tests with coverage report"
	@echo "  make verify-tools - Verify tool registry and VS Code parity"
	@echo ""
	@echo "CI/CD:"
	@echo "  make ci          - Run full CI pipeline"
	@echo "  make pre-commit  - Run pre-commit checks"
	@echo ""
	@echo "Maintenance:"
	@echo "  make clean       - Clean temporary files"
	@echo "  make all         - Run complete quality pipeline"
# Installation and setup
install:
	@echo "๐ฆ Installing dependencies..."
	pip install --upgrade pip
	pip install -r requirements.txt
	pip install pytest pytest-asyncio pytest-cov flake8 black isort pylint mypy bandit psutil
setup-dev: install
	@echo "๐ง Setting up development environment..."
	# Setup git hooks
	cp pre_commit_hook.py .git/hooks/pre-commit
	chmod +x .git/hooks/pre-commit
	@echo "โ
 Development environment ready!"
# Testing
test:
	@echo "๐งช Running tests..."
	python3 -m pytest test_kotlin_mcp_server.py -v
test-quick:
	@echo "โก Running quick tests..."
	python3 -m pytest test_kotlin_mcp_server.py -v --tb=short
coverage:
	@echo "๐ Running tests with coverage..."
	python3 -m pytest test_*.py -v --cov=. --cov-report=html --cov-report=term-missing --cov-fail-under=70
	@echo "๐ Coverage report generated in htmlcov/"
# Code quality
lint:
	@echo "๐ Running linting checks..."
	flake8 *.py --count --select=E9,F63,F7,F82 --show-source --statistics
	flake8 *.py --count --exit-zero --max-complexity=12 --max-line-length=100 --statistics
	pylint *.py --output-format=text --reports=yes --score=yes || echo "โ ๏ธ  Pylint completed with warnings"
	mypy *.py --ignore-missing-imports || echo "โ ๏ธ  MyPy completed with warnings"
format:
	@echo "๐จ Formatting code..."
	black *.py
	isort *.py
	@echo "โ
 Code formatted!"
format-check:
	@echo "๐จ Checking code formatting..."
	black --check --diff *.py
	isort --check-only --diff *.py
security:
	@echo "๐ Running security checks..."
	bandit -r *.py -f txt
	safety check || echo "โ ๏ธ  Safety check completed"
# Tool verification
verify-tools:
	@echo "๐ง Verifying tool registry and VS Code parity..."
	python3 scripts/verify_tools.py --strict
	python3 scripts/vscode_parity_check.py
	@echo "โ
 Tool verification completed"
# CI/CD
ci:
	@echo "๐ Running full CI pipeline..."
	python3 ci_test_runner.py
pre-commit:
	@echo "๐ Running pre-commit checks..."
	python3 pre_commit_hook.py
# Functionality validation
validate:
	@echo "โ
 Validating MCP server functionality..."
	python3 -c "from kotlin_mcp_server import MCPServer; print('โ
 Main server OK')"
# Performance testing
perf:
	@echo "โก Running performance tests..."
	python3 -c "import asyncio; import time; import tempfile; from pathlib import Path; from kotlin_mcp_server import MCPServer; \
	async def perf_test(): \
		server = MCPServer('perf-test'); \
		server.project_path = Path(tempfile.mkdtemp()); \
		start = time.time(); \
		for _ in range(10): await server.handle_list_tools(); \
		duration = time.time() - start; \
		print(f'โ
 10x tool listing: {duration:.3f}s ({duration/10:.3f}s avg)'); \
		import shutil; shutil.rmtree(server.project_path, ignore_errors=True); \
	asyncio.run(perf_test())"
# Maintenance
clean:
	@echo "๐งน Cleaning up..."
	rm -rf __pycache__/
	rm -rf .pytest_cache/
	rm -rf .coverage
	rm -rf htmlcov/
	rm -rf .mypy_cache/
	rm -rf build/
	rm -rf dist/
	rm -rf *.egg-info/
	find . -name "*.pyc" -delete
	find . -name "*.pyo" -delete
	find . -name "*~" -delete
	@echo "โ
 Cleanup complete!"
# Development workflow
dev-check: format-check lint test-quick validate
	@echo "๐ Development checks completed!"
# Complete quality pipeline
all: clean format lint security test coverage validate perf
	@echo "๐ Complete quality assurance pipeline completed!"
# Release preparation
release-prep: all
	@echo "๐ Preparing for release..."
	@echo "๐ Release checklist:"
	@echo "  โ
 Code formatted and linted"
	@echo "  โ
 All tests passing"
	@echo "  โ
 Security checks passed"
	@echo "  โ
 Coverage requirements met"
	@echo "  โ
 Functionality validated"
	@echo "  โ
 Performance verified"
	@echo ""
	@echo "๐ฏ Ready for deployment!"
# Android E2E Workflow
sidecar:
	@echo "๐จ Building Kotlin sidecar..."
	cd kotlin-sidecar && ./gradlew shadowJar
	@echo "โ
 Sidecar JAR built at: kotlin-sidecar/build/libs/kotlin-sidecar.jar"
e2e:
	@echo "๏ฟฝ Running E2E Android app generation..."
	python e2e_test.py e2e/sampleapp
	@echo "โ
 E2E generation complete. Check e2e/sampleapp/ for results."
fix:
	@echo "๐ง Formatting and optimizing code..."
	python3 -m black *.py
	python3 -m isort *.py
	@echo "โ
 Code formatting complete"
detekt:
	@echo "๐ Running detekt analysis..."
	./gradlew detekt
spotless:
	@echo "๐จ Running spotless check..."
	./gradlew spotlessCheck
# Android-specific CI
ci-android: sidecar e2e
	@echo "๐ค Android CI simulation complete."
# Help for specific commands
help-ci:
	@echo "๐ Continuous Integration Pipeline"
	@echo "================================="
	@echo "The CI pipeline runs the following checks:"
	@echo "1. Code formatting (black, isort)"
	@echo "2. Linting (flake8, pylint, mypy)"
	@echo "3. Security scanning (bandit, safety)"
	@echo "4. Unit tests (pytest)"
	@echo "5. Coverage analysis"
	@echo "6. Functionality validation"
	@echo "7. Performance testing"
	@echo ""
	@echo "Usage: make ci"
help-dev:
	@echo "๐ป Development Workflow"
	@echo "======================"
	@echo "Recommended development workflow:"
	@echo "1. make setup-dev       (first time only)"
	@echo "2. <make changes>"
	@echo "3. make dev-check       (quick validation)"
	@echo "4. <commit changes>     (pre-commit hook runs automatically)"
	@echo "5. make ci              (full validation before push)"
	@echo ""
	@echo "For releases: make release-prep"