forked from iota-uz/iota-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJustfile
More file actions
464 lines (394 loc) · 14.7 KB
/
Copy pathJustfile
File metadata and controls
464 lines (394 loc) · 14.7 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
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
set shell := ["bash", "-eu", "-o", "pipefail", "-c"]
set dotenv-load
DEV_COMPOSE_FILE := "compose.dev.yml"
TESTING_COMPOSE_FILE := "compose.testing.yml"
TAILWIND_INPUT := "styles/tailwind/input.css"
TAILWIND_OUTPUT := "modules/core/presentation/assets/css/main.min.css"
GO_TEST_TAG := "dev"
[default]
[group("meta")]
[doc("Show recipes")]
help:
@just --groups
@echo
@just --list --unsorted
@echo
@echo "Examples:"
@echo " just setup"
@echo " just css"
@echo " just css --watch"
@echo " just dev watch"
@echo " just db migrate up"
@echo " just test -v"
@echo " just test -v -coverprofile=./coverage/coverage.out"
@echo " just e2e ci"
[group("meta")]
[doc("Install Go dependencies")]
deps:
go get ./...
[group("meta")]
[doc("Install local dev tools")]
install-tools:
bash scripts/install-dev-tools.sh
[group("docs")]
[doc("Documentation commands (dev|build|install)")]
docs cmd="help" *args="":
case "{{cmd}}" in \
dev|build|install) (cd docs && pnpm {{cmd}} {{args}}) ;; \
*) \
echo "Usage: just docs [dev|build|install]" ; \
exit 2 ;; \
esac
[group("lens")]
[doc("Lens React runtime commands (dev|build|watch|serve-from-disk|smoke|fixture|check|typegen|ladle|vr|vr-update|install)")]
lens cmd="help" *args="":
case "{{cmd}}" in \
dev|build|ladle|install) (cd web/lens && pnpm {{cmd}} {{args}}) ;; \
watch) (cd web/lens && pnpm exec vite build --watch {{args}}) ;; \
serve-from-disk) echo "export LENS_ASSETS_DIR={{justfile_directory()}}/pkg/lens/render/react/dist" ;; \
smoke) \
if [ -z "{{args}}" ]; then echo "Usage: just lens smoke <test file | -t 'test name'>" ; exit 2 ; fi ; \
smoke_args='{{args}}' ; \
case "$smoke_args" in \
-t\ *) (cd web/lens && pnpm exec tsc --noEmit && pnpm exec vitest run -t "${smoke_args#-t }") ;; \
*) (cd web/lens && pnpm exec tsc --noEmit && pnpm exec vitest run $smoke_args) ;; \
esac ;; \
fixture) (cd web/lens && pnpm fixture {{args}}) ;; \
vr|vr-update) (cd web/lens && pnpm {{cmd}} {{args}}) ;; \
vr-linux) \
if [ "$(uname -m)" != "x86_64" ]; then \
echo "Lens Linux baselines are linux/amd64; use the lens_vr_update CI workflow on ARM hosts" ; \
exit 2 ; \
fi ; \
docker run --rm --platform linux/amd64 --ipc=host -v "{{justfile_directory()}}:/work" --mount type=volume,target=/work/web/client-host/node_modules --mount type=volume,target=/work/web/client-host/dist --mount type=volume,target=/work/web/lens/node_modules --mount type=volume,source=iota-sdk-lens-vr-pnpm-store,target=/root/.local/share/pnpm/store -w /work mcr.microsoft.com/playwright:v1.55.1-noble bash -lc 'corepack enable && cd web/client-host && pnpm install --frozen-lockfile && pnpm build && cd ../lens && pnpm install --frozen-lockfile && pnpm vr {{args}}' ;; \
typegen) go run ./cmd/lens-typegen ;; \
check) \
node web/lens/scripts/check-typegen.mjs ; \
(cd web/lens && pnpm check {{args}}) ;; \
*) \
echo "Usage: just lens [dev|build|watch|serve-from-disk|smoke|fixture|check|typegen|ladle|vr|vr-update|vr-linux|install]" ; \
echo "" ; \
echo " smoke <args> typecheck plus the tests you name — a test file, or" ; \
echo " -t 'name'. The per-edit lane; just lens check stays" ; \
echo " the pre-push one" ; \
echo " watch rebuild the bundle on every source change" ; \
echo " serve-from-disk print the env export that makes a legacy custom-element" ; \
echo " host serve the ignored compatibility bundle from Vite's" ; \
echo " outDir, so a rebuild appears without a Go restart" ; \
exit 2 ;; \
esac
[group("codegen")]
[doc("Generate Go + templ (or watch)")]
generate cmd="":
if [ "{{cmd}}" = "watch" ]; then \
just _generate-watch ; \
elif [ -z "{{cmd}}" ]; then \
just _generate-all ; \
else \
echo "Usage: just generate [watch]" ; \
exit 2 ; \
fi
[group("codegen")]
_generate-all:
go generate ./... && templ generate
[group("codegen")]
_generate-watch:
templ generate --watch
[group("compose")]
[doc("Compose commands (up|down|restart|logs)")]
compose cmd="help":
case "{{cmd}}" in \
up) just _compose-up ;; \
down) just _compose-down ;; \
restart) just _compose-restart ;; \
logs) just _compose-logs ;; \
*) \
echo "Usage: just compose [up|down|restart|logs]" ; \
exit 2 ;; \
esac
[group("compose")]
_compose-up:
docker compose -f {{DEV_COMPOSE_FILE}} up
[group("compose")]
_compose-down:
docker compose -f {{DEV_COMPOSE_FILE}} down
[group("compose")]
_compose-restart:
docker compose -f {{DEV_COMPOSE_FILE}} down && docker compose -f {{DEV_COMPOSE_FILE}} up
[group("compose")]
_compose-logs:
docker compose -f {{DEV_COMPOSE_FILE}} logs -f
[group("db")]
[doc("Database commands (local|stop|clean|reset|seed|migrate|status)")]
db cmd="help" direction="":
case "{{cmd}}" in \
local) just _db-local ;; \
stop) just _db-stop ;; \
clean) just _db-clean ;; \
reset) just _db-reset ;; \
seed) just _db-seed ;; \
migrate) just _db-migrate {{direction}} ;; \
status) just _db-migrate status ;; \
*) \
echo "Usage: just db [local|stop|clean|reset|seed|migrate|status] [for migrate: up|down|redo|status]" ; \
exit 2 ;; \
esac
[group("db")]
_db-local:
docker compose -f {{DEV_COMPOSE_FILE}} up db
[group("db")]
_db-stop:
docker compose -f {{DEV_COMPOSE_FILE}} stop db
[group("db")]
_db-clean:
docker volume rm iota-sdk-data || true
[group("db")]
_db-reset:
docker compose -f {{DEV_COMPOSE_FILE}} stop db && docker volume rm iota-sdk-data || true && docker compose -f {{DEV_COMPOSE_FILE}} up db
[group("db")]
_db-seed:
go run cmd/command/main.go dbctl apply seed.main
[group("db")]
_db-migrate direction:
go run cmd/command/main.go migrate {{direction}}
[group("quality")]
[doc("Format Go code and templ files")]
fmt: (fix "fmt")
[group("quality")]
[doc("Organize Go imports (excludes *_templ.go)")]
imports: (fix "imports")
[group("quality")]
[doc("Run golangci-lint")]
lint: (check "lint")
[group("quality")]
[doc("Validate translations")]
tr: (check "tr")
[group("quality")]
[doc("Run gosec security scan (high severity, excludes generated files)")]
gosec: (check "gosec")
[group("quality")]
[doc("Auto-fix commands (fmt|imports)")]
fix cmd="help":
case "{{cmd}}" in \
fmt) go fmt ./... && templ fmt . ;; \
imports) find . -name '*.go' -not -name '*_templ.go' -exec goimports -w {} + ;; \
*) \
echo "Usage: just fix [fmt|imports]" ; \
exit 2 ;; \
esac
[group("quality")]
[doc("Checks (lint|tr)")]
check cmd="help":
case "{{cmd}}" in \
lint) golangci-lint run --build-tags {{GO_TEST_TAG}} ./... ;; \
tr) go run cmd/command/main.go check_tr_keys ;; \
gosec) GOTOOLCHAIN=auto gosec -r ./cmd/server -exclude-generated -severity high -confidence medium && GOTOOLCHAIN=auto gosec -r ./cmd/superadmin -exclude-generated -severity high -confidence medium ;; \
*) \
echo "Usage: just check [lint|tr|gosec]" ; \
exit 2 ;; \
esac
[group("test")]
[doc("Run tests. Extra arguments are passed to `go test`")]
test *args="":
mkdir -p ./coverage
go test -tags {{GO_TEST_TAG}} {{args}} ./...
[group("test")]
[doc("Run BiChat smoke evals (offline fixture runner)")]
eval *args="":
mkdir -p ./coverage
go run ./cmd/command/main.go bichat eval run --cases ./pkg/bichat/eval/testdata/smoke --runner fixture --judge none --report ./coverage/bichat_eval_report.json {{args}}
[group("test")]
[doc("Run BiChat smoke evals with OpenAI (requires OPENAI_API_KEY)")]
eval-openai *args="":
mkdir -p ./coverage
go run ./cmd/command/main.go bichat eval run --cases ./pkg/bichat/eval/testdata/smoke --runner openai --judge openai --report ./coverage/bichat_eval_report.json {{args}}
[group("test")]
[doc("Run BiChat smoke evals with OpenAI judge (fixture runner; requires OPENAI_API_KEY)")]
eval-judge-openai *args="":
mkdir -p ./coverage
go run ./cmd/command/main.go bichat eval run --cases ./pkg/bichat/eval/testdata/smoke --runner fixture --judge openai --report ./coverage/bichat_eval_report.json {{args}}
[group("test")]
[doc("Watch tests with gow")]
test-watch *args="":
gow test -tags {{GO_TEST_TAG}} -v {{args}} ./...
[group("test")]
[doc("Run tests in docker")]
test-docker:
docker compose -f {{TESTING_COMPOSE_FILE}} up --build erp_local
[group("test")]
[doc("Print coverage score (requires ./coverage/coverage.out)")]
coverage-score:
go tool cover -func ./coverage/coverage.out | grep "total:" | awk '{print ((int($$3) > 80) != 1) }'
[group("test")]
[doc("Generate coverage HTML report (requires ./coverage/coverage.out)")]
coverage-report:
go tool cover -html=./coverage/coverage.out -o ./coverage/cover.html
[group("assets")]
[doc("Build Tailwind CSS. Extra arguments are passed to `tailwindcss` (uses npx, no root package.json required)")]
css *args="":
npx @tailwindcss/cli@4.1.18 --input {{TAILWIND_INPUT}} --output {{TAILWIND_OUTPUT}} --minify {{args}}
[group("assets")]
[doc("Remove generated CSS file")]
css-clean:
rm -rf {{TAILWIND_OUTPUT}}
[group("e2e")]
[doc("E2E commands (test|reset|seed|migrate|status|run|ci|dev|clean)")]
e2e cmd="help" direction="":
case "{{cmd}}" in \
test) just _e2e-test ;; \
reset) just _e2e-reset ;; \
seed) just _e2e-seed ;; \
migrate) just _e2e-migrate {{direction}} ;; \
status) just _e2e-migrate status ;; \
run) just _e2e-run ;; \
ci) just _e2e-ci ;; \
dev) just _e2e-dev ;; \
clean) just _e2e-clean ;; \
*) \
echo "Usage: just e2e [test|reset|seed|migrate|status|run|ci|dev|clean] [for migrate: up|down|redo|status]" ; \
exit 2 ;; \
esac
[group("e2e")]
_e2e-test:
go run cmd/command/main.go e2e test
[group("e2e")]
_e2e-reset:
go run cmd/command/main.go dbctl apply db.e2e.reset --yes
[group("e2e")]
_e2e-seed:
go run cmd/command/main.go dbctl apply seed.e2e
[group("e2e")]
_e2e-migrate direction:
go run cmd/command/main.go e2e migrate {{direction}}
[group("e2e")]
[working-directory: "e2e"]
_e2e-run:
npx playwright test --ui
[group("e2e")]
[working-directory: "e2e"]
_e2e-ci:
npx playwright test --workers=1 --reporter=list
[group("e2e")]
_e2e-clean:
go run cmd/command/main.go dbctl apply db.e2e.drop --yes
[group("e2e")]
_e2e-dev:
PORT=3201 ORIGIN='http://localhost:3201' DB_NAME=iota_erp_e2e ENABLE_TEST_ENDPOINTS=true OIDC_ISSUER_URL='https://localhost:3201/oidc' OIDC_CRYPTO_KEY='MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDE=' air
[group("build")]
[doc("Build commands (dev|local|prod|linux|docker-base|docker-prod|docker-pykernel)")]
build cmd="help" v="":
case "{{cmd}}" in \
dev) just _build-dev ;; \
local) just _build-local ;; \
prod) just _build-prod ;; \
linux) just _build-linux ;; \
docker-base) just _build-docker-base {{v}} ;; \
docker-prod) just _build-docker-prod {{v}} ;; \
docker-pykernel) just _build-docker-pykernel ;; \
*) \
echo "Usage: just build [dev|local|prod|linux|docker-base|docker-prod|docker-pykernel] [version]" ; \
exit 2 ;; \
esac
[group("build")]
_build-dev:
go build -tags {{GO_TEST_TAG}} -ldflags="-s -w" -o run_server cmd/server/main.go
[group("build")]
_build-local:
go build -ldflags="-s -w" -o run_server cmd/server/main.go
[group("build")]
_build-prod:
go build -ldflags="-s -w" -o run_server cmd/server/main.go
[group("build")]
_build-linux:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o /build/run_server cmd/server/main.go
[group("build")]
_build-docker-base v:
if [ -z "{{v}}" ]; then echo "Usage: just build docker-base <version>"; exit 2; fi
docker buildx build --push --platform linux/amd64,linux/arm64 -t iotauz/sdk:base-{{v}} --target base .
[group("build")]
_build-docker-prod v:
if [ -z "{{v}}" ]; then echo "Usage: just build docker-prod <version>"; exit 2; fi
docker buildx build --push --platform linux/amd64,linux/arm64 -t iotauz/sdk:{{v}} --target production .
# The glibc CPython runtime the pykernel manager (datamig + Ali REPL) spawns.
# Tag is fixed (`3.11-analysis`, matching pkg/pykernel/deploy/README.md), so no
# version arg. amd64 only: prod hosts are amd64 and the pinned analysis wheels
# are manylinux/glibc. Application images build `FROM` this (e.g. eai back/Dockerfile).
[group("build")]
_build-docker-pykernel:
docker buildx build --push --platform linux/amd64 -t iotauz/pykernel-base:3.11-analysis pkg/pykernel/deploy
[group("superadmin")]
[doc("Superadmin commands (dev|seed)")]
superadmin cmd="":
case "{{cmd}}" in \
dev) just _superadmin-dev ;; \
seed) just _superadmin-seed ;; \
"") just _superadmin-run ;; \
*) \
echo "Usage: just superadmin [dev|seed]" ; \
exit 2 ;; \
esac
[group("superadmin")]
_superadmin-run:
PORT=4000 DOMAIN='localhost:4000' go run cmd/superadmin/main.go
[group("superadmin")]
_superadmin-dev:
PORT=4000 DOMAIN='localhost:4000' ORIGIN='http://localhost:4000' air -c .air.superadmin.toml
[group("superadmin")]
_superadmin-seed:
LOG_LEVEL=info go run cmd/command/main.go dbctl apply seed.superadmin
[group("tools")]
[doc("sdk-tools commands (install|test|help)")]
sdk-tools cmd="help":
case "{{cmd}}" in \
install) just _sdk-tools-install ;; \
test) just _sdk-tools-test ;; \
help) sdk-tools --help ;; \
*) \
echo "Usage: just sdk-tools [install|test|help]" ; \
exit 2 ;; \
esac
[group("tools")]
[working-directory: ".claude/tools"]
_sdk-tools-install:
echo "Installing sdk-tools..."
GOWORK=off go install .
echo "✓ Installed sdk-tools to $(go env GOPATH)/bin/sdk-tools"
echo "Make sure $(go env GOPATH)/bin is in your PATH"
[group("tools")]
[working-directory: ".claude/tools"]
_sdk-tools-test:
echo "Running sdk-tools tests..."
GOWORK=off go test ./... -v
[group("tools")]
[doc("Dependency graph")]
graph:
goda graph ./modules/... | dot -Tpng -o dependencies.png
[group("tools")]
[doc("Cloudflared tunnel")]
tunnel:
cloudflared tunnel --url http://localhost:3200 --loglevel debug
[group("assets")]
[doc("Clean build artifacts")]
clean: css-clean
[group("dev")]
[doc("Start dev: just dev = project processes only; just dev <applet> = with applet")]
dev name="":
applet dev {{name}}
[group("dev")]
[doc("Applet commands. Requires applet CLI: go install github.com/iota-uz/applets/cmd/applet@latest")]
applet cmd="help" name="":
case "{{cmd}}" in \
dev) applet dev "{{name}}" ;; \
list) applet list ;; \
build) applet build "{{name}}" ;; \
check) applet check ;; \
rpc-gen) applet rpc gen --name "{{name}}" ;; \
rpc-check) applet rpc check --name "{{name}}" ;; \
deps-check) applet deps check ;; \
*) \
echo "Usage: just applet [dev <name>|list|build <name>|check|rpc-gen <name>|rpc-check <name>|deps-check]" ; \
exit 2 ;; \
esac
[group("meta")]
[doc("Full local setup")]
setup: deps css fmt imports lint