-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTaskfile.yml
More file actions
357 lines (300 loc) · 11.3 KB
/
Taskfile.yml
File metadata and controls
357 lines (300 loc) · 11.3 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
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
version: "3"
includes:
debug:
taskfile: ./taskfiles/debug.yml
vars:
CPU_COUNT:
sh: nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo "4"
PARALLEL_COUNT:
sh: echo $(({{.CPU_COUNT}} * 2))
tasks:
# ===========================================================================
# Primary workflows (what you'll use most)
# ===========================================================================
setup:
desc: One-time local dev setup (git hooks)
cmds:
- git config core.hooksPath .githooks
do:
desc: Format, lint, and test (pre-commit check)
cmds:
- task: fmt
- task: lint
- task: test
signoff:
desc: Full validation before push
aliases: [sign, s]
deps: [do, check, build]
cmds:
- gh signoff
# ===========================================================================
# Code generation
# ===========================================================================
generate:
desc: Generate all code (GraphQL client + SQLite schema)
cmds:
- task: generate:client
- task: generate:schema
generate:client:
desc: Generate GraphQL client (requires control plane at localhost:18081)
dir: internal/boundary/graphql/gen
cmds:
- npx get-graphql-schema http://localhost:18081/graphql > schema.graphql
- go run github.com/Khan/genqlient
generate:schema:
desc: Generate PowerSync and SQLite schema (uses local control plane)
cmds:
- go generate ./internal/powersync
- go generate ./internal/sqlite
- sed '/^-- Auto-generated/d; /^-- Run .task generate/d' ../control-plane/internal/powersync/schema.sql > internal/chat/tools/query_schema.sql
# ===========================================================================
# Build
# ===========================================================================
build:
desc: Build the tero binary
cmds:
- go build -o tero cmd/tero/main.go
sources:
- "**/*.go"
generates:
- tero
build:version:
desc: Build with version info (same as CI)
cmds:
- |
VERSION=$(git describe --tags --always --dirty 2>/dev/null || echo "dev")
go build -ldflags "-X main.version=${VERSION}" -o tero cmd/tero/main.go
echo "Built tero ${VERSION}"
install:
desc: Install tero to GOPATH
deps: [build]
cmds:
- go install cmd/tero/main.go
# ===========================================================================
# Quality checks
# ===========================================================================
fmt:
desc: Format code
cmds:
- go fmt ./...
lint:
desc: Run all linters
deps: [lint:go, lint:scripts, lint:naming, lint:architecture]
lint:go:
desc: Run golangci-lint
cmds:
- golangci-lint run ./...
lint:scripts:
desc: Lint shell scripts with shellcheck
cmds:
- find scripts -type f -name "*.sh" -print0 | xargs -0 shellcheck
lint:naming:
desc: Enforce UI message/event naming conventions
deps: [lint:naming:events, lint:naming:local]
lint:naming:events:
desc: Enforce app event naming conventions
cmds:
- ./scripts/lint/check-event-naming.sh
lint:naming:local:
desc: Enforce local app message naming conventions
cmds:
- ./scripts/lint/check-local-msg-naming.sh
lint:architecture:
desc: Enforce Bubble Tea event-loop architecture guardrails
deps: [lint:architecture:event-loop, lint:architecture:ownership]
cmds: []
lint:architecture:event-loop:
desc: Enforce no blocking work in Update/View
cmds:
- ./scripts/lint/check-event-loop-safety.sh
lint:architecture:ownership:
desc: Enforce feature event package ownership boundaries
cmds:
- ./scripts/lint/check-event-ownership.sh
check:
desc: Validate build
cmds:
- go vet ./...
- task: check:task-run-env
check:task-run-env:
desc: Validate task run env wiring for local and prd
cmds:
- |
RUN_CMD="$(TERO_ENV=prd task -n run 2>&1 | tail -n 1)"
echo "$RUN_CMD" | rg './scripts/with-env.sh go run ./cmd/tero' >/dev/null
rg 'env_name="\$\{TERO_ENV:-local\}"' ./scripts/with-env.sh >/dev/null
rg 'exec doppler run -c "\$env_name" -- "\$@"' ./scripts/with-env.sh >/dev/null
# ===========================================================================
# Testing
# ===========================================================================
test:
desc: Run unit and component tests
cmds:
- gotestsum --format short-verbose -- -race -p {{.CPU_COUNT}} -parallel {{.PARALLEL_COUNT}} -skip "^TestIntegration_|^TestCorrectness_" ./...
test:integration:
desc: Run hermetic integration tests (deterministic, no external services)
cmds:
- gotestsum --format short-verbose -- -race -tags=integration -run "^TestIntegration_" ./...
test:integration:live:
desc: Run live integration tests against non-production services (TERO_ENV=dev|prd)
cmds:
- './scripts/with-env.sh gotestsum --format short-verbose -- -race -tags=integration_live -run "^TestIntegrationLive_" ./...'
test:tags:compile:
desc: Compile all opt-in tagged tests (integration/live/correctness)
cmds:
- go test -tags=integration -run "^$" ./...
- go test -tags=integration_live -run "^$" ./...
- go test -tags=correctness -run "^$" ./...
test:correctness:
desc: Run correctness tests (TERO_ENV=dev|prd)
cmds:
- './scripts/with-env.sh gotestsum --format short-verbose -- -v -tags=correctness -run "^TestCorrectness_" ./...'
test:correctness:powersync-replay:
desc: Run deterministic PowerSync fixture replay correctness test
cmds:
- |
if [ -n "{{.FIXTURE}}" ]; then
TERO_POWERSYNC_FIXTURE_PATH="{{.FIXTURE}}" ./scripts/with-env.sh gotestsum --format short-verbose -- \
-v -tags=correctness -run "^TestCorrectness_PowerSync_ControllerFixtureReplayDeterministic$" ./internal/powersync/extension
else
./scripts/with-env.sh gotestsum --format short-verbose -- \
-v -tags=correctness -run "^TestCorrectness_PowerSync_ControllerFixtureReplayDeterministic$" ./internal/powersync/extension
fi
test:all:
desc: Run CI test suite (unit + hermetic integration + correctness replay)
cmds:
- task: test
- task: test:integration
- task: test:correctness:powersync-replay
test:all:full:
desc: Run full test suite including live integration checks
cmds:
- task: test:all
- task: test:integration:live
# ===========================================================================
# Development helpers
# ===========================================================================
run:
desc: Run tero (TERO_ENV=local|dev|prd)
cmds:
- "./scripts/with-env.sh go run ./cmd/tero {{.CLI_ARGS}}"
dev:
desc: Generate code and build
deps: [generate]
cmds:
- task: build
auth:login:
desc: Login to Tero (TERO_ENV=local|dev|prd)
cmds:
- "./scripts/with-env.sh go run ./cmd/tero auth login"
auth:token:
desc: Print current access token (TERO_ENV=local|dev|prd)
cmds:
- "./scripts/with-env.sh go run ./cmd/tero auth token"
auth:status:
desc: Show auth status (TERO_ENV=local|dev|prd)
cmds:
- "./scripts/with-env.sh go run ./cmd/tero auth status"
auth:switch:
desc: Switch organization (TERO_ENV=local|dev|prd)
cmds:
- "./scripts/with-env.sh go run ./cmd/tero auth switch {{.CLI_ARGS}}"
internal:powersync:capture:
desc: Capture raw PowerSync stream to NDJSON (TERO_ENV=dev|prd)
vars:
OUTPUT: '{{.OUTPUT | default "fixtures/powersync/capture.ndjson"}}'
DURATION: '{{.DURATION | default "90s"}}'
MAX_BYTES: '{{.MAX_BYTES | default "26214400"}}'
cmds:
- |
CMD="./scripts/with-env.sh go run ./cmd/tero internal powersync capture --output {{.OUTPUT}} --duration {{.DURATION}} --max-bytes {{.MAX_BYTES}}"
if [ -n "{{.ACCOUNT_ID}}" ]; then
CMD="$CMD --account-id {{.ACCOUNT_ID}}"
fi
eval "$CMD"
internal:powersync:sanitize-fixture:
desc: Sanitize raw PowerSync fixture to commit-safe NDJSON
cmds:
- |
if [ -z "{{.INPUT}}" ] || [ -z "{{.OUTPUT}}" ]; then
echo "INPUT and OUTPUT are required"
exit 1
fi
CMD="./scripts/with-env.sh go run ./cmd/tero internal powersync sanitize-fixture --input {{.INPUT}} --output {{.OUTPUT}}"
if [ -n "{{.MAX_LINES}}" ]; then
CMD="$CMD --max-lines {{.MAX_LINES}}"
fi
eval "$CMD"
# ===========================================================================
# Admin (internal tooling, not shipped)
# ===========================================================================
admin:join-org:
desc: Join a client organization (TERO_ENV=dev|prd)
cmds:
- "./scripts/with-env.sh go run ./cmd/admin join-org {{.CLI_ARGS}}"
admin:leave-org:
desc: Leave a client organization (TERO_ENV=dev|prd)
cmds:
- "./scripts/with-env.sh go run ./cmd/admin leave-org {{.CLI_ARGS}}"
# ===========================================================================
# Dependencies
# ===========================================================================
update:powersync:
desc: Update PowerSync SQLite extension to latest release
cmds:
- ./scripts/update-powersync.sh {{.CLI_ARGS}}
# ===========================================================================
# Cleanup
# ===========================================================================
clean:
desc: Clean build artifacts and caches
cmds:
- rm -f tero
- rm -rf dist/
- go clean -cache -testcache -modcache
- echo "Cleaned build artifacts and Go caches"
reset:
desc: Reset dev environment (auth, config, database, logs)
cmds:
- go run ./cmd/tero reset --db
- rm -f ~/.tero/environments/*/tero.log
- echo "Reset complete"
# ===========================================================================
# Release
# ===========================================================================
release:check:
desc: Check commits follow conventional format
cmds:
- |
echo "Recent commits (should follow conventional commit format):"
git log --oneline -10
echo ""
echo "Valid prefixes: feat, fix, chore, docs, refactor, test, ci, perf, revert"
release:snapshot:
desc: Test release build locally
cmds:
- |
VERSION=$(git describe --tags --always --dirty 2>/dev/null || echo "dev")
CGO_ENABLED=1 go build -trimpath -ldflags "-s -w -X main.version=${VERSION}" -o dist/tero ./cmd/tero
echo "Built dist/tero ${VERSION}"
ls -lh dist/tero
release:test-install:
desc: Test install.sh script against latest release
cmds:
- |
echo "Testing install script..."
export TERO_INSTALL_DIR="/tmp/tero-install-test"
rm -rf "$TERO_INSTALL_DIR"
sh scripts/install.sh --help
echo ""
echo "Installing latest release to $TERO_INSTALL_DIR..."
sh scripts/install.sh -y
if [ -x "$TERO_INSTALL_DIR/tero" ]; then
echo ""
echo "Installation successful!"
"$TERO_INSTALL_DIR/tero" --version
else
echo "Installation failed"
exit 1
fi
rm -rf "$TERO_INSTALL_DIR"