-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
313 lines (289 loc) · 12.2 KB
/
Makefile
File metadata and controls
313 lines (289 loc) · 12.2 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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
# =============================================================================
# Makefile — Generic Test Runner & Development Tasks
# =============================================================================
# Designed to work with the CLAUDE.md testing framework (Section 5).
# Detects project language automatically. Override with: make test LANG=python
#
# Supported languages: python, typescript, go, rust
#
# Usage:
# make test Run full suite (all tiers, fail-fast)
# make test-unit Tier 1 — Unit tests only
# make test-integration Tier 2 — Integration tests only
# make test-agent Tier 3 — Agent behavior tests only
# make test-file FILE=x Run a single test file
# make test-coverage Full suite + coverage report
# make lint Run linter
# make fmt Run formatter
# make typecheck Run type checker
# make build Compile / build the project
# make check Lint + typecheck + full test suite (pre-PR gate)
# =============================================================================
# ---------------------------------------------------------------------------
# Language Detection (override with LANG=python|typescript|go|rust)
# ---------------------------------------------------------------------------
LANG ?= auto
ifeq ($(LANG),auto)
ifneq (,$(wildcard Cargo.toml))
DETECTED_LANG := rust
else ifneq (,$(wildcard go.mod))
DETECTED_LANG := go
else ifneq (,$(wildcard tsconfig.json))
DETECTED_LANG := typescript
else ifneq (,$(wildcard package.json))
DETECTED_LANG := typescript
else ifneq (,$(wildcard pyproject.toml setup.py setup.cfg requirements.txt))
DETECTED_LANG := python
else
DETECTED_LANG := python
endif
else
DETECTED_LANG := $(LANG)
endif
# ---------------------------------------------------------------------------
# Python Configuration
# ---------------------------------------------------------------------------
PYTHON_TEST_CMD := python -m pytest
PYTHON_UNIT_DIR := tests/unit
PYTHON_INT_DIR := tests/integration
PYTHON_AGENT_DIR := tests/agent
PYTHON_LINT_CMD := python -m ruff check .
PYTHON_FMT_CMD := python -m ruff format .
PYTHON_TYPE_CMD := python -m mypy .
PYTHON_BUILD_CMD := @echo "Python: no compilation needed"
PYTHON_COV_FLAGS := --cov --cov-report=term-missing --cov-report=html:coverage_html
PYTHON_FILE_CMD := python -m pytest
PYTHON_SETUP_CMD := python -m venv .venv && . .venv/bin/activate && pip install -e '.[dev]' 2>/dev/null || pip install -e .
# ---------------------------------------------------------------------------
# TypeScript Configuration
# ---------------------------------------------------------------------------
TS_TEST_CMD := npx vitest run
TS_UNIT_DIR := tests/unit
TS_INT_DIR := tests/integration
TS_AGENT_DIR := tests/agent
TS_LINT_CMD := npx eslint .
TS_FMT_CMD := npx eslint . --fix
TS_TYPE_CMD := npx tsc --noEmit
TS_BUILD_CMD := npx tsc
TS_COV_FLAGS := --coverage
TS_FILE_CMD := npx vitest run
TS_SETUP_CMD := npm install
# ---------------------------------------------------------------------------
# Go Configuration
# ---------------------------------------------------------------------------
GO_TEST_CMD := go test
GO_UNIT_DIR := ./tests/unit/...
GO_INT_DIR := ./tests/integration/...
GO_AGENT_DIR := ./tests/agent/...
GO_LINT_CMD := golangci-lint run
GO_FMT_CMD := gofmt -w .
GO_TYPE_CMD := @echo "Go: type checking included in build"
GO_BUILD_CMD := go build ./...
GO_COV_FLAGS := -coverprofile=coverage.out
GO_FILE_CMD := go test
GO_SETUP_CMD := go mod download
# ---------------------------------------------------------------------------
# Rust Configuration
# ---------------------------------------------------------------------------
RUST_TEST_CMD := cargo test
RUST_UNIT_DIR :=
RUST_INT_DIR :=
RUST_AGENT_DIR :=
RUST_LINT_CMD := cargo clippy -- -D warnings
RUST_FMT_CMD := cargo fmt
RUST_TYPE_CMD := @echo "Rust: type checking included in build"
RUST_BUILD_CMD := cargo build
RUST_COV_FLAGS :=
RUST_FILE_CMD := cargo test
RUST_SETUP_CMD := cargo fetch
# ---------------------------------------------------------------------------
# Resolve commands based on detected language
# ---------------------------------------------------------------------------
ifeq ($(DETECTED_LANG),python)
TEST_CMD := $(PYTHON_TEST_CMD)
UNIT_DIR := $(PYTHON_UNIT_DIR)
INT_DIR := $(PYTHON_INT_DIR)
AGENT_DIR := $(PYTHON_AGENT_DIR)
LINT_CMD := $(PYTHON_LINT_CMD)
FMT_CMD := $(PYTHON_FMT_CMD)
TYPE_CMD := $(PYTHON_TYPE_CMD)
BUILD_CMD := $(PYTHON_BUILD_CMD)
COV_FLAGS := $(PYTHON_COV_FLAGS)
FILE_CMD := $(PYTHON_FILE_CMD)
SETUP_CMD := $(PYTHON_SETUP_CMD)
else ifeq ($(DETECTED_LANG),typescript)
TEST_CMD := $(TS_TEST_CMD)
UNIT_DIR := $(TS_UNIT_DIR)
INT_DIR := $(TS_INT_DIR)
AGENT_DIR := $(TS_AGENT_DIR)
LINT_CMD := $(TS_LINT_CMD)
FMT_CMD := $(TS_FMT_CMD)
TYPE_CMD := $(TS_TYPE_CMD)
BUILD_CMD := $(TS_BUILD_CMD)
COV_FLAGS := $(TS_COV_FLAGS)
FILE_CMD := $(TS_FILE_CMD)
SETUP_CMD := $(TS_SETUP_CMD)
else ifeq ($(DETECTED_LANG),go)
TEST_CMD := $(GO_TEST_CMD)
UNIT_DIR := $(GO_UNIT_DIR)
INT_DIR := $(GO_INT_DIR)
AGENT_DIR := $(GO_AGENT_DIR)
LINT_CMD := $(GO_LINT_CMD)
FMT_CMD := $(GO_FMT_CMD)
TYPE_CMD := $(GO_TYPE_CMD)
BUILD_CMD := $(GO_BUILD_CMD)
COV_FLAGS := $(GO_COV_FLAGS)
FILE_CMD := $(GO_FILE_CMD)
SETUP_CMD := $(GO_SETUP_CMD)
else ifeq ($(DETECTED_LANG),rust)
TEST_CMD := $(RUST_TEST_CMD)
UNIT_DIR := $(RUST_UNIT_DIR)
INT_DIR := $(RUST_INT_DIR)
AGENT_DIR := $(RUST_AGENT_DIR)
LINT_CMD := $(RUST_LINT_CMD)
FMT_CMD := $(RUST_FMT_CMD)
TYPE_CMD := $(RUST_TYPE_CMD)
BUILD_CMD := $(RUST_BUILD_CMD)
COV_FLAGS := $(RUST_COV_FLAGS)
FILE_CMD := $(RUST_FILE_CMD)
SETUP_CMD := $(RUST_SETUP_CMD)
endif
# ---------------------------------------------------------------------------
# Common flags
# ---------------------------------------------------------------------------
VERBOSE ?=
ifeq ($(VERBOSE),1)
V_FLAG := -v
else
V_FLAG :=
endif
# ---------------------------------------------------------------------------
# Targets
# ---------------------------------------------------------------------------
.PHONY: test test-unit test-integration test-agent test-file test-coverage \
lint fmt typecheck build check setup setup-github help
## Run full test suite: unit → integration → agent (fail-fast)
## For Rust: cargo test runs all tests; tiers are filtered by test name prefix
test:
@echo "═══ Running Full Test Suite ($(DETECTED_LANG)) ═══"
ifeq ($(DETECTED_LANG),rust)
@echo "--- Running all Rust tests ---"
@$(TEST_CMD) $(V_FLAG) || (echo "❌ Tests failed." && exit 1)
else
@echo "--- Tier 1: Unit Tests ---"
@$(TEST_CMD) $(UNIT_DIR) $(V_FLAG) || (echo "❌ Unit tests failed — stopping." && exit 1)
@echo "--- Tier 2: Integration Tests ---"
@$(TEST_CMD) $(INT_DIR) $(V_FLAG) || (echo "❌ Integration tests failed — stopping." && exit 1)
@echo "--- Tier 3: Agent Behavior Tests ---"
@$(TEST_CMD) $(AGENT_DIR) $(V_FLAG) || (echo "❌ Agent behavior tests failed — stopping." && exit 1)
endif
@echo "✅ All tiers passed."
## Tier 1: Unit tests only
test-unit:
@echo "--- Tier 1: Unit Tests ($(DETECTED_LANG)) ---"
ifeq ($(DETECTED_LANG),rust)
$(TEST_CMD) --lib $(V_FLAG)
else
$(TEST_CMD) $(UNIT_DIR) $(V_FLAG)
endif
## Tier 2: Integration tests only
test-integration:
@echo "--- Tier 2: Integration Tests ($(DETECTED_LANG)) ---"
ifeq ($(DETECTED_LANG),rust)
$(TEST_CMD) --test '*' $(V_FLAG)
else
$(TEST_CMD) $(INT_DIR) $(V_FLAG)
endif
## Tier 3: Agent behavior tests only
test-agent:
@echo "--- Tier 3: Agent Behavior Tests ($(DETECTED_LANG)) ---"
ifeq ($(DETECTED_LANG),rust)
$(TEST_CMD) --test 'agent_*' $(V_FLAG)
else
$(TEST_CMD) $(AGENT_DIR) $(V_FLAG)
endif
## Run a single test file (usage: make test-file FILE=tests/unit/test_foo.py)
test-file:
ifndef FILE
@echo "Usage: make test-file FILE=path/to/test_file"
@exit 1
endif
$(FILE_CMD) $(FILE) $(V_FLAG)
## Full suite with coverage report
test-coverage:
@echo "═══ Running Full Suite + Coverage ($(DETECTED_LANG)) ═══"
ifeq ($(DETECTED_LANG),rust)
$(TEST_CMD) $(COV_FLAGS) $(V_FLAG)
else
$(TEST_CMD) $(UNIT_DIR) $(INT_DIR) $(AGENT_DIR) $(COV_FLAGS) $(V_FLAG)
endif
## Run linter
lint:
@echo "--- Linting ($(DETECTED_LANG)) ---"
$(LINT_CMD)
## Run formatter
fmt:
@echo "--- Formatting ($(DETECTED_LANG)) ---"
$(FMT_CMD)
## Run type checker
typecheck:
@echo "--- Type Checking ($(DETECTED_LANG)) ---"
$(TYPE_CMD)
## Compile / build the project
build:
@echo "--- Building ($(DETECTED_LANG)) ---"
$(BUILD_CMD)
## Pre-PR gate: lint + typecheck + full test suite
check: lint typecheck test
@echo "✅ All checks passed — ready for PR."
## Bootstrap dev environment: install deps, set up pre-commit
setup:
@echo "═══ Setting up development environment ($(DETECTED_LANG)) ═══"
@echo "--- Installing dependencies ---"
$(SETUP_CMD)
@if [ -f .pre-commit-config.yaml ]; then \
echo "--- Setting up pre-commit hooks ---"; \
pre-commit install 2>/dev/null || echo "⚠️ pre-commit not found — install with: pip install pre-commit"; \
fi
@echo ""
@echo "✅ Setup complete. Run 'make check' to verify everything works."
## Set up GitHub labels and project management
setup-github:
@echo "═══ Setting up GitHub project management ═══"
@echo "Creating labels..."
@gh label create "bug" --color "d73a4a" --description "Something isn't working" --force 2>/dev/null || true
@gh label create "feature" --color "0075ca" --description "New feature or enhancement" --force 2>/dev/null || true
@gh label create "task" --color "0e8a16" --description "Development task or chore" --force 2>/dev/null || true
@gh label create "chore" --color "e4e669" --description "Maintenance or cleanup" --force 2>/dev/null || true
@gh label create "refactor" --color "d4c5f9" --description "Code restructuring, no behavior change" --force 2>/dev/null || true
@gh label create "P0-critical" --color "b60205" --description "Drop everything" --force 2>/dev/null || true
@gh label create "P1-high" --color "d93f0b" --description "Fix this sprint" --force 2>/dev/null || true
@gh label create "P2-medium" --color "fbca04" --description "Plan for next sprint" --force 2>/dev/null || true
@gh label create "P3-low" --color "c5def5" --description "Nice to have" --force 2>/dev/null || true
@gh label create "needs-triage" --color "f9d0c4" --description "Needs review and prioritization" --force 2>/dev/null || true
@gh label create "ready" --color "0e8a16" --description "Ready to be picked up" --force 2>/dev/null || true
@gh label create "blocked" --color "b60205" --description "Waiting on external dependency" --force 2>/dev/null || true
@gh label create "in-progress" --color "1d76db" --description "Currently being worked on" --force 2>/dev/null || true
@echo "✅ Labels created"
## Show available targets
help:
@echo "Available targets:"
@echo " make test Full suite (unit → integration → agent, fail-fast)"
@echo " make test-unit Tier 1 — Unit tests"
@echo " make test-integration Tier 2 — Integration tests"
@echo " make test-agent Tier 3 — Agent behavior tests"
@echo " make test-file FILE=x Single test file"
@echo " make test-coverage Full suite + coverage report"
@echo " make lint Run linter"
@echo " make fmt Run formatter"
@echo " make typecheck Run type checker"
@echo " make build Compile / build"
@echo " make check Lint + typecheck + full suite (pre-PR gate)"
@echo " make setup Bootstrap dev environment (deps + pre-commit)"
@echo " make setup-github Create GitHub labels (requires gh CLI)"
@echo ""
@echo "Options:"
@echo " LANG=python|typescript|go|rust Override language detection"
@echo " VERBOSE=1 Verbose test output"
@echo ""
@echo "Detected language: $(DETECTED_LANG)"