-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
148 lines (120 loc) · 4.96 KB
/
Copy pathMakefile
File metadata and controls
148 lines (120 loc) · 4.96 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
# QUALITY GATES AUTOMATION - ENTERPRISE GRADE
.PHONY: help install quality test coverage lint type-check complexity doc-coverage format clean all
# Colors for output
RED = \033[0;31m
GREEN = \033[0;32m
YELLOW = \033[1;33m
BLUE = \033[0;34m
NC = \033[0m # No Color
help: ## Show this help message
@echo "$(BLUE)Quality Gates Automation$(NC)"
@echo "========================="
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "$(YELLOW)%-20s$(NC) %s\n", $$1, $$2}'
install: ## Install all dependencies
@echo "$(BLUE)Installing dependencies...$(NC)"
pip install --upgrade pip
pip install -r requirements.txt
@echo "$(GREEN)✓ Dependencies installed$(NC)"
# ==================== QUALITY GATES ====================
quality: ## Run all quality checks (FAIL FAST)
@echo "$(BLUE)Running comprehensive quality gates...$(NC)"
@$(MAKE) format-check
@$(MAKE) lint
@$(MAKE) type-check
@$(MAKE) complexity
@$(MAKE) doc-coverage
@$(MAKE) test
@echo "$(GREEN)✓ ALL QUALITY GATES PASSED$(NC)"
test: ## Run tests with coverage enforcement (≥80%)
@echo "$(BLUE)Running tests with coverage enforcement...$(NC)"
pytest tests/ --cov=src --cov-fail-under=80 --cov-report=term-missing --cov-report=html
@echo "$(GREEN)✓ Tests passed with ≥80% coverage$(NC)"
coverage: ## Generate detailed coverage report
@echo "$(BLUE)Generating coverage report...$(NC)"
pytest tests/ --cov=src --cov-report=html --cov-report=term-missing
@echo "$(YELLOW)Coverage report: htmlcov/index.html$(NC)"
lint: ## Run pylint with strict rules
@echo "$(BLUE)Running pylint...$(NC)"
pylint src/ --fail-under=8.0 --rcfile=pyproject.toml
@echo "$(GREEN)✓ Pylint passed$(NC)"
type-check: ## Run mypy type checking
@echo "$(BLUE)Running mypy type checking...$(NC)"
mypy src/ --config-file=pyproject.toml --strict
@echo "$(GREEN)✓ Type checking passed$(NC)"
complexity: ## Check code complexity (CC ≤ 10, MI > B)
@echo "$(BLUE)Checking code complexity...$(NC)"
radon cc src/ --min B --show-complexity --average
radon mi src/ --min B --show
xenon src/ --max-absolute B --max-modules A --max-average A
@echo "$(GREEN)✓ Complexity within limits$(NC)"
doc-coverage: ## Check documentation coverage (≥90%)
@echo "$(BLUE)Checking documentation coverage...$(NC)"
interrogate src/ --fail-under 90 --verbose 2
@echo "$(GREEN)✓ Documentation coverage ≥90%$(NC)"
format: ## Format code with black and isort
@echo "$(BLUE)Formatting code...$(NC)"
black src/ tests/
isort src/ tests/
@echo "$(GREEN)✓ Code formatted$(NC)"
format-check: ## Check if code is properly formatted
@echo "$(BLUE)Checking code formatting...$(NC)"
black --check src/ tests/
isort --check-only src/ tests/
@echo "$(GREEN)✓ Code formatting is correct$(NC)"
# ==================== PERFORMANCE GATES ====================
performance-test: ## Run performance tests with thresholds
@echo "$(BLUE)Running performance tests...$(NC)"
pytest tests/test_performance.py -v --tb=short
@echo "$(GREEN)✓ Performance tests passed$(NC)"
benchmark: ## Run benchmarks
@echo "$(BLUE)Running benchmarks...$(NC)"
pytest tests/ -k "benchmark" --benchmark-only --benchmark-sort=mean
@echo "$(GREEN)✓ Benchmarks completed$(NC)"
# ==================== INTEGRATION TESTS ====================
integration: ## Run integration tests
@echo "$(BLUE)Running integration tests...$(NC)"
pytest tests/test_integration*.py -v --tb=short
@echo "$(GREEN)✓ Integration tests passed$(NC)"
property: ## Run property-based tests
@echo "$(BLUE)Running property-based tests...$(NC)"
pytest tests/ -m property -v --tb=short
@echo "$(GREEN)✓ Property-based tests passed$(NC)"
# ==================== CONTINUOUS QUALITY ====================
pre-commit: ## Run all checks before commit
@echo "$(BLUE)Pre-commit quality checks...$(NC)"
@$(MAKE) format
@$(MAKE) quality
@echo "$(GREEN)✓ Ready for commit$(NC)"
ci: ## Continuous Integration checks
@echo "$(BLUE)CI Quality Pipeline...$(NC)"
@$(MAKE) install
@$(MAKE) quality
@$(MAKE) integration
@$(MAKE) performance-test
@echo "$(GREEN)✓ CI Pipeline passed$(NC)"
# ==================== CLEANUP ====================
clean: ## Clean generated files
@echo "$(BLUE)Cleaning generated files...$(NC)"
rm -rf htmlcov/
rm -rf .coverage
rm -rf coverage.xml
rm -rf .pytest_cache/
rm -rf .mypy_cache/
rm -rf __pycache__/
find . -name "*.pyc" -delete
find . -name "__pycache__" -delete
@echo "$(GREEN)✓ Cleanup completed$(NC)"
# ==================== DEVELOPMENT ====================
dev-setup: ## Setup development environment
@echo "$(BLUE)Setting up development environment...$(NC)"
@$(MAKE) install
@$(MAKE) format
@echo "$(GREEN)✓ Development environment ready$(NC)"
quick-check: ## Quick quality check (fast)
@echo "$(BLUE)Quick quality check...$(NC)"
black --check src/ tests/
mypy src/ --config-file=pyproject.toml
pytest tests/ --cov=src --cov-fail-under=80 -q
@echo "$(GREEN)✓ Quick check passed$(NC)"
# Default target
all: quality ## Run all quality checks (default)