forked from DRYTRIX/TimeTracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
221 lines (181 loc) Β· 5.69 KB
/
Copy pathMakefile
File metadata and controls
221 lines (181 loc) Β· 5.69 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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
# TimeTracker Makefile
# Common development and testing tasks
.PHONY: help install test test-smoke test-unit test-integration test-security test-coverage \
test-fast test-parallel lint format clean docker-build docker-run setup dev security-scan frontend-a11y
# Default target
help:
@echo "TimeTracker Development Commands"
@echo "================================="
@echo ""
@echo "Setup:"
@echo " make setup - Install all dependencies"
@echo " make dev - Setup development environment"
@echo ""
@echo "Testing:"
@echo " make test - Run full test suite"
@echo " make test-smoke - Run smoke tests (< 1 min)"
@echo " make test-unit - Run unit tests (2-5 min)"
@echo " make test-integration - Run integration tests"
@echo " make test-routes - Run route/endpoint tests"
@echo " make test-models - Run model tests"
@echo " make test-api - Run API tests"
@echo " make test-security - Run security tests"
@echo " make test-database - Run database tests"
@echo " make test-coverage - Run tests with 50% coverage requirement"
@echo " make test-coverage-report - Generate coverage report (no minimum)"
@echo " make test-fast - Run tests in parallel"
@echo " make test-parallel - Run tests with 4 workers"
@echo " make test-failed - Re-run last failed tests"
@echo ""
@echo "Code Quality:"
@echo " make lint - Run linters (flake8)"
@echo " make format - Format code (black + isort)"
@echo " make format-check - Check code formatting"
@echo " make security-scan - Run security scanners"
@echo " make frontend-a11y - Run accessibility check on web app (requires app running; set FRONTEND_URL)"
@echo ""
@echo "Docker:"
@echo " make docker-build - Build Docker image"
@echo " make docker-run - Run Docker container"
@echo " make docker-test - Test Docker container"
@echo ""
@echo "Cleanup:"
@echo " make clean - Clean temporary files"
@echo " make clean-all - Clean everything including deps"
# Setup and installation
install:
pip install -r requirements.txt
dev:
pip install -r requirements.txt
pip install -r requirements-test.txt
setup: dev
@echo "Development environment ready!"
@echo "Run 'make test-smoke' to verify setup"
# Testing targets
test:
pytest -v
test-smoke:
pytest -m smoke -v
test-unit:
pytest -m unit -v
test-integration:
pytest -m integration -v
test-security:
bash scripts/ci/security-pytest.sh
test-database:
pytest -m database -v
test-routes:
pytest -m routes -v
test-models:
pytest -m models -v
test-api:
pytest -m api -v
test-coverage:
pytest --cov=app --cov-report=html --cov-report=term-missing --cov-report=xml --cov-fail-under=50
@echo "Coverage report: htmlcov/index.html"
test-coverage-report:
pytest --cov=app --cov-report=html --cov-report=term-missing
@echo "Coverage report: htmlcov/index.html"
@echo "Note: No minimum coverage threshold enforced"
test-fast:
pytest -n auto -v
test-parallel:
pytest -n 4 -v
test-failed:
pytest --lf -v
test-debug:
pytest -v --tb=long --pdb
# Code quality targets
lint:
@echo "Running flake8..."
flake8 app/ --count --select=E9,F63,F7,F82 --show-source --statistics
flake8 app/ --count --max-complexity=10 --max-line-length=120 --statistics
format:
@echo "Running black..."
black app/
@echo "Running isort..."
isort app/
format-check:
@echo "Checking black..."
black --check app/
@echo "Checking isort..."
isort --check-only app/
security-scan:
@echo "Running bandit..."
bandit -r app/
@echo "Running safety..."
safety check --file requirements.txt
# Frontend quality: accessibility check (requires app running at FRONTEND_URL, default http://localhost:3000)
FRONTEND_URL ?= http://localhost:3000
frontend-a11y:
@echo "Accessibility check: $(FRONTEND_URL)"
@command -v npx >/dev/null 2>&1 || { echo "npx not found; install Node.js or run: npx pa11y $(FRONTEND_URL)"; exit 0; }
npx --yes pa11y "$(FRONTEND_URL)" 2>/dev/null || echo "Run: npx pa11y $(FRONTEND_URL) (start app first). See docs/development/FRONTEND_QUALITY_GATES.md"
# Docker targets
docker-build:
docker build -t timetracker:latest .
docker-run:
docker run -d --name timetracker \
-p 8080:8080 \
-e DATABASE_URL="sqlite:///test.db" \
-e SECRET_KEY="dev-secret" \
timetracker:latest
docker-test:
docker build -t timetracker:test .
docker run --rm timetracker:test pytest -m smoke
docker-stop:
docker stop timetracker || true
docker rm timetracker || true
# Database targets
db-migrate:
flask db migrate
db-upgrade:
flask db upgrade
db-downgrade:
flask db downgrade
# Cleanup targets
clean:
find . -type f -name '*.pyc' -delete
find . -type d -name '__pycache__' -delete
find . -type d -name '*.egg-info' -exec rm -rf {} +
rm -rf htmlcov/
rm -rf .pytest_cache/
rm -rf .coverage
rm -rf coverage.xml
rm -rf *.db
rm -rf dist/
rm -rf build/
clean-all: clean
rm -rf venv/
rm -rf .venv/
find . -type f -name '*.log' -delete
# Development server
run:
python app.py
run-dev:
FLASK_ENV=development FLASK_DEBUG=1 python app.py
# CI/CD simulation
ci-local:
@echo "Simulating CI pipeline locally..."
@echo "1. Running smoke tests..."
make test-smoke
@echo "2. Running unit tests..."
make test-unit
@echo "3. Running code quality checks..."
make lint
make format-check
@echo "4. Running security scan..."
make security-scan
@echo "β Local CI checks passed!"
# Install pre-commit hooks
hooks:
@echo "Installing pre-commit hooks..."
@which pre-commit > /dev/null || pip install pre-commit
pre-commit install
@echo "Pre-commit hooks installed!"
# Documentation
docs:
@echo "Documentation files:"
@echo " - CI_CD_QUICK_START.md"
@echo " - CI_CD_DOCUMENTATION.md"
@echo " - CI_CD_IMPLEMENTATION_SUMMARY.md"