forked from driosalido/mcp-karma
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
148 lines (112 loc) · 5.01 KB
/
Copy pathMakefile
File metadata and controls
148 lines (112 loc) · 5.01 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
# Makefile for Karma MCP Server
.PHONY: help install test test-unit test-integration test-all lint type-check coverage clean docker docker-build docker-run
# Default target
.DEFAULT_GOAL := help
# Variables
PYTHON := python
UV := uv
DOCKER_IMAGE := driosalido/karma-mcp
DOCKER_TAG := latest
help: ## Show this help message
@echo "Karma MCP Server - Available commands:"
@echo ""
@awk 'BEGIN {FS = ":.*##"} /^[a-zA-Z_-]+:.*##/ {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
install: ## Install dependencies
$(UV) pip install -e ".[test]"
install-dev: ## Install development dependencies
$(UV) pip install -e ".[test]"
@echo "✅ Development dependencies installed"
test: ## Run all tests
$(PYTHON) scripts/run_tests.py --verbose
test-unit: ## Run only unit tests
$(PYTHON) scripts/run_tests.py --unit --verbose
test-integration: ## Run only integration tests (requires KARMA_URL)
$(PYTHON) scripts/run_tests.py --integration --verbose --karma-url $(KARMA_URL)
test-with-karma: ## Run integration tests with local Karma
$(PYTHON) scripts/run_tests.py --integration --verbose --karma-url http://localhost:8080
test-all: ## Run all tests with coverage
$(PYTHON) scripts/run_tests.py --all --coverage --verbose
coverage: ## Generate coverage report
$(PYTHON) -m pytest --cov=src/karma_mcp --cov-report=html --cov-report=term-missing
@echo "📊 Coverage report generated in htmlcov/"
lint: ## Run linting checks
$(PYTHON) scripts/run_tests.py --lint
type-check: ## Run type checking
$(PYTHON) scripts/run_tests.py --type-check
format: ## Format code (if ruff is available)
@if command -v ruff >/dev/null 2>&1; then \
ruff format src/ tests/; \
echo "✅ Code formatted"; \
else \
echo "⚠️ ruff not found - install with: pip install ruff"; \
fi
check: ## Run all checks (lint, type-check, test)
$(PYTHON) scripts/run_tests.py --all --verbose
# Test individual components
test-mcp-tools: ## Test MCP tools specifically
$(PYTHON) -m pytest tests/unit/test_mcp_tools.py -v
test-http-server: ## Test HTTP server specifically
$(PYTHON) -m pytest tests/unit/test_http_server.py -v
test-e2e: ## Test end-to-end functionality
$(PYTHON) -m pytest tests/integration/test_http_server_e2e.py -v
# Manual testing
test-manual: ## Run manual test scripts
@echo "Running manual tests..."
KARMA_URL=http://localhost:8080 $(UV) run python tests/manual/test_mcp_tools.py
KARMA_URL=http://localhost:8080 $(UV) run python tests/manual/test_state_filtering.py
# Development helpers
serve-local: ## Run HTTP server locally for testing
KARMA_URL=http://localhost:8080 $(UV) run python -m karma_mcp.http_server
serve-mcp: ## Run MCP server locally for testing
KARMA_URL=http://localhost:8080 $(UV) run python -m karma_mcp.server
debug-karma: ## Debug Karma API responses
KARMA_URL=http://localhost:8080 $(UV) run python tests/manual/debug_data.py
# Docker commands
docker-build: ## Build Docker image
docker buildx build --platform linux/amd64,linux/arm64 -t $(DOCKER_IMAGE):$(DOCKER_TAG) -f docker/Dockerfile . --push
docker-run: ## Run Docker image locally
docker run --rm -p 8080:8080 -e KARMA_URL=http://localhost:8080 $(DOCKER_IMAGE):$(DOCKER_TAG)
docker-test: ## Test Docker image
docker run --rm $(DOCKER_IMAGE):$(DOCKER_TAG) python -m pytest tests/unit/ -v
# Kubernetes/Helm commands
helm-install: ## Install Helm chart (requires kubectl context)
helm install karma-mcp ./helm/karma-mcp -f helm/karma-mcp/values-teddy.yaml -n monitoring
helm-upgrade: ## Upgrade Helm chart
helm upgrade karma-mcp ./helm/karma-mcp -f helm/karma-mcp/values-teddy.yaml -n monitoring
helm-uninstall: ## Uninstall Helm chart
helm uninstall karma-mcp -n monitoring
# Cleanup
clean: ## Clean up generated files
rm -rf htmlcov/
rm -rf .coverage
rm -rf .pytest_cache/
find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
find . -type f -name "*.pyc" -delete
@echo "🧹 Cleaned up generated files"
clean-docker: ## Clean up Docker images
docker image prune -f
@echo "🐳 Docker images cleaned"
# CI/CD helpers
ci-test: ## Run tests in CI environment
$(PYTHON) -m pytest --cov=src/karma_mcp --cov-report=xml --cov-report=term-missing -v
validate-config: ## Validate configuration files
@echo "Validating pyproject.toml..."
@$(PYTHON) -c "import tomllib; tomllib.load(open('pyproject.toml', 'rb'))" && echo "✅ pyproject.toml is valid"
@echo "Validating Helm charts..."
@helm lint ./helm/karma-mcp/ && echo "✅ Helm chart is valid"
# Documentation
docs: ## Generate documentation (placeholder)
@echo "📚 Documentation generation not yet implemented"
# Quick development workflow
dev-setup: install-dev ## Set up development environment
@echo "🚀 Development environment ready!"
@echo ""
@echo "Next steps:"
@echo " make test-unit # Run unit tests"
@echo " make serve-local # Start local server"
@echo " make test-manual # Run manual tests"
# Show current version
version: ## Show current version
@echo "Karma MCP Server"
@grep version pyproject.toml | head -1
@echo "Docker image: $(DOCKER_IMAGE):$(DOCKER_TAG)"