Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
32998df
feat: allow spin as a supported config store adapter
Apr 24, 2026
1022cd7
docs: update adapters field comment to include spin
Apr 24, 2026
5bb8051
feat: add SpinConfigStore backed by spin_sdk::variables
Apr 24, 2026
d64e95d
fix: rename SpinConfigBackend and remove feature gate on config_store…
Apr 24, 2026
53dfa1c
fix: fmt ordering in lib.rs and add SpinConfigStore to ConfigStore tr…
Apr 24, 2026
917ff57
feat: add SpinSecretStore backed by spin_sdk::variables
Apr 24, 2026
8a4e227
feat: add SpinKvStore backed by spin_sdk::key_value
Apr 24, 2026
ac8facb
chore: remove stale 'not yet implemented' note from run_app doc comment
Apr 24, 2026
a0ec8e6
ci: add spin-adapter-tests job
Apr 24, 2026
cf57f58
fix: handle InvalidName in SpinSecretStore and restore allow(unused_v…
Apr 24, 2026
ec7dc14
feat: add configurable max_list_keys cap to SpinKvStore
Apr 24, 2026
a905d5a
feat: wire store handles into Spin dispatch and add contract tests
Apr 24, 2026
11aa462
feat: add Spin adapter support to smoke test scripts
Apr 24, 2026
58c7b6e
chore: ignore .spin/ runtime directory
Apr 24, 2026
b5129da
- Return KvError::Validation when key count exceeds max_list_keys
prk-Jr Apr 25, 2026
c001103
fix CI cache conflict
prk-Jr Apr 25, 2026
3b995e5
Fix test.yml to use matrix run
prk-Jr Apr 29, 2026
4644225
Fix pin viceroy pin and wasmtime install flag
prk-Jr Apr 29, 2026
ff0633b
Fix type mismatch for wasm32-wasip1
prk-Jr Apr 29, 2026
c9d1e25
Address pr review findings
prk-Jr May 14, 2026
8956aba
chore: merge main into feat/spin-store-support
prk-Jr May 14, 2026
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
117 changes: 55 additions & 62 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ jobs:
- name: Add wasm targets
run: rustup target add wasm32-wasip1 wasm32-unknown-unknown

- name: Setup Viceroy
run: cargo install viceroy --locked --force

- name: Fetch dependencies (locked)
run: cargo fetch --locked

Expand All @@ -57,12 +54,25 @@ jobs:
- name: Check feature compilation
run: cargo check --workspace --all-targets --features "fastly cloudflare spin"

- name: Check Spin wasm32 compilation
run: cargo check -p edgezero-adapter-spin --target wasm32-wasip1 --features spin

cloudflare-wasm-tests:
name: cloudflare wasm tests
adapter-wasm-tests:
name: ${{ matrix.adapter }} wasm tests
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- adapter: cloudflare
target: wasm32-unknown-unknown
runner_env: CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_RUNNER
runner_value: wasm-bindgen-test-runner
- adapter: fastly
target: wasm32-wasip1
runner_env: CARGO_TARGET_WASM32_WASIP1_RUNNER
runner_value: viceroy run
- adapter: spin
target: wasm32-wasip1
runner_env: CARGO_TARGET_WASM32_WASIP1_RUNNER
runner_value: wasmtime run
steps:
- uses: actions/checkout@v4

Expand All @@ -74,24 +84,25 @@ jobs:
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-cloudflare-${{ hashFiles('**/Cargo.lock') }}
key: ${{ runner.os }}-cargo-${{ matrix.adapter }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-cloudflare-
${{ runner.os }}-cargo-${{ matrix.adapter }}-

- name: Retrieve Rust version
id: rust-version-cloudflare
id: rust-version
run: echo "rust-version=$(grep '^rust ' .tool-versions | awk '{print $2}')" >> $GITHUB_OUTPUT
shell: bash

- name: Set up Rust tool chain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ steps.rust-version-cloudflare.outputs.rust-version }}
toolchain: ${{ steps.rust-version.outputs.rust-version }}

- name: Add wasm32 target
run: rustup target add wasm32-unknown-unknown
- name: Add wasm target
run: rustup target add ${{ matrix.target }}

- name: Resolve wasm-bindgen CLI version
if: matrix.adapter == 'cloudflare'
id: wasm-bindgen-version
shell: bash
run: |
Expand All @@ -109,60 +120,42 @@ jobs:
echo "version=$version" >> "$GITHUB_OUTPUT"

- name: Install wasm-bindgen test runner
run: cargo install wasm-bindgen-cli --version "${{ steps.wasm-bindgen-version.outputs.version }}" --locked --force

- name: Fetch dependencies (locked)
run: cargo fetch --locked
if: matrix.adapter == 'cloudflare'
run: |
required="${{ steps.wasm-bindgen-version.outputs.version }}"
if ! command -v wasm-bindgen-test-runner &>/dev/null \
|| ! wasm-bindgen --version 2>/dev/null | grep -q "$required"; then
cargo install wasm-bindgen-cli --version "$required" --locked --force
fi

- name: Run Cloudflare wasm tests
- name: Setup Viceroy
if: matrix.adapter == 'fastly'
env:
CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_RUNNER: wasm-bindgen-test-runner
run: cargo test -p edgezero-adapter-cloudflare --features cloudflare --target wasm32-unknown-unknown --test contract

- name: Check Cloudflare wasm target
run: cargo check -p edgezero-adapter-cloudflare --features cloudflare --target wasm32-unknown-unknown

fastly-wasm-tests:
name: fastly wasm tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Cache Cargo dependencies
uses: actions/cache@v4
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-fastly-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-fastly-

- name: Retrieve Rust version
id: rust-version-fastly
run: echo "rust-version=$(grep '^rust ' .tool-versions | awk '{print $2}')" >> $GITHUB_OUTPUT
shell: bash

- name: Set up Rust tool chain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ steps.rust-version-fastly.outputs.rust-version }}

- name: Add wasm targets
run: rustup target add wasm32-wasip1
VICEROY_VERSION: 0.16.5
run: |
if ! command -v viceroy &>/dev/null \
|| ! viceroy --version 2>/dev/null | grep -qF "$VICEROY_VERSION"; then
cargo install viceroy --version "$VICEROY_VERSION" --locked
fi

- name: Setup Viceroy
run: cargo install viceroy --locked --force
- name: Setup Wasmtime
if: matrix.adapter == 'spin'
env:
WASMTIME_VERSION: v44.0.0
run: |
if ! command -v wasmtime &>/dev/null \
|| ! wasmtime --version 2>/dev/null | grep -qF "${WASMTIME_VERSION#v}"; then
curl https://wasmtime.dev/install.sh -sSf | bash -s -- --version "$WASMTIME_VERSION"
echo "$HOME/.wasmtime/bin" >> "$GITHUB_PATH"
fi

- name: Fetch dependencies (locked)
run: cargo fetch --locked

- name: Run Fastly wasm tests
- name: Run ${{ matrix.adapter }} wasm tests
env:
CARGO_TARGET_WASM32_WASIP1_RUNNER: "viceroy run"
run: cargo test -p edgezero-adapter-fastly --features fastly --target wasm32-wasip1 --test contract
${{ matrix.runner_env }}: ${{ matrix.runner_value }}
run: cargo test -p edgezero-adapter-${{ matrix.adapter }} --features ${{ matrix.adapter }} --target ${{ matrix.target }} --test contract

- name: Check Fastly wasm target
run: cargo check -p edgezero-adapter-fastly --features fastly --target wasm32-wasip1
- name: Check ${{ matrix.adapter }} wasm target
run: cargo check -p edgezero-adapter-${{ matrix.adapter }} --features ${{ matrix.adapter }} --target ${{ matrix.target }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ bin/
pkg/
target/
.wrangler/
.spin/
.edgezero/

# env
Expand Down
82 changes: 82 additions & 0 deletions crates/edgezero-adapter-spin/src/config_store.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
//! Spin adapter config store: wraps `spin_sdk::variables`.

use edgezero_core::config_store::{ConfigStore, ConfigStoreError};

/// Config store backed by Spin component variables.
pub struct SpinConfigStore {
inner: SpinConfigBackend,
}

enum SpinConfigBackend {
#[cfg(target_arch = "wasm32")]
Spin,
#[cfg(test)]
InMemory(std::collections::HashMap<String, String>),
/// Never constructed; keeps the enum inhabited in non-wasm32, non-test builds.
#[cfg(not(any(target_arch = "wasm32", test)))]
_Uninhabited(std::convert::Infallible),
}

impl SpinConfigStore {
/// Create a new `SpinConfigStore` using the Spin variables API.
#[cfg(target_arch = "wasm32")]
pub fn new() -> Self {
Self {
inner: SpinConfigBackend::Spin,
}
}

#[cfg(test)]
fn from_entries(entries: impl IntoIterator<Item = (String, String)>) -> Self {
Self {
inner: SpinConfigBackend::InMemory(entries.into_iter().collect()),
}
}
}

#[cfg(target_arch = "wasm32")]
impl Default for SpinConfigStore {
fn default() -> Self {
Self::new()
}
}

impl ConfigStore for SpinConfigStore {
fn get(&self, _key: &str) -> Result<Option<String>, ConfigStoreError> {
match &self.inner {
#[cfg(target_arch = "wasm32")]
SpinConfigBackend::Spin => {
use spin_sdk::variables;
match variables::get(_key) {
Ok(value) => Ok(Some(value)),
Err(variables::Error::Undefined(_)) => Ok(None),
Err(variables::Error::InvalidName(msg)) => {
Err(ConfigStoreError::invalid_key(msg))
}
Err(e) => Err(ConfigStoreError::unavailable(e.to_string())),
}
}
#[cfg(test)]
SpinConfigBackend::InMemory(data) => Ok(data.get(_key).cloned()),
#[cfg(not(any(target_arch = "wasm32", test)))]
SpinConfigBackend::_Uninhabited(never) => match *never {},
}
}
}

#[cfg(test)]
mod tests {
use super::*;

// These contract tests exercise the InMemory backend (not the real Spin
// variables API). Dotted keys such as "contract.key.a" are valid here but
// would trigger `InvalidName` on the real Spin backend, which requires
// lowercase variable names without dots. Real-backend behaviour is
// verified by the smoke tests in scripts/smoke_test_config.sh.
edgezero_core::config_store_contract_tests!(spin_config_store_contract, {
SpinConfigStore::from_entries([
("contract.key.a".to_string(), "value_a".to_string()),
("contract.key.b".to_string(), "value_b".to_string()),
])
});
}
Loading
Loading