-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustfile
More file actions
420 lines (339 loc) Β· 15.1 KB
/
Copy pathjustfile
File metadata and controls
420 lines (339 loc) Β· 15.1 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
set shell := ["/bin/bash", "-c"]
set dotenv-load := true
set positional-arguments := true
# === Colors ===
# Generated via printf because just 1.51.0 doesn't accept \033 (octal) or \x1b (hex)
# escape sequences in string variables. Newer just versions handle both.
GREEN := `printf '\033[0;32m'`
YELLOW := `printf '\033[0;33m'`
RED := `printf '\033[0;31m'`
RESET := `printf '\033[0m'`
# === Dev ===
dev:
@cd apps/rook && cargo watch -x check -x test -x clippy
# === Dev Container (Docker) ===
# Run rook in an isolated container to smoke-test without touching the host OS.
# Wraps dev/run.sh + dev/docker-compose.dev.yml.
dev-build:
@./dev/run.sh build
dev-run: dev-build
@./dev/run.sh up
dev-up:
@./dev/run.sh up
dev-down:
@./dev/run.sh down
dev-logs:
@./dev/run.sh logs
dev-shell:
@./dev/run.sh shell
dev-restart:
@./dev/run.sh restart
dev-status:
@./dev/run.sh status
dev-clean:
@./dev/run.sh clean
# === Lint ===
check:
cargo check --workspace
clippy:
cargo clippy --workspace --all-targets -- -D warnings
clippy-fail-fast:
cargo clippy --workspace --all-targets -- -D warnings || true
@echo "{{GREEN}}Clippy complete{{RESET}}"
fmt:
cargo fmt --all
fmt-check:
cargo fmt --all -- --check
# === Test ===
test:
cargo test --workspace --all-features
test-unit:
cargo test --workspace --lib
test-integration:
cargo test --workspace --test '*'
test-doc:
cargo test --workspace --doc
# === E2E Tests ===
test-e2e-build:
@echo "{{YELLOW}}Building Docker image for e2e tests...{{RESET}}"
docker build -f Dockerfile.dev -t rook:e2e-api-keys .
test-e2e:
@echo "{{YELLOW}}Running E2E tests (Playwright)...{{RESET}}"
./dev/e2e/run-api-keys-e2e.sh --test
test-e2e-dev:
@echo "{{YELLOW}}Starting E2E dev environment (manual testing)...{{RESET}}"
./dev/e2e/run-api-keys-e2e.sh
test-e2e-cleanup:
@echo "{{YELLOW}}Cleaning up E2E containers...{{RESET}}"
./dev/e2e/run-api-keys-e2e.sh --cleanup
test-e2e-install-deps:
@echo "{{YELLOW}}Installing dashboard dependencies...{{RESET}}"
cd apps/rook/dashboard && pnpm install
coverage:
cargo llvm-cov --workspace --html
coverage-text:
cargo llvm-cov --workspace
# === Build ===
build:
cargo build --workspace --release
build-app:
cargo build -p rook --release
build-targets:
# Cross-compile for all targets
@echo "{{YELLOW}}Building for macOS Intel...{{RESET}}"
cargo build -p rook --release --target x86_64-apple-darwin
@echo "{{YELLOW}}Building for macOS ARM64...{{RESET}}"
cargo build -p rook --release --target aarch64-apple-darwin
@echo "{{YELLOW}}Building for Linux x86_64...{{RESET}}"
cargo build -p rook --release --target x86_64-unknown-linux-gnu
@echo "{{YELLOW}}Building for Linux ARM64...{{RESET}}"
cargo build -p rook --release --target aarch64-unknown-linux-gnu
@echo "{{YELLOW}}Building for Windows x86_64...{{RESET}}"
cargo build -p rook --release --target x86_64-pc-windows-msvc
@echo "{{YELLOW}}Building for Windows ARM64...{{RESET}}"
cargo build -p rook --release --target aarch64-pc-windows-msvc
@echo "{{GREEN}}All targets built!{{RESET}}"
# === Run ===
# Run the backend (rook) in dev mode
run:
ROOK_CONFIG=$HOME/.config/cortex/rook.toml cargo run -p rook
# Run the Vue dashboard dev server (requires pnpm install first)
run-dashboard:
cd apps/rook/dashboard && pnpm dev
# Install dashboard npm dependencies (run once after cloning)
dashboard-install:
cd apps/rook/dashboard && pnpm install
# === DB ===
# Reset the SQLite database β removes rook.db, rook.db-wal, rook.db-shm
# Always delete all three files together; a leftover -wal against a fresh DB
# causes SQLite error 522 ("file truncated") on the next startup.
db-reset:
@rm -f ~/.local/share/cortex/rook/rook.db{,-wal,-shm}
@echo "{{GREEN}}Database reset β rook.db, rook.db-wal, rook.db-shm removed{{RESET}}"
# Kill any process occupying port 3773 (stale rook instance)
kill-backend:
@lsof -ti :3773 | xargs kill -9 2>/dev/null && echo "{{GREEN}}Killed process on :3773{{RESET}}" || echo "{{YELLOW}}Nothing running on :3773{{RESET}}"
# One-shot first-time setup: install dashboard deps + verify Rust toolchain
setup:
@echo "{{YELLOW}}Installing dashboard dependencies...{{RESET}}"
cd apps/rook/dashboard && pnpm install
@echo "{{YELLOW}}Verifying Rust toolchain...{{RESET}}"
rustup show
@echo "{{GREEN}}Setup complete β run 'just run' in one terminal and 'just run-dashboard' in another{{RESET}}"
# === Quality ===
audit:
cargo audit --no-fetch
outdated:
cargo outdated -r
unused:
cargo udeps --workspace
hack:
cargo hack --workspace --optional-deps-metadata
spellcheck:
cargo-spellcheck check --all
# === Providers ===
check-providers:
cargo check -p providers-openai -p providers-anthropic -p providers-ollama -p providers-gemini -p providers-groq
# === Infra ===
check-infra:
cargo check -p transport-axum -p cache-memory -p audit-sqlite -p observability
# === Domain ===
check-domain:
cargo check -p shared-kernel -p rook-core
# === Doc ===
doc:
cargo doc --workspace --no-deps --document-private-items
doc-open:
cargo doc --workspace --no-deps --open
# === Clean ===
clean:
cargo clean
cargo llvm-cov clean --workspace
# === Full CI (local) ===
# Each ci-* recipe is independent and can be run standalone.
# ci-local chains them sequentially β stops on first failure with a clear banner.
# Run individual steps with: just ci-lint, just ci-test-rust, etc.
_ci-header phase:
@echo "{{YELLOW}}π {{ phase }}{{RESET}}"
ci-lint: (_ci-header "1/9 markdown-lint...")
@pnpm exec markdownlint-cli2 "*.md" "docs/**/*.md"
ci-fmt: (_ci-header "2/9 fmt-check...")
@cargo fmt --all -- --check
ci-clippy: (_ci-header "3/9 clippy...")
@cargo clippy --workspace --all-targets -- -D warnings
ci-check: (_ci-header "4/9 cargo check...")
@cargo check --workspace
ci-test-rust: (_ci-header "5/9 cargo test (Rust)...")
@cargo test --workspace --all-features
ci-test-vitest: (_ci-header "6/9 vitest (Frontend)...")
@cd apps/rook/dashboard && pnpm exec vitest run
ci-doc: (_ci-header "7/9 cargo doc...")
@RUSTDOCFLAGS="--document-private-items -D warnings" cargo doc --workspace --no-deps
ci-audit: (_ci-header "8/9 cargo audit...")
@cargo audit --no-fetch || true
ci-e2e: (_ci-header "9/9 e2e (Playwright)...")
@./dev/e2e/run-api-keys-e2e.sh --test
# ---------------------------------------------------------------------------
# ci-local: sequential fail-fast with clear error banner
# ---------------------------------------------------------------------------
# Runs every ci-* step in order. On first failure, prints a red banner with
# the step name and elapsed time, then exits immediately.
ci-local:
#!/usr/bin/env bash
set -euo pipefail
G="$(printf '\033[0;32m')" Y="$(printf '\033[0;33m')" R="$(printf '\033[0;31m')" N="$(printf '\033[0m')"
TOTAL_START=$SECONDS
run_step() {
local label="$1"; shift
echo "${Y}π ${label}${N}"
local step_start=$SECONDS
if "$@"; then
local elapsed=$(( SECONDS - step_start ))
echo "${G} β ${label} (${elapsed}s)${N}"
else
local elapsed=$(( SECONDS - step_start ))
echo ""
echo "${R}ββββββββββββββββββββββββββββββββββββββββββββββ${N}"
echo "${R} β FAILED at: ${label} (${elapsed}s)${N}"
echo "${R}ββββββββββββββββββββββββββββββββββββββββββββββ${N}"
echo ""
exit 1
fi
}
echo ""
echo "${Y}ββββββββββββββββββββββββββββββββββββββββββββββ${N}"
echo "${Y} CI LOCAL β fail-fast on first error${N}"
echo "${Y}ββββββββββββββββββββββββββββββββββββββββββββββ${N}"
echo ""
run_step "1/9 markdown-lint" pnpm exec markdownlint-cli2 "*.md" "docs/**/*.md"
run_step "2/9 fmt-check" cargo fmt --all -- --check
run_step "3/9 clippy" cargo clippy --workspace --all-targets -- -D warnings
run_step "4/9 cargo check" cargo check --workspace
run_step "5/9 cargo test" cargo test --workspace --all-features
run_step "6/9 vitest" bash -c 'cd apps/rook/dashboard && pnpm exec vitest run'
run_step "7/9 cargo doc" bash -c 'RUSTDOCFLAGS="--document-private-items -D warnings" cargo doc --workspace --no-deps'
run_step "8/9 cargo audit" bash -c 'cargo audit --no-fetch || true'
run_step "9/9 e2e" ./dev/e2e/run-api-keys-e2e.sh --test
TOTAL=$(( SECONDS - TOTAL_START ))
echo ""
echo "${G}ββββββββββββββββββββββββββββββββββββββββββββββ${N}"
echo "${G} CI LOCAL β ALL PASSED β (${TOTAL}s total)${N}"
echo "${G}ββββββββββββββββββββββββββββββββββββββββββββββ${N}"
echo ""
# Run only linting + formatting stages
ci-lint-only:
@just ci-lint
@just ci-fmt
@echo "{{GREEN}}Lint stages passed{{RESET}}"
# Run only compile + type-check stages
ci-check-only:
@just ci-clippy
@just ci-check
@echo "{{GREEN}}Check stages passed{{RESET}}"
# Run only test stages (fast feedback loop)
ci-test-only:
@just ci-test-rust
@just ci-test-vitest
@echo "{{GREEN}}Test stages passed{{RESET}}"
# Run CI without E2E (skip Docker dependency for quick iteration)
ci-ci:
#!/usr/bin/env bash
set -euo pipefail
G="$(printf '\033[0;32m')" Y="$(printf '\033[0;33m')" R="$(printf '\033[0;31m')" N="$(printf '\033[0m')"
TOTAL_START=$SECONDS
run_step() {
local label="$1"; shift
echo "${Y}π ${label}${N}"
local step_start=$SECONDS
if "$@"; then
local elapsed=$(( SECONDS - step_start ))
echo "${G} β ${label} (${elapsed}s)${N}"
else
local elapsed=$(( SECONDS - step_start ))
echo ""
echo "${R}ββββββββββββββββββββββββββββββββββββββββββββββ${N}"
echo "${R} β FAILED at: ${label} (${elapsed}s)${N}"
echo "${R}ββββββββββββββββββββββββββββββββββββββββββββββ${N}"
echo ""
exit 1
fi
}
echo ""
echo "${Y}ββββββββββββββββββββββββββββββββββββββββββββββ${N}"
echo "${Y} CI (no E2E) β fail-fast on first error${N}"
echo "${Y}ββββββββββββββββββββββββββββββββββββββββββββββ${N}"
echo ""
run_step "1/8 markdown-lint" pnpm exec markdownlint-cli2 "*.md" "docs/**/*.md"
run_step "2/8 fmt-check" cargo fmt --all -- --check
run_step "3/8 clippy" cargo clippy --workspace --all-targets -- -D warnings
run_step "4/8 cargo check" cargo check --workspace
run_step "5/8 cargo test" cargo test --workspace --all-features
run_step "6/8 vitest" bash -c 'cd apps/rook/dashboard && pnpm exec vitest run'
run_step "7/8 cargo doc" bash -c 'RUSTDOCFLAGS="--document-private-items -D warnings" cargo doc --workspace --no-deps'
run_step "8/8 cargo audit" bash -c 'cargo audit --no-fetch || true'
TOTAL=$(( SECONDS - TOTAL_START ))
echo ""
echo "${G}ββββββββββββββββββββββββββββββββββββββββββββββ${N}"
echo "${G} CI (no E2E) β ALL PASSED β (${TOTAL}s total)${N}"
echo "${G}ββββββββββββββββββββββββββββββββββββββββββββββ${N}"
echo ""
# === Release ===
release-dry-run:
@echo "{{YELLOW}}Running release-please dry-run...{{RESET}}"
npx release-please release-pr --token=$$GITHUB_TOKEN --dry-run
# === Help ===
help:
@echo "cortex/rook - available commands:"
@echo ""
@echo "Quality:"
@echo " just fmt - Format code"
@echo " just fmt-check - Check formatting"
@echo " just clippy - Run clippy (deny warnings)"
@echo " just test - Run all tests (unit + integration + doc)"
@echo " just test-unit - Run unit tests only (lib)"
@echo " just test-integration - Run integration tests"
@echo " just coverage - Generate HTML coverage report"
@echo " just audit - Check for vulnerabilities"
@echo " just ci-local - Run full CI locally (fail-fast: stops on first error)"
@echo " just ci-ci - Full CI without E2E (no Docker needed)"
@echo " just ci-lint-only - Lint + fmt only"
@echo " just ci-check-only - Clippy + cargo check only"
@echo " just ci-test-only - Rust + Vitest tests only"
@echo ""
@echo "E2E Tests (Playwright):"
@echo " just test-e2e-build - Build Docker image for e2e"
@echo " just test-e2e - Run Playwright e2e tests"
@echo " just test-e2e-dev - Start e2e env for manual testing"
@echo " just test-e2e-cleanup - Stop/remove e2e containers"
@echo " just test-e2e-install-deps - Install dashboard dependencies"
@echo ""
@echo "Build:"
@echo " just build - Build release (all targets)"
@echo " just build-app - Build rook binary"
@echo " just build-targets - Cross-compile for all platforms"
@echo ""
@echo "Dev:"
@echo " just setup - First-time setup (dashboard deps + toolchain check)"
@echo " just dev - Watch mode with check+test+clippy"
@echo " just run - Run rook backend"
@echo " just run-dashboard - Run Vue dashboard dev server (localhost:4747)"
@echo " just dashboard-install - Install dashboard npm dependencies"
@echo ""
@echo "DB:"
@echo " just db-reset - Delete rook.db + WAL files (clean slate)"
@echo " just kill-backend - Kill stale process on port 3773"
@echo ""
@echo "Dev Container (Docker β no host pollution):"
@echo " just dev-run - Build image + start container (waits for /health)"
@echo " just dev-up - Start container (builds image if missing)"
@echo " just dev-build - Build the rook:dev image only"
@echo " just dev-down - Stop and remove container"
@echo " just dev-logs - Tail container logs"
@echo " just dev-shell - Shell into the running container"
@echo " just dev-restart - Restart the container"
@echo " just dev-status - Container + /health status"
@echo " just dev-clean - Remove image and container"
@echo ""
@echo "Doc:"
@echo " just doc - Generate docs"
@echo " just doc-open - Generate and open docs"