Skip to content

Commit b0c7399

Browse files
committed
Initial commit
Signed-off-by: James Sturtevant <jsturtevant@gmail.com>
0 parents  commit b0c7399

141 files changed

Lines changed: 33932 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
---
2+
name: justfile-ci
3+
description: >
4+
Guide for editing Justfiles and GitHub Actions CI workflows in this repository.
5+
Use when the user asks to add, modify, or remove build/test/lint/format steps,
6+
add new CI jobs, update Justfile recipes, or wire new tasks into the build system.
7+
Trigger phrases: "add to CI", "add a just recipe", "update the Justfile",
8+
"add a test step", "wire into CI", "add to the build", "new CI job".
9+
---
10+
11+
# Justfile & CI Editing Guide
12+
13+
## Architecture
14+
15+
This repo uses a **hierarchical Justfile** structure with a matching **GitHub Actions CI** workflow.
16+
17+
### Justfile Hierarchy
18+
19+
```
20+
Justfile (root) ← orchestrates everything
21+
├── mod wasm 'src/wasm_sandbox/Justfile'
22+
├── mod jssandbox 'src/javascript_sandbox/Justfile'
23+
├── mod nanvix 'src/nanvix_sandbox/Justfile'
24+
├── mod python 'src/sdk/python/Justfile'
25+
└── mod examples_mod 'examples/Justfile'
26+
```
27+
28+
- Root recipes (`test`, `build-all`, `lint`, `fmt`) delegate to subproject recipes via `mod::recipe` syntax
29+
- Subproject Justfiles own environment setup (e.g. `WIT_WORLD` for WASM)
30+
- Root Justfile uses `set unstable := true` to enable module imports
31+
- Justfiles are organized with `#### SECTION ####` headers (BUILD TARGETS, TESTS, DOCS, etc.)
32+
- Section headers must have a blank line after them to avoid becoming recipe doc comments in `just --list`
33+
- Example recipes are flat: one `examples` recipe listing all `cargo run`/`uv run` commands directly (no per-example helper recipes)
34+
35+
### CI Structure
36+
37+
`.github/workflows/ci.yml` has separate jobs per subproject. Each job calls `just` recipes — never raw `cargo`/`python` commands.
38+
39+
See `references/architecture.md` for the full CI job layout and Justfile recipe map.
40+
41+
## Workflow: Adding a New Step
42+
43+
1. **Add the recipe to the subproject Justfile** — include any env setup, deps, and the actual command
44+
2. **Wire it into the root Justfile** if it should be part of `test`, `lint`, `fmt`, `build-all`, or `examples`
45+
3. **Add the CI step** — call the `just` recipe from the appropriate CI job
46+
4. **Verify alignment** — root `just test` should run the same test steps that CI runs
47+
48+
## Rules
49+
50+
### Justfile Rules
51+
- Always add recipes to the **subproject Justfile first**, then reference from root via `mod::recipe`
52+
- Don't create root-level wrapper recipes for things that can be called as `mod::recipe` directly
53+
- Subproject recipes handle their own env setup (e.g. `WIT_WORLD`, `CARGO_MANIFEST_DIR`)
54+
- Use recipe dependencies for ordering: `test: build lint` not separate commands
55+
- Use `#### SECTION ####` headers to group recipes; keep a blank line after the header
56+
- Keep comments minimal — don't restate the recipe name; only add comments for non-obvious behavior
57+
- Use `default-target` parameter pattern for build profile selection
58+
- Example recipes should be flat lists of commands in one `examples` recipe, not separate per-example recipes
59+
60+
### CI Rules
61+
- CI steps must call `just` recipes — never bypass with raw commands
62+
- Each subproject has its own CI job (don't mix unrelated subprojects)
63+
- Exception: Python SDK runs in the `wasm-sandbox` job to avoid rebuilding
64+
- KVM setup is required for jobs that run Hyperlight sandboxes
65+
- `just` is installed via `cargo install --locked just` in each job
66+
67+
### Alignment Rule
68+
- Root `just test` and CI must test the same things
69+
- When adding a test step to CI, verify it's also called from `just test`
70+
- When adding a `just test` dependency, verify CI runs it too
71+
72+
## Common Patterns
73+
74+
### Adding a test recipe to a subproject
75+
```just
76+
# In subproject Justfile:
77+
test target=default-target:
78+
{{ wit-world }} cargo test --manifest-path {{repo-root}}/path/Cargo.toml --profile={{ if target == "debug" {"dev"} else { target } }} --test my_test
79+
```
80+
81+
### Wiring it into root
82+
```just
83+
# In root Justfile — add to test deps:
84+
test: wasm::guest-build wasm::js-guest-build python::build python::python-test test-rust wasm::test
85+
```
86+
87+
### Adding to CI
88+
```yaml
89+
# In ci.yml — add step to appropriate job:
90+
- name: Integration tests
91+
run: just wasm test
92+
```
93+
94+
### Recipe with feature flags
95+
```just
96+
test-rust:
97+
cargo test -p hyperlight-sandbox --features test-utils
98+
99+
lint-rust:
100+
cargo clippy -p hyperlight-sandbox --all-targets --features test-utils -- -D warnings
101+
```
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Justfile & CI Architecture Reference
2+
3+
## Root Justfile Recipe Map
4+
5+
| Recipe | Delegates to | Purpose |
6+
|--------|-------------|---------|
7+
| `build-all` | `wasm::build`, `jssandbox::build`, `nanvix::build`, `python::build` | Build everything |
8+
| `test` | `test-rust`, `wasm::test`, `python::python-test` | All tests |
9+
| `test-rust` | (direct cargo) | Core crate unit + integration tests |
10+
| `lint` | `lint-rust`, `wasm::lint`, `jssandbox::lint`, `python::lint` | All linters |
11+
| `fmt` | `fmt-rust`, `python::fmt` | Format all code |
12+
| `fmt-check` | `fmt-check-rust`, `python::fmt-check` | Check formatting |
13+
| `examples` | `wasm::examples`, `jssandbox::examples`, `python::examples` | Run all examples |
14+
| `fuzz` | `python::python-fuzz` | Python fuzz tests |
15+
| `benchmark` | `python::python-sandbox-benchmark` | Python benchmark |
16+
| `clean` | `wasm::clean`, `python::clean` | Clean build artifacts |
17+
18+
## CI Job Layout
19+
20+
```
21+
ci.yml
22+
├── rust — fmt-check-rust, lint-rust, test-rust
23+
├── wasm-sandbox — wasm build, lint, test, examples + python fmt-check/lint/build/examples/python-test/fuzz/benchmark/integration-examples
24+
├── javascript-sandbox — jssandbox build, lint, test, examples
25+
└── nanvix-sandbox — nanvix build (examples skipped pending upstream)
26+
```
27+
28+
## Subproject Justfile Responsibilities
29+
30+
### wasm (`src/wasm_sandbox/Justfile`)
31+
- Sets `WIT_WORLD` env var (required for compilation)
32+
- Builds Python/JS guest WASM components and AOT compiles them
33+
- Manages `wasm-tools` and `hyperlight-wasm-aot` tool installation
34+
- Recipes: `guest-build`, `js-guest-build`, `build`, `test`, `examples`, `lint`, `clean`
35+
- `examples` is a flat recipe listing all `cargo run` commands (no per-example sub-recipes)
36+
37+
### jssandbox (`src/javascript_sandbox/Justfile`)
38+
- Needs WIT world from wasm for compilation
39+
- Recipes: `build`, `test`, `examples`, `lint`
40+
- `examples` is a flat recipe listing all `cargo run` commands
41+
42+
### nanvix (`src/nanvix_sandbox/Justfile`)
43+
- Standalone build, excluded from workspace
44+
- Recipes: `build`, `examples` (currently skipped)
45+
46+
### python (`src/sdk/python/Justfile`)
47+
- Manages `uv`, `maturin`, `ruff` tooling
48+
- Recipes: `build`, `fmt`, `fmt-check`, `lint`, `examples`, `python-test`, `python-fuzz`, `python-sandbox-benchmark`, `python-publish`
49+
- `examples` is a flat recipe listing all `uv run python` commands
50+
- `lint-rust` in root needs `--features test-utils` because `--all-targets` compiles integration tests
51+
52+
## Key Environment Variables
53+
54+
| Variable | Required by | Purpose |
55+
|----------|------------|---------|
56+
| `WIT_WORLD` | WASM + JS sandbox builds | Path to compiled WIT world (`src/wasm_sandbox/wit/sandbox-world.wasm`) |
57+
| `COPILOT_GITHUB_TOKEN` | Integration examples | GitHub token for Copilot SDK examples |
58+
59+
## CI Job Dependencies and Setup
60+
61+
All jobs need:
62+
- `just` installed via `cargo install --locked just`
63+
64+
WASM/JS jobs additionally need:
65+
- KVM enabled (for Hyperlight VM)
66+
- `clang` installed
67+
68+
WASM job additionally needs:
69+
- Python 3.12 + `uv` (for guest componentize-py)
70+
- Node.js + npm (for JS guest build)

.github/act-event.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"act": true
3+
}

.github/copilot-instructions.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Copilot Instructions
2+
3+
- When running examples in this repository, use the `Justfile` recipes instead of invoking `cargo run` or `python` directly.
4+
- Use `just examples` from the repository root to run the full example suite.
5+
- To run examples for a specific sandbox, use module-scoped recipes: `just wasm examples`, `just jssandbox examples`, `just python examples`.
6+
- Use `just build-all` from the repository root to build all subprojects and SDKs.
7+
- Reason: the example commands depend on `WIT_WORLD` being set to `src/wasm_sandbox/wit/sandbox-world.wasm`; the `Justfile` handles that setup.
8+
9+
Make things cross-platform where possible (window/mac/linux). Mac supprot for hyperlight isn't avaliable yet but is coming.
10+
11+
- **After changing WIT interfaces**: you must run `just build-all` (or at minimum rebuild the guest `.wasm` and `.aot` files) before running examples. The pre-compiled guest binaries embed the WIT signature; a mismatch causes "Host function vector parameter missing length" errors at runtime.
12+
13+
- **Formatting and linting**: always use `just fmt` and `just fmt-check` from the repository root instead of invoking `cargo fmt`, `ruff format`, or `ruff check` directly. The Justfile recipes run multiple tools in sequence (e.g. `ruff format` + `ruff check --fix` for Python) and missing a step causes CI failures.

.github/dependabot.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
version: 2
2+
updates:
3+
# GitHub Actions
4+
- package-ecosystem: "github-actions"
5+
directory: "/"
6+
schedule:
7+
interval: "weekly"
8+
9+
# Rust (root workspace)
10+
- package-ecosystem: "cargo"
11+
directory: "/"
12+
schedule:
13+
interval: "weekly"
14+
15+
# Rust (Python wasm backend — separate workspace)
16+
- package-ecosystem: "cargo"
17+
directory: "/src/sdk/python/wasm_backend"
18+
schedule:
19+
interval: "weekly"
20+
21+
# Rust (Python hyperlight-js backend — separate workspace)
22+
- package-ecosystem: "cargo"
23+
directory: "/src/sdk/python/hyperlight_js_backend"
24+
schedule:
25+
interval: "weekly"
26+
27+
# Rust (Python pyo3 common — separate workspace)
28+
- package-ecosystem: "cargo"
29+
directory: "/src/sdk/python/pyo3_common"
30+
schedule:
31+
interval: "weekly"
32+
33+
# Python (uv/pip)
34+
- package-ecosystem: "pip"
35+
directory: "/"
36+
schedule:
37+
interval: "weekly"
38+
39+
# npm (JavaScript guest)
40+
- package-ecosystem: "npm"
41+
directory: "/src/wasm_sandbox/guests/javascript"
42+
schedule:
43+
interval: "weekly"

.github/hooks/hooks.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"hooks": {
3+
"PostToolUse": [
4+
{
5+
"type": "command",
6+
"command": "bash .vscode/run-just-post-session.sh",
7+
"timeout": 1800
8+
}
9+
]
10+
}
11+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
payload="$(cat)"
5+
6+
# Run only after file-modifying tool calls.
7+
if [[ "$payload" != *'replace_string_in_file'* && \
8+
"$payload" != *'multi_replace_string_in_file'* && \
9+
"$payload" != *'create_file'* && \
10+
"$payload" != *'edit_notebook_file'* ]]; then
11+
exit 0
12+
fi
13+
14+
just fmt
15+
just lint

0 commit comments

Comments
 (0)