Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
run: cargo test --workspace --all-targets

- name: Check feature compilation
run: cargo check --workspace --all-targets --features "fastly cloudflare"
run: cargo check --workspace --all-targets --features "fastly cloudflare spin"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 CI gate feature list properly extended (and CLAUDE.md:164 updated in lockstep).

🌱 Follow-up seed: the workflow installs only wasm32-wasip1, and the spin wasm is never actually built in CI — only cargo check --features runs on host. That matches the pre-existing pattern for Fastly, but means a breakage in the target-gated blocks of src/lib.rs wouldn't be caught. Worth a separate issue to tighten wasm build coverage across all three wasm adapters.


playwright:
name: playwright tests
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
**/bin/
**/pkg/

# Spin runtime logs
.spin/logs/
**/.spin/logs/

# env
.env

Expand Down
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ Every PR must pass:
1. `cargo fmt --all -- --check`
2. `cargo clippy --workspace --all-targets --all-features -- -D warnings`
3. `cargo test --workspace --all-targets`
4. `cargo check --workspace --all-targets --features "fastly cloudflare"`
4. `cargo check --workspace --all-targets --features "fastly cloudflare spin"`
5. Playwright e2e tests (`tests/playwright/`)
6. ESLint + Prettier on `docs/`

Expand Down
154 changes: 147 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ members = [
"crates/mocktioneer-adapter-axum",
"crates/mocktioneer-adapter-cloudflare",
"crates/mocktioneer-adapter-fastly",
"crates/mocktioneer-adapter-spin",
]
resolver = "2"

Expand All @@ -24,9 +25,11 @@ ed25519-dalek = "2.1"
edgezero-adapter-axum = { git = "https://github.com/stackpop/edgezero.git", branch = "main", package = "edgezero-adapter-axum", default-features = false }
edgezero-adapter-cloudflare = { git = "https://github.com/stackpop/edgezero.git", branch = "main", package = "edgezero-adapter-cloudflare", default-features = false }
edgezero-adapter-fastly = { git = "https://github.com/stackpop/edgezero.git", branch = "main", package = "edgezero-adapter-fastly", default-features = false }
edgezero-adapter-spin = { git = "https://github.com/stackpop/edgezero.git", branch = "main", package = "edgezero-adapter-spin", default-features = false }
edgezero-cli = { git = "https://github.com/stackpop/edgezero.git", branch = "main", package = "edgezero-cli" }
edgezero-core = { git = "https://github.com/stackpop/edgezero.git", branch = "main", package = "edgezero-core" }
fastly = "0.11.9"
spin-sdk = { version = "5.2", default-features = false }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spin-sdk = { ..., default-features = false }. Disabling defaults on the SDK is unusual. It currently compiles only because #[http_component] happens not to require any of the dropped features. What prompted disabling them?

If intentional (e.g., trimming binary size), a one-line comment justifying the choice would help future maintainers avoid "fixing" it back.

futures = { version = "0.3", features = ["std", "executor"] }
futures-util = "0.3.31"
handlebars = "6"
Expand Down
24 changes: 24 additions & 0 deletions crates/mocktioneer-adapter-spin/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[package]
name = "mocktioneer-adapter-spin"
version = "0.1.0"
edition = "2021"
publish = false
Comment thread
ChristianPavilonis marked this conversation as resolved.
license.workspace = true

[lib]
crate-type = ["cdylib"]
path = "src/lib.rs"

[features]
default = []
spin = ["edgezero-adapter-spin/spin"]

[dependencies]
edgezero-adapter-spin = { workspace = true }
Comment thread
ChristianPavilonis marked this conversation as resolved.
edgezero-core = { workspace = true } # direct dep for Cargo feature unification; same pattern as cloudflare/fastly adapters
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Misleading justification comment. The comment claims "same pattern as cloudflare/fastly adapters," but mocktioneer-adapter-fastly/Cargo.toml lists edgezero-core only under [target.'cfg(target_arch = "wasm32")'.dependencies]not unconditionally. Only Cloudflare matches the unconditional placement.

Either:

  • (a) correct the comment to reference only Cloudflare, or
  • (b) move edgezero-core to target-gated deps (matching Fastly's leaner pattern) and drop the comment.

Which is intended?

mocktioneer-core = { workspace = true }
anyhow = { workspace = true }
Comment thread
ChristianPavilonis marked this conversation as resolved.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

anyhow declared unconditionally but only used in wasm-gated code. The anyhow::Result reference in src/lib.rs:19 is entirely behind #[cfg(target_arch = "wasm32")]. Consider moving anyhow to [target.'cfg(target_arch = "wasm32")'.dependencies] for parity with how the other cfg-gated deps are declared — avoids pulling it into host builds.


[target.'cfg(target_arch = "wasm32")'.dependencies]
edgezero-adapter-spin = { workspace = true, features = ["spin"] }
Comment thread
ChristianPavilonis marked this conversation as resolved.
spin-sdk = { workspace = true }
16 changes: 16 additions & 0 deletions crates/mocktioneer-adapter-spin/spin.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
spin_manifest_version = 3

[application]
name = "mocktioneer-adapter-spin"
version = "0.1.0"

[[trigger.http]]
route = "/..."
component = "mocktioneer"

[component.mocktioneer]
source = "../../target/wasm32-wasip2/release/mocktioneer_adapter_spin.wasm"
allowed_outbound_hosts = []
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Tight allowed_outbound_hosts = [] aligns nicely with Mocktioneer's deterministic / self-contained design. Good default.

[component.mocktioneer.build]
command = "cargo build --target wasm32-wasip2 --release -p mocktioneer-adapter-spin"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Flag-order drift between two build commands. This line has cargo build --target wasm32-wasip2 --release -p ..., while edgezero.toml line 213 has cargo build --release --target wasm32-wasip2 -p .... Functionally identical but byte-different — align flag order in both places to avoid "are these actually the same?" diffs later.

🌱 Also: the watch list only covers src/**/*.rs and Cargo.toml. Changes to mocktioneer-core/src/**/*.rs or edgezero.toml won't retrigger during spin watch. Worth revisiting once Spin is in active dev use.

watch = ["src/**/*.rs", "Cargo.toml"]
21 changes: 21 additions & 0 deletions crates/mocktioneer-adapter-spin/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//! Spin adapter for Mocktioneer.
//!
//! This crate is a `cdylib` targeting `wasm32-wasip2`. All runtime code is
//! gated behind `#[cfg(target_arch = "wasm32")]` so the crate compiles (but is
//! empty) on the host target, allowing `cargo fmt`, `cargo clippy`, and
//! `cargo test` to run across the whole workspace without pulling in WASM-only
//! dependencies.
#![cfg_attr(not(target_arch = "wasm32"), allow(dead_code, unused_imports))]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused_imports allow looks unnecessary. Every use in this file is already cfg-gated, so nothing is actually unused on host. The Fastly equivalent uses only allow(dead_code). Is unused_imports load-bearing (e.g., leftover from an earlier iteration)? If not, drop it for consistency.


#[cfg(target_arch = "wasm32")]
Comment thread
ChristianPavilonis marked this conversation as resolved.
use mocktioneer_core::MocktioneerApp;
#[cfg(target_arch = "wasm32")]
use spin_sdk::http::{IncomingRequest, IntoResponse};
#[cfg(target_arch = "wasm32")]
use spin_sdk::http_component;

#[cfg(target_arch = "wasm32")]
#[http_component]
async fn handle(req: IncomingRequest) -> anyhow::Result<impl IntoResponse> {
edgezero_adapter_spin::run_app::<MocktioneerApp>(req).await
}
Loading
Loading