Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
171 lines (147 loc) · 5.45 KB
/
Copy pathMakefile
File metadata and controls
171 lines (147 loc) · 5.45 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
.PHONY: help test test-frontend test-e2e test-integration test-cleanup test-all \
js-resolvers lint lint-python lint-frontend lint-infra spellcheck typecheck \
format format-python format-frontend tflint kics all ci ci-full \
test-guards clean
# Default target
help:
@echo "KernelWorx - Build & Test Commands"
@echo ""
@echo "Testing:"
@echo " make test - Run Python unit tests (pytest)"
@echo " make test-frontend - Run TypeScript unit tests (vitest)"
@echo " make test-e2e - Run Python E2E smoke tests (pytest-playwright)"
@echo " make test-integration - Run integration tests"
@echo " make test-cleanup - Run TypeScript global cleanup only"
@echo " make test-all - Run all tests (unit + guards + frontend + integration + e2e + js-resolvers)"
@echo " make js-resolvers - Run AppSync JS resolver tests (node --test)"
@echo ""
@echo "Linting & Type Checking:"
@echo " make lint - Run all linters (Python + TypeScript)"
@echo " make lint-python - Run Python linters (ruff + mypy)"
@echo " make lint-frontend - Run TypeScript linters (eslint + tsc)"
@echo " make spellcheck - Run spell check across the repo"
@echo " make typecheck - Run type checkers (mypy + tsc)"
@echo ""
@echo "Formatting:"
@echo " make format - Format all code (Python + TypeScript)"
@echo " make format-python - Format Python code (ruff import sort + format)"
@echo " make format-frontend - Format TypeScript code (prettier)"
@echo ""
@echo "Infrastructure Scanning:"
@echo " make lint-infra - Run infrastructure checks (tflint + kics)"
@echo " make tflint - Run tflint on OpenTofu code"
@echo " make kics - Run KICS security scan"
@echo ""
@echo "Comprehensive:"
@echo " make all - Run everything (format + lint + typecheck + test + test-frontend)"
@echo " make ci - Run CI pipeline (lint + typecheck + spellcheck + test + test-frontend + test-guards + js-resolvers)"
@echo " make clean - Clean generated files"
# Python unit tests
test:
@echo "Running Python unit tests..."
uv run pytest tests/unit --cov=src --cov-fail-under=100 -v
# TypeScript unit tests
test-frontend:
@echo "Running TypeScript unit tests..."
cd frontend && npm run test:coverage
# Python E2E smoke tests (pytest-playwright)
test-e2e:
@echo "Running Python E2E smoke tests..."
uv run pytest tests/e2e/ -v
# Integration tests
test-integration:
@echo "Running integration tests..."
cd tests/integration && npm run test
# TypeScript cleanup only (reuses integration globalTeardown)
test-cleanup:
@echo "Running TypeScript cleanup..."
cd tests/integration && npm run cleanup
# TypeScript guard tests (resolver static checks + sanitize unit tests)
test-guards:
@echo "Running TypeScript guard tests..."
npm run test:guards
# AppSync JS resolver tests (node --test)
js-resolvers:
@echo "Running AppSync JS resolver tests..."
npm run test:js-resolvers
# Run all tests
test-all: test test-guards test-frontend test-integration test-e2e js-resolvers
# Python linting and type checking
lint-python:
@echo "Running mypy..."
uv run mypy src/
@echo "Running ruff check..."
uv run ruff check src/ tests/
# TypeScript linting and type checking
lint-frontend:
@echo "Running eslint..."
cd frontend && npm run lint
@echo "Running TypeScript type check..."
cd frontend && npm run typecheck
# Spell check across the repository
spellcheck:
@echo "Running cspell..."
frontend/node_modules/.bin/cspell --config cspell.json .
# All linting
lint: lint-python lint-frontend
# Type checking only
typecheck:
@echo "Running mypy..."
uv run mypy src/
@echo "Running TypeScript type check..."
cd frontend && npm run typecheck
# Format Python code
format-python:
@echo "Formatting Python code..."
uv run ruff check --select I --fix src/ tests/
uv run ruff format src/ tests/
# Format TypeScript code
format-frontend:
@echo "Formatting TypeScript code..."
cd frontend && npm run format
# Format all code
format: format-python format-frontend
# Run tflint on infrastructure code
tflint:
@echo "Running tflint on OpenTofu code..."
cd tofu && tflint --init
cd tofu && tflint --recursive
# Run KICS security scan
kics:
@echo "Pulling KICS image..."
docker pull checkmarx/kics:v2.1.20
@echo "Running KICS security scan..."
@mkdir -p tofu/kics-results
docker run -t \
-v "$(PWD)/tofu":/path:ro,z \
-v "$(PWD)/tofu/kics-results":/results:z \
checkmarx/kics:v2.1.20 scan \
-p /path \
--config /path/.kics.yml \
--fail-on high,medium \
-o /results \
--report-formats json
@echo "KICS results saved to tofu/kics-results/"
# All infrastructure checks (linting only, no deployment)
lint-infra: tflint kics
# Run everything (development workflow)
all: format lint typecheck test test-frontend
# Local CI pipeline (no live AWS required)
ci: lint typecheck spellcheck test test-frontend test-guards js-resolvers
# Full CI pipeline including integration tests (requires AWS credentials)
ci-full: ci test-integration
# Clean generated files
clean:
@echo "Cleaning generated files..."
rm -rf htmlcov/
rm -rf .coverage
rm -rf .pytest_cache/
rm -rf .mypy_cache/
rm -rf .ruff_cache/
rm -rf frontend/coverage/
rm -rf frontend/playwright-report/
rm -rf frontend/test-results/
rm -rf tofu/kics-results/
find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
find . -type d -name ".vitest" -exec rm -rf {} + 2>/dev/null || true
@echo "Clean complete!"