Skip to content
Merged
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
78 changes: 78 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: ci

on:
push:
branches: [main]
pull_request:

permissions:
contents: read

env:
# Immutable SDK commit (Perfscale/sdk-libraries, feat/wasm-step-sdk):
# defineSteps + --kind steps build + settings delivery.
SDK_COMMIT: 522cfdd590062652c04337e6dfdcfc1c2c79389e

jobs:
build-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
path: repo
# The SDK is a file: sibling dependency (../sdk-step-authoring/ts);
# pin it to an exact public commit.
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
repository: Perfscale/sdk-libraries
ref: feat/wasm-step-sdk
path: sdk-step-authoring
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: 24
- name: Verify the pinned SDK commit
working-directory: sdk-step-authoring
run: test "$(git rev-parse HEAD)" = "$SDK_COMMIT"
- name: Install and build SDK (dist + type declarations)
working-directory: sdk-step-authoring/ts
run: |
npm ci
npm run build
- name: Install, typecheck, unit-test
working-directory: repo
run: |
npm install
npm run typecheck
npm test
- name: Build the WASM component
working-directory: repo
run: npm run build
- name: Inspect component imports/exports
working-directory: repo
run: ../sdk-step-authoring/ts/node_modules/.bin/jco wit nodejs.wasm
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: nodejs-wasm
path: repo/nodejs.wasm
retention-days: 7

integration:
needs: build-test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
with:
name: nodejs-wasm
path: .
- uses: dtolnay/rust-toolchain@stable
- name: Build Perfscale v0.30.0 from source
run: |
git clone --depth 1 --branch v0.30.0 https://github.com/Perfscale/perfscale.git /tmp/perfscale-src
cargo build --release -p perfscale-cli --manifest-path /tmp/perfscale-src/Cargo.toml
cp /tmp/perfscale-src/target/release/perfscale "$GITHUB_WORKSPACE/perfscale"
"$GITHUB_WORKSPACE/perfscale" --version
- name: Run the example through the engine (settings-driven install + exec)
run: |
"$GITHUB_WORKSPACE/perfscale" run -f examples/node.test.yaml -c examples/node.config.yaml | tee run.log
grep -q 'hello from node v24.16.0' run.log
55 changes: 47 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ scripts can do on the host, they do with the perfscale process's privileges.
or override, string values only).
- `install` never uses sudo and never mutates global state: everything
lands under `install-dir` (default `/tmp/perfscale-toolcache/nodejs`).
It is idempotent — if `<install-dir>/node-v<VERSION>-linux-<ARCH>/bin/node
--version` succeeds, nothing is re-downloaded or re-installed, ever. On a
It is idempotent — if `<install-dir>/node-v<VERSION>-linux-<ARCH>/bin/node`
exists (`test -x`; the host import hard-errors on spawn-ENOENT) and
answers `--version`, nothing is re-downloaded or re-installed, ever. On a
checksum mismatch only the downloaded archive is deleted; install trees
are never `rm`'d.
- `exec` path/`node-path` values are passed verbatim — this is a trusted
Expand Down Expand Up @@ -129,14 +130,51 @@ steps:
use: lib/nodejs/install-exec
with:
node-version: 24.16.0
install-dir: .perfscale-tools/nodejs
install-dir: /tmp/perfscale-toolcache/nodejs # absolute — exec requires an absolute node-path
script: console.log("ok")
outputs: combo
```

Output merges install and exec results: `{ "path", "node-path", "version",
"exit_code", "stdout", "stderr" }`.

## Run settings (RFC 009)

Every step knob may be set once for the whole run instead of repeated per
step. Precedence (highest first):

1. the step's explicit `with:` params
2. the `nodejs:` config extension block (claimed via the component's config
schema — unknown keys fail the run)
3. the `variables.nodejs` map
4. the library entry's `with:` block
5. the built-in defaults

`env` maps merge in that same order (a step's `env` wins per key). Accepted
settings keys: `node-version` (alias `version`), `install-dir`, `node-path`
(alias `executable`), `working-directory` / `cwd`, `timeout_ms` /
`timeoutMs`, `env`. Invalid blocks (unknown key, wrong type, relative
`node-path`, bad version) are hard errors — at instantiation for the
library `with:`, at step resolution for the rest.

```yaml
# perfscale.config.yaml
nodejs: # config extension, validated against the schema
node-version: "24"
install-dir: /tmp/perfscale-toolcache/nodejs # absolute — exec requires an absolute node-path
variables:
nodejs: { timeout_ms: 30000 }
libraries:
- use: ./nodejs.wasm
capabilities: [process]
with: { env: { NODE_ENV: test } } # lowest-precedence defaults
steps:
- name: smoke
use: lib/nodejs/install-exec
with:
script: console.log(process.version) # version/dir come from settings
```

## Orchestration, not hot path

Each step invocation is **real host process spawns** (and `install` may
Expand All @@ -150,7 +188,7 @@ before:
use: lib/nodejs/install
with:
node-version: 24.16.0
install-dir: .perfscale-tools/nodejs
install-dir: /tmp/perfscale-toolcache/nodejs # absolute — exec requires an absolute node-path
outputs: setup # → ${{ config.setup.node-path }} in test steps
```

Expand All @@ -165,10 +203,11 @@ $ npm run build # → nodejs.wasm (needs the SDK bin, see below)
$ perfscale run -f examples/node.test.yaml -c examples/node.config.yaml
```

Run `perfscale` from the **repository root** — `install-dir:
.perfscale-tools/nodejs` (gitignored) is resolved against the process cwd.
The first run downloads Node.js 24.16.0 from nodejs.org; later runs reuse
the cache.
The first run downloads Node.js 24.16.0 from nodejs.org into the default
toolcache (`/tmp/perfscale-toolcache/nodejs`); later runs reuse the cache.
`install-dir` may be relative, but then the installed `node-path` is
relative too and `exec` (which requires an absolute path) will refuse it —
prefer absolute install dirs.

## Development

Expand Down
10 changes: 6 additions & 4 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@ its contract, for example:
skipping the SHA-256 verification against the official `SHASUMS256.txt`
before extraction.
- Spawning anything other than the documented `/usr/bin/uname`,
`/usr/bin/mkdir`, `/usr/bin/curl`, `/usr/bin/sha256sum`, `/usr/bin/tar`,
`/usr/bin/rm` (the downloaded archive only), or the selected node binary.
`/usr/bin/test` (cache probe), `/usr/bin/mkdir`, `/usr/bin/curl`,
`/usr/bin/sha256sum`, `/usr/bin/tar`, `/usr/bin/rm` (the downloaded
archive only), or the selected node binary.
- Leaking host environment variables into a child (the host import already
guarantees a replacement environment; a bug that bypasses it matters).
- The cache-idempotency or bad-archive cleanup deleting anything other than
the downloaded `.tar.xz` archive.
- Validation gaps that let crafted `with:` params alter the spawned argv in
undocumented ways.
- Validation gaps that let crafted `with:` params or settings blocks
(extension / variables / library `with:`) alter the spawned argv or
environment in undocumented ways.

## What is out of scope

Expand Down
15 changes: 12 additions & 3 deletions examples/node.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,25 @@ seed: 42
# side, the engine refuses to load the component (fail-closed, like `net`).
allow_library_capabilities: true
allow_process_actions: true
# Run-level settings (RFC 009): the `nodejs` extension block is claimed by
# the component's config schema; a step's explicit `with:` still wins over
# it, `variables.nodejs` sits one level below it, and the library entry's
# `with:` provides defaults below both. install-dir stays at its (absolute)
# built-in default — exec requires an absolute node-path.
nodejs:
timeout_ms: 60000
variables:
nodejs: { timeout_ms: 30000 }
libraries:
- use: ../nodejs.wasm
capabilities: [process]
before:
# Pinned exact version, checksum-verified against the official
# nodejs.org SHASUMS256.txt. Installs into a repo-local toolcache
# (gitignored); subsequent runs reuse it — nothing is re-downloaded.
# nodejs.org SHASUMS256.txt. Installs into the default toolcache
# (/tmp/perfscale-toolcache/nodejs); subsequent runs reuse it — nothing is
# re-downloaded.
- name: node
use: lib/nodejs/install
with:
node-version: 24.16.0
install-dir: .perfscale-tools/nodejs
outputs: setup # → ${{ config.setup.node-path }} in test steps
5 changes: 1 addition & 4 deletions examples/node.test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
# npm run build # → ../nodejs.wasm relative to this file's examples dir
#
# perfscale run -f examples/node.test.yaml -c examples/node.config.yaml
# (run from the repository root — `install-dir: .perfscale-tools/nodejs`
# is resolved against the process cwd)
#
# NOTE: process steps are orchestration (setup, fixtures, one-off checks),
# not a high-RPS hot path — each invocation is a real host spawn.
Expand All @@ -24,8 +22,7 @@ steps:
- name: install-exec-one-shot
use: lib/nodejs/install-exec
with:
node-version: 24.16.0
install-dir: .perfscale-tools/nodejs # cache hit — no re-download
node-version: 24.16.0 # cache hit — no re-download
script: console.log(JSON.stringify(process.argv.slice(2)))
args: ["perfscale"]
outputs: combo
Expand Down
Loading
Loading