-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
86 lines (76 loc) · 3.09 KB
/
Makefile
File metadata and controls
86 lines (76 loc) · 3.09 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
# ctm Makefile — UI build, Go build, and dev orchestration.
#
# Step 8 scope: `make ui` produces the React bundle and copies it into
# internal/serve/dist/ so Go can //go:embed it (sibling required because
# go:embed rejects parent-relative paths).
UI_DIR := ui
UI_DIST := $(UI_DIR)/dist
EMBED_DIST := internal/serve/dist
# V19 slice 3 requires SQLite FTS5. mattn/go-sqlite3 compiles FTS5 in
# only when the sqlite_fts5 build tag is set; applied to every go
# build / test / install invocation below. Binaries built without it
# will panic at boot on "no such module: fts5".
GO_TAGS := sqlite_fts5
.PHONY: ui build dev clean help e2e regression
help:
@echo "Targets:"
@echo " ui — install + build React UI, sync to $(EMBED_DIST)"
@echo " build — make ui && go build ./..."
@echo " dev — pnpm --prefix ui dev + go run . serve in parallel"
@echo " e2e — Playwright tests against vite preview, mocked API surface"
@echo " regression — full pre-merge pack: go build/test/race/vuln + ui tsc/vitest/audit/e2e"
@echo " clean — remove $(UI_DIST) and $(EMBED_DIST)"
ui:
@echo "==> pnpm install"
cd $(UI_DIR) && pnpm install --frozen-lockfile
@echo "==> vite build"
cd $(UI_DIR) && pnpm build
@echo "==> rsync $(UI_DIST)/ → $(EMBED_DIST)/"
mkdir -p $(EMBED_DIST)
rsync -a --delete $(UI_DIST)/ $(EMBED_DIST)/
build: ui
@echo "==> go build"
go build -trimpath -tags $(GO_TAGS) ./...
# Dev: run pnpm dev (Vite proxies to :37778) and go run . serve in parallel.
# Trap SIGINT so Ctrl-C tears down both.
dev:
@trap 'kill 0' INT TERM EXIT; \
pnpm --prefix $(UI_DIR) dev & \
go run . serve & \
wait
clean:
rm -rf $(UI_DIST) $(EMBED_DIST)
# Playwright E2E. Uses Chromium from ~/.cache/ms-playwright (installed via
# `pnpm exec playwright install chromium`). Mocks /api + /events at page
# level so tests don't need a running daemon or fixture DB. Run
# `pnpm --prefix ui exec playwright install chromium` once before first run.
e2e:
@echo "==> pnpm build (needed for vite preview)"
cd $(UI_DIR) && pnpm build
@echo "==> playwright test"
cd $(UI_DIR) && pnpm exec playwright test
# Unified regression pack. Runs everything a PR must clear before merge.
# Fails fast — first non-zero exit stops the run. Total wall time on this
# machine is ~60-90s depending on Go cache state.
#
# Contract: every shipped bug fix or new feature adds a test case that
# executes under one of these steps (unit / vitest / e2e). The pack grows;
# it does not get replaced. See ui/e2e/README.md.
regression:
@echo "==> go build ./..."
go build -tags $(GO_TAGS) ./...
@echo "==> go test ./..."
go test -tags $(GO_TAGS) ./...
@echo "==> go test -race ./internal/serve/..."
go test -race -tags $(GO_TAGS) ./internal/serve/...
@echo "==> govulncheck ./..."
govulncheck ./...
@echo "==> pnpm -C ui tsc --noEmit"
pnpm -C $(UI_DIR) exec tsc --noEmit
@echo "==> pnpm -C ui test (vitest)"
pnpm -C $(UI_DIR) test
@echo "==> pnpm audit (High/Critical fails; Medium/Low reported)"
cd $(UI_DIR) && pnpm audit --audit-level=high
@echo "==> make e2e"
$(MAKE) e2e
@echo "==> regression pack OK"