-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
269 lines (223 loc) Β· 9.78 KB
/
Copy pathMakefile
File metadata and controls
269 lines (223 loc) Β· 9.78 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
.PHONY: all build build-worker build-export-worker run test lint clean docker docker-up docker-down migrate web check coverage quality pre-commit gen-tesla gen-tesla-check arch-baseline arch-check generate generate-check ai-vet ai-eval-fast ai-eval-full ai-eval-judged tidy fmt vet web-typecheck web-test-fast verify verify-full verify-smoke replay-fixture
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
BUILD_TIME ?= $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
LDFLAGS := -s -w -X main.version=$(VERSION) -X main.commit=$(COMMIT) -X main.buildTime=$(BUILD_TIME)
all: build build-worker build-export-worker
## build: Build the Go backend binary
build:
CGO_ENABLED=0 go build -ldflags="$(LDFLAGS)" -o bin/teslasync ./cmd/teslasync
## build-worker: Build the notification worker binary
build-worker:
CGO_ENABLED=0 go build -ldflags="$(LDFLAGS)" -o bin/notification-worker ./cmd/notification-worker
## build-export-worker: Build the export worker binary
build-export-worker:
CGO_ENABLED=0 go build -ldflags="$(LDFLAGS)" -o bin/export-worker ./cmd/export-worker
## run: Run the backend locally
run:
go run -ldflags="$(LDFLAGS)" ./cmd/teslasync
## test: Run all Go tests
test:
go test -race -coverprofile=coverage.out ./...
## lint: Run golangci-lint
lint:
golangci-lint run ./...
## check: Run all quality checks (lint + test + vet)
check: lint test
go vet ./...
@echo "All checks passed β"
## quality: Full quality pipeline (Go + frontend lint + tests)
quality: lint test web-lint web-test
go vet ./...
@echo "Full quality pipeline passed β"
## web-test: Run frontend tests
web-test:
cd web && npx vitest run --reporter=dot
## pre-commit: Install pre-commit hooks
pre-commit:
pip install pre-commit
pre-commit install
pre-commit install --hook-type pre-push
@echo "Pre-commit hooks installed β"
## coverage: Generate HTML coverage report
coverage:
go test -race -coverprofile=coverage.out ./...
go tool cover -html=coverage.out -o coverage.html
@echo "Coverage report: coverage.html"
## clean: Remove build artifacts
clean:
rm -rf bin/ coverage.out web/dist web/node_modules
## web-install: Install frontend dependencies
web-install:
cd web && npm ci
## web-dev: Start frontend dev server
web-dev:
cd web && npm run dev
## web-build: Build frontend for production
web-build:
cd web && npm run build
## web-lint: Lint frontend code
web-lint:
cd web && npm run lint
## docker: Build all Docker images
docker:
docker compose build
## docker-up: Start all services with Docker Compose
docker-up:
docker compose up -d
## docker-dev: Start full dev stack (all services + Jaeger tracing)
docker-dev:
docker compose -f docker-compose.dev.yml up --build -d
## docker-down: Stop all services
docker-down:
docker compose down
## docker-logs: Tail logs from all services
docker-logs:
docker compose logs -f
## helm-install: Install Helm chart to current k8s context
helm-install:
helm upgrade --install teslasync helm/teslasync
## helm-uninstall: Uninstall Helm chart
helm-uninstall:
helm uninstall teslasync
## gen-tesla: Regenerate Tesla protomodel sources from the vendored proto
gen-tesla:
go generate ./internal/tesla/protomodel/...
## gen-tesla-check: Fail if generated Tesla protomodel sources drift from the proto
gen-tesla-check: gen-tesla
@if ! git diff --quiet -- internal/tesla/protomodel/; then \
echo "ERROR: generated files are out of sync with proto"; \
git --no-pager diff -- internal/tesla/protomodel/; \
exit 1; \
fi
## arch-baseline: Refresh the architecture metrics baseline (JSON + Markdown)
arch-baseline:
go run ./tools/archmetrics > tools/archmetrics/baseline.json
go run ./tools/archmetrics -report > tools/archmetrics/baseline.md
## arch-check: Fail if architecture regresses against the committed baseline
arch-check:
go run ./tools/archmetrics -compare tools/archmetrics/baseline.json
## generate: Regenerate cross-language artefacts (TS mirror of the AI feature registry).
## Phase-50 / 0001 β F0 AI-Off Contract. Adding a new AI
## feature in internal/ai/features/registry.go MUST be
## followed by `make generate` so web/src/ai/features.ts
## stays in sync. CI fails on drift via `make generate-check`.
generate:
go run ./tools/aigen
## generate-check: Fail if generated artefacts drift from their generators.
## Registry-driven (scripts/generated-artifacts.json): runs the
## non-mutating --check form of every generator AND proves the
## worktree is byte-identical afterwards, so a "check" can never
## quietly rewrite a committed source file.
generate-check:
go run ./tools/aigen --check
node scripts/check-generated-freshness.mjs
## ai-vet: Phase-50 / 0001 β enforce the AI-Off Contract at the
## type-system level (registry coverage + every /api/v1/ai/*
## route mounted via guard.Wrap). Run by CI on every PR.
ai-vet:
go run ./tools/aivet
## ai-eval-fast: Phase-50 / 0007 β F6 eval harness, fast mode.
## Runs every goldens.yaml under internal/ai/strategies
## with the canned mock provider only. Zero network egress.
## Used by PR CI as an advisory gate.
ai-eval-fast:
go run ./cmd/ai-eval --all
## ai-eval-full: Phase-50 / 0007 β F6 eval harness, full mode.
## Same coverage as ai-eval-fast but emits a JUnit XML
## artifact for the main-branch CI to publish + diff
## pass-rate. Still 100% offline (no real provider).
ai-eval-full:
go run ./cmd/ai-eval --all --output ai-eval.junit.xml
## ai-eval-judged: Phase-50 / 0007 β F6 eval harness, LLM-as-judge mode.
## Re-scores each canned answer using an LLM judge
## (seed=42, temperature=0). Requires JUDGE_PROVIDER +
## JUDGE_API_KEY env vars; nightly CI use only.
ai-eval-judged:
go run ./cmd/ai-eval --all --judge --output ai-eval.judged.junit.xml
# βββ Phase A2.3 verification tier βββββββββββββββββββββββββββββββββββββββ
# Three tiers of green-or-fail gates designed to make per-slice
# iteration cheap and per-batch iteration safe. Use them as follows:
#
# make verify β run before every commit (per-slice gate; ~30-60s)
# make verify-full β run before every push (per-batch gate; ~3-5 min)
# make verify-smoke β run before tagging release (per-track gate; ~10 min)
#
# Each tier is a STRICT superset of the previous one. A passing
# verify-full implies verify; a passing verify-smoke implies verify-full.
# If you can't recall which one to run, run `verify-full`.
#
# These targets are pure compositions β the work itself lives in the
# leaf targets (lint / vet / test / web-typecheck / arch-check / etc).
# That makes each leaf reusable from CI and from per-package iteration
# (e.g. `make vet` alone, or `cd internal/whatever && go test`).
## tidy: Run `go mod tidy` to canonicalise go.mod / go.sum
tidy:
go mod tidy
## fmt: Auto-format Go (gofmt) and frontend (ESLint --fix)
## Does NOT fail on unfixable issues β that's what `lint` is for.
## Run before `verify` to clean up easy diff noise.
fmt:
gofmt -s -w .
cd web && npx eslint . --fix --max-warnings 0 || true
## vet: Run `go vet` over the whole module
## Already implied by `lint` (golangci-lint enables govet), but
## exposed as its own target for fast local iteration when
## chasing a single govet failure.
vet:
go vet ./...
## web-typecheck: Run `tsc --noEmit` over the frontend
## Separate target so per-slice loops can skip the
## slower 24-audit lint chain when only types changed.
web-typecheck:
cd web && npx tsc --noEmit
## web-test-fast: Run Vitest in non-watch, non-coverage mode (fast)
## Used by `verify`. `web-test` (existing target) is
## the canonical full run with reporter=dot.
web-test-fast:
cd web && npx vitest run --reporter=dot --passWithNoTests
## verify: FAST per-slice gate (~30-60s)
## lint + vet + short tests + web typecheck + web lint chain
## Run this before EVERY commit. Skips: -race, arch-check,
## ai-vet, generate-check, docker, replay.
verify: lint vet web-typecheck web-lint
go test ./... -short -count=1
@echo "verify β"
## verify-full: BATCH per-push gate (~3-5 min)
## Strict superset of `verify`. Adds: -race, arch-check,
## ai-vet, generate-check, web tests.
## Run this before EVERY push.
verify-full: verify
go test -race ./...
$(MAKE) arch-check
$(MAKE) ai-vet
$(MAKE) generate-check
$(MAKE) gen-tesla-check
$(MAKE) web-test-fast
@echo "verify-full β"
## verify-smoke: TRACK per-release gate (~10 min)
## Strict superset of `verify-full`. Adds: docker-up,
## health-wait, signal-log replay fixture, docker-down.
## Run this before tagging a release.
## NOTE: Requires Docker Desktop running. NOT run by CI on
## every push β too slow. Run locally before release.
verify-smoke: verify-full
$(MAKE) docker-up
@echo "Waiting 45s for services to become healthyβ¦"
@sleep 45 || powershell -NoProfile -Command "Start-Sleep -Seconds 45"
$(MAKE) replay-fixture
$(MAKE) docker-down
@echo "verify-smoke β"
## replay-fixture: Replay a canned signal_log fixture against the live
## dev stack. Used by verify-smoke. Implementation lives
## in scripts/ (added in Phase D1); placeholder for now.
replay-fixture:
@if [ -x scripts/replay-fixture.sh ]; then \
scripts/replay-fixture.sh; \
else \
echo "scripts/replay-fixture.sh not present (Phase D1); skipping"; \
fi
## help: Show this help message
help:
@echo "Available targets:"
@grep -E '^## ' Makefile | sed 's/## / /'