|
| 1 | +# SPDX-License-Identifier: PMPL-1.0-or-later |
| 2 | +# justfile - Just recipes for Lithoglyph |
| 3 | +# Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk> |
| 4 | + |
| 5 | +# Default recipe |
| 6 | +default: |
| 7 | + @just --list |
| 8 | + |
| 9 | +# ============================================================ |
| 10 | +# BUILD |
| 11 | +# ============================================================ |
| 12 | + |
| 13 | +# Build Zig libraries (static + shared) |
| 14 | +build-zig: |
| 15 | + cd core-zig && zig build |
| 16 | + |
| 17 | +# Build shared library for FFI consumers |
| 18 | +build-ffi: |
| 19 | + cd core-zig && zig build-lib src/bridge.zig -dynamic -lc -O ReleaseFast |
| 20 | + |
| 21 | +# Build C FFI integration test binary |
| 22 | +build-ffi-tests: |
| 23 | + cd core-zig && gcc -o test-ffi-integration test-ffi-integration.c -L zig-out/lib -llith_bridge |
| 24 | + cd core-zig && gcc -o test-version-only test-version-only.c -L zig-out/lib -llith_bridge |
| 25 | + cd core-zig && gcc -o test-db-open test-db-open.c -L zig-out/lib -llith_bridge |
| 26 | + |
| 27 | +# Build everything |
| 28 | +build: build-zig |
| 29 | + |
| 30 | +# ============================================================ |
| 31 | +# TESTS |
| 32 | +# ============================================================ |
| 33 | + |
| 34 | +# Run Zig unit tests (bridge + blocks) |
| 35 | +test-zig: |
| 36 | + @echo "=== Zig Unit Tests ===" |
| 37 | + cd core-zig && zig build test |
| 38 | + @echo "Zig tests passed" |
| 39 | + |
| 40 | +# Run Zig tests directly (faster, no build system) |
| 41 | +test-zig-fast: |
| 42 | + @echo "=== Zig Direct Tests ===" |
| 43 | + cd core-zig && zig test src/bridge.zig |
| 44 | + cd core-zig && zig test src/blocks.zig |
| 45 | + |
| 46 | +# Run Forth block layer tests |
| 47 | +test-forth: |
| 48 | + @echo "=== Forth Block Tests ===" |
| 49 | + cd core-forth/test && gforth test-blocks.fs -e bye |
| 50 | + |
| 51 | +# Run C FFI integration tests (requires build-zig first) |
| 52 | +test-ffi: build-zig |
| 53 | + @echo "=== C FFI Integration Tests ===" |
| 54 | + cd core-zig && LD_LIBRARY_PATH=zig-out/lib ./test-ffi-integration |
| 55 | + |
| 56 | +# Run C FFI quick smoke tests |
| 57 | +test-ffi-smoke: build-zig |
| 58 | + @echo "=== C FFI Smoke Tests ===" |
| 59 | + cd core-zig && LD_LIBRARY_PATH=zig-out/lib ./test-version-only |
| 60 | + cd core-zig && LD_LIBRARY_PATH=zig-out/lib ./test-db-open |
| 61 | + |
| 62 | +# Run Factor seam tests |
| 63 | +test-factor: |
| 64 | + @echo "=== Factor Seam Tests ===" |
| 65 | + cd core-factor/gql && factor seam-tests.factor |
| 66 | + |
| 67 | +# Run ReScript property tests |
| 68 | +test-property: |
| 69 | + @echo "=== ReScript Property Tests ===" |
| 70 | + cd tests/property && deno task test |
| 71 | + |
| 72 | +# Run ReScript fuzz tests (quick: 1K iterations) |
| 73 | +test-fuzz-quick: |
| 74 | + @echo "=== ReScript Fuzz Tests (Quick) ===" |
| 75 | + cd tests/fuzz && deno task fuzz:quick |
| 76 | + |
| 77 | +# Run ReScript fuzz tests (standard: 10K iterations) |
| 78 | +test-fuzz: |
| 79 | + @echo "=== ReScript Fuzz Tests ===" |
| 80 | + cd tests/fuzz && deno task fuzz |
| 81 | + |
| 82 | +# Run ReScript integration tests (requires Deno + ReScript) |
| 83 | +test-integration: |
| 84 | + @echo "=== ReScript Integration Tests ===" |
| 85 | + cd tests/integration && deno task test |
| 86 | + |
| 87 | +# Run E2E tests (requires running Lith server on :8080) |
| 88 | +test-e2e: |
| 89 | + @echo "=== E2E Tests (requires server on :8080) ===" |
| 90 | + cd tests/e2e && deno task test |
| 91 | + |
| 92 | +# Run all core tests (no server required) |
| 93 | +test: test-zig test-forth test-ffi |
| 94 | + |
| 95 | +# Run all tests including ReScript suites |
| 96 | +test-all: test-zig test-forth test-ffi test-property test-fuzz-quick |
| 97 | + |
| 98 | +# ============================================================ |
| 99 | +# BENCHMARKS |
| 100 | +# ============================================================ |
| 101 | + |
| 102 | +# Run Factor GQL benchmarks |
| 103 | +bench-factor: |
| 104 | + @echo "=== Factor GQL Benchmarks ===" |
| 105 | + cd core-factor/gql && factor benchmarks.factor |
| 106 | + |
| 107 | +# Run all benchmarks |
| 108 | +bench: bench-factor |
| 109 | + |
| 110 | +# ============================================================ |
| 111 | +# CHECKS & VALIDATION |
| 112 | +# ============================================================ |
| 113 | + |
| 114 | +# Check that Forth code loads without errors |
| 115 | +check-forth: |
| 116 | + @echo "Checking Forth code loads..." |
| 117 | + cd core-forth/src && gforth lithoglyph-blocks.fs -e 'bye' |
| 118 | + cd core-forth/src && gforth lithoglyph-journal.fs -e 'bye' |
| 119 | + cd core-forth/src && gforth lithoglyph-model.fs -e 'bye' |
| 120 | + @echo "All Forth files load successfully" |
| 121 | + |
| 122 | +# Check that Lean code compiles |
| 123 | +check-lean: |
| 124 | + @echo "Checking Lean code compiles..." |
| 125 | + cd normalizer/lean && lake build |
| 126 | + @echo "Lean code compiles" |
| 127 | + |
| 128 | +# Verify Zig ABI exports match expectations |
| 129 | +check-abi: build-zig |
| 130 | + @echo "=== ABI Export Verification ===" |
| 131 | + nm -D core-zig/zig-out/lib/liblith_bridge.so | grep ' T lith_' | sort |
| 132 | + @echo "Expected: lith_version, lith_db_open, lith_db_close, lith_txn_begin, lith_txn_commit, lith_txn_abort, lith_apply, lith_introspect_schema, lith_render_block, lith_render_journal, lith_blob_free" |
| 133 | + |
| 134 | +# Run all checks |
| 135 | +check: check-forth check-lean check-abi |
| 136 | + |
| 137 | +# Format Zig code |
| 138 | +fmt: |
| 139 | + cd core-zig && zig fmt src/ |
| 140 | + |
| 141 | +# ============================================================ |
| 142 | +# CLEAN |
| 143 | +# ============================================================ |
| 144 | + |
| 145 | +# Clean build artifacts |
| 146 | +clean: |
| 147 | + @echo "Cleaning build artifacts..." |
| 148 | + rm -rf core-zig/zig-out core-zig/.zig-cache |
| 149 | + rm -f core-zig/test-*.lgh |
| 150 | + @echo "Clean complete" |
| 151 | + |
| 152 | +# ============================================================ |
| 153 | +# DEV TOOLS |
| 154 | +# ============================================================ |
| 155 | + |
| 156 | +# Show development environment status |
| 157 | +env-status: |
| 158 | + @echo "Development Environment Status:" |
| 159 | + @echo "================================" |
| 160 | + @which zig 2>/dev/null && echo "Zig: $(zig version)" || echo "Zig: NOT INSTALLED" |
| 161 | + @which gforth 2>/dev/null && echo "Forth: $(gforth --version 2>&1 | head -1)" || echo "gforth: NOT INSTALLED" |
| 162 | + @which factor 2>/dev/null && echo "Factor: installed" || echo "Factor: NOT INSTALLED" |
| 163 | + @which lean 2>/dev/null && echo "Lean: $(lean --version 2>&1 | head -1)" || echo "Lean: NOT INSTALLED" |
| 164 | + @which deno 2>/dev/null && echo "Deno: $(deno --version 2>&1 | head -1)" || echo "Deno: NOT INSTALLED" |
| 165 | + |
| 166 | +# Start demo server for E2E testing |
| 167 | +serve: |
| 168 | + @echo "Starting Lithoglyph demo server on :8080..." |
| 169 | + cd core-zig && zig run ../demo-server.zig -- -lc |
0 commit comments