Skip to content

Add unified build script and improve test validation#6

Merged
rjrodger merged 10 commits intomainfrom
claude/fix-build-script-44pLJ
Mar 5, 2026
Merged

Add unified build script and improve test validation#6
rjrodger merged 10 commits intomainfrom
claude/fix-build-script-44pLJ

Conversation

@rjrodger
Copy link
Contributor

@rjrodger rjrodger commented Mar 5, 2026

Summary

This PR introduces a unified build system for creating standalone executables of voxgig-apidef across multiple runtimes (Bun, Deno, Node.js SEA) and platforms, along with enhanced test validation to ensure correctness of generated API definitions.

Key Changes

  • New unified build script (cmd/build.sh): Single entry point for building standalone executables with support for:

    • Multiple targets: Bun, Deno, Node.js Single Executable Application (SEA)
    • Cross-platform compilation (linux-x64, linux-arm64, darwin-x64, darwin-arm64, windows-x64)
    • Automatic tool detection and installation (e.g., Deno auto-install)
    • Consistent verification and reporting across all targets
  • Enhanced test validation (cmd/test/run-test.js):

    • Added validateGuide() function that checks generated API guide structure against expected schema
    • Validates entity definitions, paths, operations, and metrics
    • Writes correctness validation results to correctness.json for external comparison
    • Ensures guide correctness is verified in all runtime environments (Node, Bun, SEA, Deno)
  • Improved test comparison (cmd/test/build-and-test.sh):

    • Added correctness validation checks when comparing test outputs
    • Validates reference output correctness before running target comparisons
    • Reports correctness status alongside other output comparisons
  • Refactored Deno build script (cmd/deno/build.sh):

    • Simplified to focus on core Deno compilation logic
    • Removed inline entry point generation (now handled by unified script)
    • Added esbuild bundling step for better CommonJS compatibility
    • Improved error handling and output reporting
  • Documentation (cmd/README.md): New guide documenting build targets, platforms, usage examples, and prerequisites

  • Build output organization: Added cmd/build/ to .gitignore for generated executables

  • Dependency update: Updated aontu peer dependency from >=0.36.0 to ^0.37.0

Implementation Details

  • The unified build script uses helper functions (exe_name, verify_exe, report) to standardize output naming and verification across targets
  • Cross-compilation is supported for Bun and Deno; Node SEA only builds natively
  • Test validation uses deep-contains semantics to check only specified keys in the expected guide structure
  • Deno builds now include esbuild bundling to resolve CommonJS requires before compilation
  • CA certificate auto-detection for Deno in restricted environments

https://claude.ai/code/session_01PuRnKkrSs3UDHo5VifnCs4

claude added 10 commits March 5, 2026 10:37
The script had two versions concatenated: one using $DIST_DIR with main.ts,
another creating an inline entry.ts wrapper with $BUILD_DIR. This caused
duplicate variable declarations, orphaned compile flags after echo "Done.",
and a script that could not execute.

Resolved by keeping the Deno installation check, using the existing main.ts
entry point (the proper Deno-native implementation), and including all
necessary permissions (--allow-sys, --node-modules-dir=auto).

https://claude.ai/code/session_01PuRnKkrSs3UDHo5VifnCs4
run-test.js now validates the guide output against the expected solar
guide structure (entities, paths, operations, actions, metrics) matching
the SOLAR_GUIDE assertions from the main test suite. This closes the gap
where cmd experiments only tested output equivalence across runtimes but
not correctness of the output itself.

build-and-test.sh checks correctness.json for both the Node.js reference
and each runtime executable, failing the build if the guide structure
doesn't match expectations.

https://claude.ai/code/session_01PuRnKkrSs3UDHo5VifnCs4
The correctness.json has "ok": true (with space after colon) but the
grep pattern expected "ok":true (no space). Updated to "ok": *[a-z]*
to handle both formats.

https://claude.ai/code/session_01PuRnKkrSs3UDHo5VifnCs4
- Bundle with esbuild before deno compile (same as Node SEA) so all
  CommonJS require() calls are resolved into a single file
- Auto-detect DENO_CERT from system CA bundle for environments with
  custom certificates
- Add --no-check to skip type-checking the esbuild bundle
- Add --unstable-detect-cjs for Deno 2.x CommonJS compatibility

All three executables now pass: 19 PASS, 0 FAIL, 0 SKIP.

https://claude.ai/code/session_01PuRnKkrSs3UDHo5VifnCs4
cmd/build.sh <target> [os-arch] builds standalone executables for
bun, deno, node-sea, or all three. Supports cross-compilation via
os-arch argument (linux-x64, linux-arm64, darwin-x64, darwin-arm64,
windows-x64). Defaults to current platform when os-arch is omitted.

https://claude.ai/code/session_01PuRnKkrSs3UDHo5VifnCs4
Drop Node 18/20/22 matrix entries, replace with 24.x and latest.
Bump actions/checkout and actions/setup-node to v4. Simplify test
step to just `npm test`.

https://claude.ai/code/session_01PuRnKkrSs3UDHo5VifnCs4
@rjrodger rjrodger merged commit 686e897 into main Mar 5, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants