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
24 changes: 19 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,11 @@ jobs:
with:
persist-credentials: false

- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
# Differential tests use fixtures recorded from this exact Node release.
node-version: "24.20.0"

- name: Install Rust
run: rustup update stable --no-self-update
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
Expand All @@ -748,18 +753,25 @@ jobs:
run: |
pnpm install

- name: Install Puppeteer browser
if: matrix.workspace == 'rolldown-plugin-jco'
run: pnpm run test:setup:puppeteer

- name: Build workspace dependencies and package
run: |
if [ "${{ matrix.workspace }}" = "jco-std" ]; then
pnpm --filter "packages/jco-transpile" run build
pnpm --filter "packages/${{ matrix.workspace }}" run build
pnpm --filter "./packages/jco-transpile" --fail-if-no-match run build
pnpm --filter "./packages/${{ matrix.workspace }}" --fail-if-no-match run build
else
pnpm --filter "packages/${{ matrix.workspace }}" run build
pnpm --filter "./packages/${{ matrix.workspace }}" --fail-if-no-match run build
fi

- name: run test on workspace
env:
TEST_PUPPETEER_LAUNCH_ARGS: --no-sandbox
TERM: xterm-256color
run: |
pnpm --filter "packages/${{ matrix.workspace }}" run test
pnpm --filter "./packages/${{ matrix.workspace }}" --fail-if-no-match run test

examples:
needs:
Expand Down Expand Up @@ -899,6 +911,8 @@ jobs:
chmod: 0755

- uses: bytecodealliance/actions/wasmtime/setup@9152e710e9f7182e4c29ad218e4f335a7b203613 # v1.1.3
with:
version: v50.0.0

- name: Cache node modules
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
Expand Down Expand Up @@ -949,7 +963,7 @@ jobs:
env:
TEST_PUPPETEER_LAUNCH_ARGS: --no-sandbox
run: |
pnpm --filter '${{ matrix.project.workspace }}' run all
pnpm --filter './${{ matrix.project.workspace }}' --fail-if-no-match run all

examples-perry:
# Perry's WASI target is not released yet. Keep this compiler setup separate
Expand Down
1 change: 1 addition & 0 deletions packages/jco/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"build:ts": "tsc -p tsconfig.json",
"build:types:preview2-shim": "pnpm run build:types:preview2-shim --include-workspace-root",
"build:test:components": "cargo xtask build-test-components",
"bench:componentize-backends": "node test/bench/componentize-backends.mjs",
"bench:serve-isolation": "node test/bench/serve-request-isolation.js",
"fmt": "oxfmt",
"fmt:check": "oxfmt --check",
Expand Down
5 changes: 5 additions & 0 deletions packages/jco/test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

This folder contains tests for Jco.

## Benchmarks

Opt-in performance benchmarks, run instructions, and recent results are in
[`bench/README.md`](./bench/README.md).

## Dependencies

You'll need the following binaries installed in your path or specificed explicitly:
Expand Down
280 changes: 280 additions & 0 deletions packages/jco/test/bench/README.md

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions packages/jco/test/bench/componentize-backends-runner.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { WASIShim } from "@bytecodealliance/preview2-shim/instantiation";
import { createRequire } from "node:module";
import { fileURLToPath, pathToFileURL } from "node:url";

const jco = fileURLToPath(new URL("../../dist/jco.js", import.meta.url));
const requireJco = createRequire(jco);
const host = (name) =>
import(pathToFileURL(requireJco.resolve(`@bytecodealliance/jco-std/wasi/0.2.x/node/24.x.x/${name}`)).href);
const [fs, console, http] = await Promise.all([host("fs/host/node"), host("console/host/node"), host("http/host")]);
const input = fileURLToPath(new URL("./fixtures/filesystem/data/input.txt", import.meta.url));
const mapPath = (path) => (path.tag === "text" && path.val === "/data/input.txt" ? { ...path, val: input } : path);
const wasi = new WASIShim({
sandbox: { preopens: { "/data": fileURLToPath(new URL("./fixtures/filesystem/data/", import.meta.url)) } },
});
const imports = {
...wasi.getImportObject(),
"jco:node/fs": {
...fs,
readFile: (file, options) =>
fs.readFile(file.tag === "path" ? { ...file, val: mapPath(file.val) } : file, options),
stat: (path, options) => fs.stat(mapPath(path), options),
},
"jco:node/console": console,
"jco:node/http": http,
};
const start = process.hrtime.bigint();
const { instantiate } = await import(pathToFileURL(process.argv[2]).href);
const { run } = await instantiate(undefined, imports);
const runStart = process.hrtime.bigint();
await run.run();
const end = process.hrtime.bigint();
const runMs = Number(end - runStart) / 1e6;
const loadAndRunMs = Number(end - start) / 1e6;
process.stderr.write(`${JSON.stringify({ runMs, loadAndRunMs })}\n`);
Loading
Loading