From 1c42ba66138a66b12c0b5575c6c709923984658e Mon Sep 17 00:00:00 2001 From: Vikash Loomba Date: Wed, 29 Jul 2026 17:27:57 -0700 Subject: [PATCH 1/3] ci: add canonical build-wasm workflow (pinned toolchain, artifacts, sha256 summary) Builds quickjs.wasm and the five extension .so files with the exact toolchain pins (wasi-sdk 32 via the Makefile, binaryen 130.0.0 via the frozen lockfile, pnpm 10.30.3 via packageManager, Node 24.15.0), runs the test suite against the built binary, uploads all six artifacts, and prints their sha256 in the job summary. Verified byte-identical to the published quickjs-wasi@3.2.0 npm artifacts. Claude-Session: https://claude.ai/code/session_01MgymXCZfQjmjZTxgHjEsE7 --- .github/workflows/build-wasm.yml | 108 +++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 .github/workflows/build-wasm.yml diff --git a/.github/workflows/build-wasm.yml b/.github/workflows/build-wasm.yml new file mode 100644 index 0000000..5a4aa81 --- /dev/null +++ b/.github/workflows/build-wasm.yml @@ -0,0 +1,108 @@ +# 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: + +env: + WASI_SDK: ${{ runner.temp }}/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 From 1e94a49d5c6d91a3fb5a0f9785783097c9ba844c Mon Sep 17 00:00:00 2001 From: Vikash Loomba Date: Wed, 29 Jul 2026 17:27:57 -0700 Subject: [PATCH 2/3] docs: correct wasi-sdk pin in Development section (v30 -> v32) The Makefile pins WASI_SDK_VERSION_REQUIRED = 32 and check-wasi-sdk hard-fails on any other version; the README still said v30 and showed a hardcoded wasi-sdk-30 download URL. Point readers at 'make setup', which honors the Makefile pin. Claude-Session: https://claude.ai/code/session_01MgymXCZfQjmjZTxgHjEsE7 --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index c2c50f2..104e2bf 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 From a6a339885997519d80777f0709579d0285414d64 Mon Sep 17 00:00:00 2001 From: Vikash Loomba Date: Wed, 29 Jul 2026 17:29:20 -0700 Subject: [PATCH 3/3] fix(ci): use a literal WASI_SDK path in workflow-level env The runner context is not available in workflow-level env, which made the workflow file invalid and failed the run at parse time. Use the Makefile's default /tmp/wasi-sdk instead. Claude-Session: https://claude.ai/code/session_01MgymXCZfQjmjZTxgHjEsE7 --- .github/workflows/build-wasm.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-wasm.yml b/.github/workflows/build-wasm.yml index 5a4aa81..c893a4e 100644 --- a/.github/workflows/build-wasm.yml +++ b/.github/workflows/build-wasm.yml @@ -25,8 +25,10 @@ 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: ${{ runner.temp }}/wasi-sdk + WASI_SDK: /tmp/wasi-sdk jobs: build-wasm: