forked from cyberfabric/cyber-pilot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
154 lines (134 loc) · 5.41 KB
/
Makefile
File metadata and controls
154 lines (134 loc) · 5.41 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
149
150
151
152
153
154
# @cpt-algo:cpt-cypilot-spec-init-structure-change-infrastructure:p1
.PHONY: test test-verbose test-quick test-coverage validate validate-examples validate-feature validate-code validate-code-feature self-check vulture vulture-ci install install-pipx install-proxy clean help check-pytest check-pytest-cov check-pipx check-vulture check-versions update
PYTHON ?= python3
PIPX ?= pipx
CPT ?= cpt
PYTEST_PIPX ?= $(PIPX) run --spec pytest pytest
PYTEST_PIPX_COV ?= $(PIPX) run --spec pytest-cov pytest
VULTURE_PIPX ?= $(PIPX) run --spec vulture vulture
VULTURE_MIN_CONF ?= 0
# Default target
help:
@echo "Cypilot Makefile"
@echo ""
@echo "Available targets:"
@echo " make test - Run all tests"
@echo " make test-verbose - Run tests with verbose output"
@echo " make test-quick - Run fast tests only (skip slow integration tests)"
@echo " make test-coverage - Run tests with coverage report"
@echo " make validate-examples - Validate requirements examples under examples/requirements"
@echo " make validate - Validate core methodology spec"
@echo " make self-check - Validate SDLC examples against their templates"
@echo " make check-versions - Check version consistency across components"
@echo " make vulture - Scan python code for dead code (report only, does not fail)"
@echo " make vulture-ci - Scan python code for dead code (fails if findings)"
@echo " make install - Install Python dependencies"
@echo " make install-proxy - Reinstall cpt proxy from local source"
@echo " make update - Update .bootstrap from local source"
@echo " make clean - Remove Python cache files"
@echo " make help - Show this help message"
# Run all tests
check-pipx:
@command -v $(PIPX) >/dev/null 2>&1 || { \
echo ""; \
echo "ERROR: pipx not found"; \
echo ""; \
echo "Install it with:"; \
echo " brew install pipx"; \
echo " pipx ensurepath"; \
echo ""; \
exit 1; \
}
check-pytest: check-pipx
@$(PYTEST_PIPX) --version >/dev/null 2>&1 || { \
echo ""; \
echo "ERROR: pytest is not runnable via pipx"; \
echo ""; \
echo "Install it with:"; \
echo " make install"; \
echo ""; \
exit 1; \
}
check-pytest-cov: check-pytest
@$(PYTEST_PIPX_COV) --help 2>/dev/null | grep -q -- '--cov' || { \
echo ""; \
echo "ERROR: pytest-cov not available (missing --cov option)"; \
echo ""; \
echo "Install it with:"; \
echo " make install"; \
echo ""; \
exit 1; \
}
check-vulture: check-pipx
@$(VULTURE_PIPX) --version >/dev/null 2>&1 || { \
echo ""; \
echo "ERROR: vulture is not runnable via pipx"; \
echo ""; \
echo "Install it with:"; \
echo " pipx install vulture"; \
echo "or just run: make vulture (pipx run will download it)"; \
echo ""; \
exit 1; \
}
test: check-pytest
@echo "Running Cypilot tests with pipx..."
$(PYTEST_PIPX) tests/ -v --tb=short
# Run tests with verbose output
test-verbose: check-pytest
@echo "Running Cypilot tests (verbose) with pipx..."
$(PYTEST_PIPX) tests/ -vv
# Run quick tests only
test-quick: check-pytest
@echo "Running quick tests with pipx..."
$(PYTEST_PIPX) tests/ -v -m "not slow"
# Run tests with coverage
test-coverage: check-pytest-cov
@echo "Running tests with coverage..."
$(PYTEST_PIPX_COV) tests/ \
--cov=skills/cypilot/scripts/cypilot \
--cov-report=term-missing \
--cov-report=json:coverage.json \
--cov-report=html \
-v --tb=short
@$(PYTHON) scripts/check_coverage.py coverage.json --root skills/cypilot/scripts/cypilot --min 90
@echo ""
@echo "Coverage report generated:"
@echo " HTML: htmlcov/index.html"
@echo " Open with: open htmlcov/index.html"
vulture: check-vulture
@echo "Running vulture dead-code scan (excluding tests by scanning only skills/cypilot/scripts/cypilot)..."
@echo "Tip: raise/lower VULTURE_MIN_CONF to reduce false positives (current: $(VULTURE_MIN_CONF))."
@$(VULTURE_PIPX) skills/cypilot/scripts/cypilot vulture_whitelist.py --min-confidence $(VULTURE_MIN_CONF) || true
vulture-ci: check-vulture
@echo "Running vulture dead-code scan (CI mode, fails if findings)..."
$(VULTURE_PIPX) skills/cypilot/scripts/cypilot vulture_whitelist.py --min-confidence $(VULTURE_MIN_CONF)
# Check version consistency
check-versions:
@$(PYTHON) scripts/check_versions.py
# Update .bootstrap from local source
update:
$(CPT) update --source . --force
# Validate core methodology spec
validate:
$(CPT) validate --json
# Validate SDLC examples against templates
self-check:
@echo "Running self-check: validating SDLC examples against templates..."
$(CPT) self-check
# Install Python dependencies
install-pipx: check-pipx
@echo "Installing pytest + pytest-cov via pipx..."
@$(PIPX) install pytest >/dev/null 2>&1 || $(PIPX) upgrade pytest
@$(PIPX) inject pytest pytest-cov
@echo "Done. If pytest is not found, run: pipx ensurepath (then restart your shell)."
install: install-pipx
# Reinstall cpt/cypilot proxy from local source
install-proxy: check-pipx
$(PIPX) install --force .
# Clean Python cache
clean:
@echo "Cleaning Python cache files..."
find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
find . -type f -name "*.pyc" -delete
find . -type d -name ".pytest_cache" -exec rm -rf {} + 2>/dev/null || true
@echo "Clean complete"