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
110 changes: 110 additions & 0 deletions .github/workflows/build-wasm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# Canonical quickjs.wasm build pipeline.
#
# This workflow defines the canonical artifact: every workspace snapshot is laid
# out by a specific build of quickjs.wasm, so the binary must be reproducible
# from source with exactly pinned toolchains.
#
# Toolchain pins (all exact):
# - wasi-sdk: version required by the Makefile (WASI_SDK_VERSION_REQUIRED,
# currently 32 -> release tarball wasi-sdk-32.0). `make setup`
# downloads it and `make check-wasi-sdk` hard-fails on mismatch,
# so the Makefile remains the single source of truth.
# - binaryen (wasm-opt): pinned by pnpm-lock.yaml (130.0.0), installed with
# --frozen-lockfile.
# - pnpm: pinned by the package.json "packageManager" field (10.30.3).
# - Node.js: pinned exactly below (does not affect the wasm bytes, but is
# pinned for a fully reproducible test environment).
#
# Reproducibility was verified against the published npm artifact
# (quickjs-wasi@3.2.0): sha256 of quickjs.wasm and all five extension .so
# files are byte-identical when built with these pins.

name: Build WASM

on:
push:
workflow_dispatch:

# The Makefile's default install location; ephemeral on hosted runners.
# (A literal path: the `runner` context is not allowed in workflow-level env.)
env:
WASI_SDK: /tmp/wasi-sdk

jobs:
build-wasm:
name: Build quickjs.wasm + extensions
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive

- name: Setup pnpm
uses: pnpm/action-setup@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 24.15.0
cache: pnpm

- name: Install dependencies (frozen lockfile)
run: pnpm install --frozen-lockfile

- name: Install pinned wasi-sdk
run: make setup

- name: Verify wasi-sdk pin
run: make check-wasi-sdk

- name: Print toolchain versions
run: |
{
echo "## Toolchain versions"
echo '```'
echo "wasi-sdk: $(head -1 "$WASI_SDK/VERSION")"
"$WASI_SDK/bin/clang" --version | head -1
echo "wasm-opt (binaryen): $(node_modules/.bin/wasm-opt --version)"
echo "node: $(node --version)"
echo "pnpm: $(pnpm --version)"
echo '```'
} | tee -a "$GITHUB_STEP_SUMMARY"

- name: Build WASM
run: pnpm run build:wasm

- name: Build TypeScript
run: pnpm run build:ts

- name: Run tests against built binary
run: pnpm test

- name: Artifact checksums
run: |
{
echo "## Artifact sha256"
echo '```'
sha256sum \
quickjs.wasm \
extensions/url/url.so \
extensions/encoding/encoding.so \
extensions/headers/headers.so \
extensions/crypto/crypto.so \
extensions/structured-clone/structured-clone.so
echo '```'
} | tee -a "$GITHUB_STEP_SUMMARY"

- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: quickjs-wasm-${{ github.sha }}
if-no-files-found: error
path: |
quickjs.wasm
extensions/url/url.so
extensions/encoding/encoding.so
extensions/headers/headers.so
extensions/crypto/crypto.so
extensions/structured-clone/structured-clone.so
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@ This design survives snapshot/restore: the name string is stored in QuickJS's he

### Prerequisites

- [wasi-sdk](https://github.com/WebAssembly/wasi-sdk) (tested with v30) — set `WASI_SDK` env var or defaults to `/tmp/wasi-sdk`
- [wasi-sdk](https://github.com/WebAssembly/wasi-sdk) v32 (pinned via `WASI_SDK_VERSION_REQUIRED` in the Makefile; the build fails on any other version) — set `WASI_SDK` env var or defaults to `/tmp/wasi-sdk`
- Node.js >= 22
- pnpm

Expand All @@ -751,9 +751,9 @@ This design survives snapshot/restore: the name string is stored in QuickJS's he
git clone --recursive https://github.com/vercel-labs/quickjs-wasm.git
cd quickjs-wasm

# Install wasi-sdk (macOS arm64 — adjust URL for your platform)
curl -sL "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-30/wasi-sdk-30.0-arm64-macos.tar.gz" \
| tar xz -C /tmp --strip-components=1 --one-top-level=wasi-sdk
# Install the pinned wasi-sdk (auto-detects your platform, installs to $WASI_SDK
# or /tmp/wasi-sdk by default)
make setup

# Install dependencies
pnpm install
Expand Down
Loading