-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
219 lines (174 loc) · 7.94 KB
/
Copy pathMakefile
File metadata and controls
219 lines (174 loc) · 7.94 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
# ReadSync Makefile (all phases)
# Targets for building, running, and testing Phase 0 tools.
GOOS ?= windows
GOARCH ?= amd64
GOFLAGS = CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH)
.PHONY: all fixtures koreader-sim moon-recorder winsvc-spike vet clean help \
deps vet-phase1 test test-unit test-pipeline migrate-test build \
test-koreader run replay-koreader-live \
test-phase6 run-fakeserver test-e2e installer smoke-installer \
test-phase7-unit test-phase7-moon test-phase7-cgo \
test-security test-integration test-phase7
## help: Show this help message
help:
@echo "ReadSync Makefile (Phase 9 — all targets)"
@echo ""
@echo "Targets:"
@grep -E '^## ' Makefile | sed 's/## / /'
## all: Build all tools
all: koreader-sim moon-recorder winsvc-spike
## koreader-sim: Build KOReader sync simulator
koreader-sim:
cd tools/koreader-sim && go build -o koreader-sim.exe .
## moon-recorder: Build Moon+ fixture recorder
moon-recorder:
cd tools/moon-fixture-recorder && go build -o moon-fixture-recorder.exe .
## winsvc-spike: Build Windows service spike (Windows only)
winsvc-spike:
cd tools/winsvc-spike && $(GOFLAGS) go build -o readsync-spike.exe .
## fixtures: Generate synthetic fixture files
fixtures:
cd tools/generate-fixtures && go run . --root ../..
@echo "Synthetic fixtures generated in fixtures/moonplus/synthetic/"
## run-koreader-sim: Run KOReader simulator (port 7200)
run-koreader-sim:
cd tools/koreader-sim && go run . --port 7200 --verbose
## run-moon-recorder: Run Moon+ fixture recorder (port 8765)
run-moon-recorder:
cd tools/moon-fixture-recorder && \
go run . --port 8765 --verbose \
--capture-dir ../../fixtures/moonplus/captures
## replay-koreader: Run the KOReader curl replay script
replay-koreader:
bash fixtures/koreader/curl-replay.sh http://localhost:7200
## vet: Run go vet on all tools
vet:
go vet ./tools/koreader-sim/...
go vet ./tools/moon-fixture-recorder/...
go vet ./tools/winsvc-spike/...
go vet ./tools/generate-fixtures/...
## clean: Remove built binaries
clean:
rm -f tools/koreader-sim/koreader-sim.exe
rm -f tools/moon-fixture-recorder/moon-fixture-recorder.exe
rm -f tools/winsvc-spike/readsync-spike.exe
# ─── Phase 1 main module ─────────────────────────────────────────────────────
# NOTE: go-sqlite3 requires CGO. Install TDM-GCC on Windows:
# https://jmeubank.github.io/tdm-gcc/
# Then: make deps && make test
## deps: Download main module dependencies (run once after checkout)
deps:
go mod tidy
go mod download
## vet-phase1: Run go vet on Phase 1 main module
vet-phase1:
go vet ./cmd/... ./internal/...
## test: Run all Phase 1 tests (requires CGO+GCC for go-sqlite3)
test:
go test -v -count=1 -timeout 60s ./...
## test-unit: Run core pure unit tests (resolver, conflicts, logging, outbox, moon - no CGO)
test-unit:
go test -v -count=1 -timeout 30s \
./internal/resolver/... \
./internal/conflicts/... \
./internal/logging/...
## test-pipeline: Run end-to-end pipeline and migration tests (requires CGO)
test-e2e:
go test -v -count=1 -timeout 30s \
-run 'TestPipeline|TestMigrate' ./internal/core/...
# test-pipeline above (was test-e2e: - renamed to avoid conflict with Playwright test-e2e)
## test-pipeline: Run core pipeline tests (requires CGO) — replaces dead test-e2e at line 95
test-pipeline:
CGO_ENABLED=1 go test -v -count=1 -timeout 30s \
-run 'TestPipeline|TestMigrate' ./internal/core/...
## migrate-test: Apply DB migrations to a test database file
migrate-test:
@mkdir -p test-output
go run ./cmd/readsyncctl db migrate --db test-output/readsync-test.db
@echo "Schema verified at: test-output/readsync-test.db"
## build: Build all Phase 1 binaries (requires CGO)
build: deps vet-phase1
@mkdir -p bin
go build -o bin/readsync-service.exe ./cmd/readsync-service/
go build -o bin/readsyncctl.exe ./cmd/readsyncctl/
go build -o bin/readsync-tray.exe ./cmd/readsync-tray/
# ─── Phase 3 KOReader adapter ─────────────────────────────────────────────────
# NOTE: `make deps` must be run once before these targets work.
# Phase 3 added gin, x/crypto, x/time to go.mod. go.sum is committed
# run `make deps` to update after any go.mod change.
# See docs/phases/phase3-manifest.md for Phase 3 details.
## test-koreader: Run KOReader adapter integration tests (requires CGO)
test-koreader:
CGO_ENABLED=1 go test -v -count=1 -timeout 60s ./internal/adapters/koreader/...
## run: Start dev runner on 127.0.0.1:7200 (registration open, go run .)
run:
CGO_ENABLED=1 go run . --db readsync-dev.db
## replay-koreader-live: Replay KOSync curl fixtures against the live dev runner
## Start `make run` in another terminal first, then run this.
replay-koreader-live:
bash fixtures/koreader/curl-replay.sh http://localhost:7200
# ─── Phase 6 user-facing surface ─────────────────────────────────────────────
## test-phase6: Run Phase 6 unit tests (no CGO required).
test-phase6:
go test -count=1 -timeout 60s \
./internal/setup/... \
./internal/repair/... \
./internal/secrets/... \
./internal/api/... \
./cmd/readsync-tray/...
## run-fakeserver: Start the fake admin UI for Playwright E2E.
run-fakeserver:
go run ./tests/fakeserver -port 7201
## test-e2e: Run Playwright wizard suite (requires npm + chromium).
test-e2e:
cd tests && npm install && npx playwright install chromium && npx playwright test wizard.spec.js
## installer: Build binaries + invoke ISCC. Requires Inno Setup 6.
installer:
@mkdir -p bin
go build -ldflags="-H windowsgui" -o bin/readsync-tray.exe ./cmd/readsync-tray
go build -o bin/readsync-service.exe ./cmd/readsync-service
iscc installer/readsync.iss
## smoke-installer: Run the installer smoke test (admin PowerShell).
smoke-installer:
powershell -ExecutionPolicy Bypass -File installer/smoke.ps1 \
-Installer dist/ReadSync-0.6.0-setup.exe
# ─── Phase 7 QA & Hardening ──────────────────────────────────────────────────
## test-phase7-unit: Run Phase 7 pure-Go unit tests (no CGO required; run test-phase7-moon for moon).
## Note: CI phase7-unit also includes moon. Use test-phase7-moon or test-phase7 for moon tests locally.
test-phase7-unit:
go test -v -count=1 -timeout 60s \
./internal/resolver/... \
./internal/conflicts/... \
./internal/logging/... \
./internal/outbox/... \
./internal/setup/... \
./internal/repair/... \
./internal/secrets/... \
./internal/api/... \
./cmd/readsync-tray/... \
./tests/security/...
## test-phase7-pure-adapters: Run pure-Go adapter subpackage tests (no CGO).
## Covers: moon, calibre/opf (OPF parser), koreader/codec (wire codec).
test-phase7-moon:
go test -v -count=1 -timeout 30s \
./internal/adapters/moon/... \
./internal/adapters/calibre/opf/... \
./internal/adapters/koreader/codec/...
## NOTE: calibre and koreader need CGO - use test-phase7-cgo or test-integration
##
## test-phase7-cgo: Run Phase 7 CGO-required tests (calibre, koreader).
test-phase7-cgo:
CGO_ENABLED=1 go test -v -count=1 -timeout 60s \
./internal/adapters/calibre/... \
./internal/adapters/moon/... \
./internal/adapters/koreader/...
## test-security: Run security tests (no CGO required).
test-security:
go test -v -count=1 -timeout 30s ./tests/security/...
## test-integration: Run integration tests with fake adapters (CGO required).
test-integration:
CGO_ENABLED=1 go test -v -count=1 -timeout 60s ./tests/integration/...
## test-phase7: Run all Phase 7 pure-Go tests (unit + moon + security, no CGO required).
test-phase7: test-phase7-unit test-phase7-moon
@echo "Phase 7 unit + security tests complete."
@echo "Run 'make test-integration' separately (requires CGO/GCC)."