wasm-rquickjs-cli 0.5.3

Tool for wrapping JavaScript modules as WebAssembly components using the QuickJS engine
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
name: CI

on:
  push:
    tags:
      - "v0.5.*"
    branches:
      - main
  pull_request:

concurrency:
  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
  cancel-in-progress: ${{ github.event_name == 'pull_request' }}

permissions:
  checks: write
  pull-requests: write
  contents: write

env:
  CARGO_TERM_COLOR: always
  WASI_SDK_VERSION: "25"
  WASI_SDK_PATH: /opt/wasi-sdk
  # Cache compilation only. Every case still creates a fresh Store, instance,
  # WASI context, QuickJS runtime, and temporary filesystem.
  WASM_RQUICKJS_TEST_WASMTIME_CACHE: "1"
  WASM_RQUICKJS_TEST_PREPARED_COMPONENT_CACHE: "1"
  WASM_RQUICKJS_TEST_PRECOMPILE_COMPONENT: "1"
  # The `build` and `test-other` jobs build and test against Golem's wasmtime
  # fork — see .github/scripts/enable-wasmtime-fork.sh for the rationale. They
  # run that script (which uncomments the [patch.crates-io] block in
  # Cargo.toml) and pass --features use-golem-wasmtime via this variable.
  # The P3 runtime, node-compat and `test-p3` lanes, and the `release-binaries`
  # and `publish` jobs, use the unpatched, crates.io-publishable wasmtime.
  CI_WASMTIME_FORK_FEATURES: --features use-golem-wasmtime

jobs:
  quick-checks:
    runs-on: blacksmith-16vcpu-ubuntu-2404
    steps:
      - uses: actions/checkout@v4
        with:
          submodules: true
      - name: CI reporting contracts
        run: node --test .github/scripts/test_prepare_test_reports.cjs
      - uses: dtolnay/rust-toolchain@stable
        with:
          components: rustfmt
      - name: Check formatting
        run: cargo fmt -- --check

  skeleton-clippy:
    needs: [quick-checks]
    runs-on: blacksmith-16vcpu-ubuntu-2404
    steps:
      - uses: actions/checkout@v4
        with:
          submodules: true
      - uses: ./.github/actions/setup
        with:
          cache-key: skeleton
      - name: Clippy embedded skeleton
        run: tools/check-skeleton-clippy.sh

  build:
    needs: [quick-checks]
    runs-on: blacksmith-16vcpu-ubuntu-2404
    steps:
      - uses: actions/checkout@v4
        with:
          submodules: true
      - uses: ./.github/actions/setup
        with:
          cache-key: fork
          wasmtime-fork: "true"
      - name: Install component license audit tool
        # rust-cache can restore install metadata without the executable.
        run: cargo binstall --force --locked --version 0.9.2 cargo-about
      - name: Check generated component licenses
        run: tools/check-component-licenses.sh --check
      - name: Clippy
        run: cargo clippy $CI_WASMTIME_FORK_FEATURES -- -Dwarnings
      - name: Build
        run: cargo build --all-targets $CI_WASMTIME_FORK_FEATURES
      - name: Local test profile contracts
        run: cargo test --test dev_test_profiles $CI_WASMTIME_FORK_FEATURES
      - name: Node compatibility parser contracts
        run: cargo test --test js_subtest_parser $CI_WASMTIME_FORK_FEATURES -- --report-time
      - name: Module loader architecture contracts
        run: cargo test -p wasm-rquickjs --lib $CI_WASMTIME_FORK_FEATURES -- module_loader_architecture

  test-other:
    needs: [quick-checks]
    runs-on: blacksmith-16vcpu-ubuntu-2404
    steps:
      - uses: actions/checkout@v4
        with:
          submodules: true
          # Full history makes push and pull-request diff bases available to
          # the current-report selector. Measured SHAs are optional: retained
          # input hashes remain authoritative after rebases and squash merges.
          fetch-depth: 0
      - uses: ./.github/actions/setup
        with:
          cache-key: fork
          wasmtime-fork: "true"
      - name: Test performance-report currentness selection
        run: tools/performance-report-currentness.sh self-test
      - name: Select agentic TypeScript currentness inputs
        id: agentic-ts-currentness
        shell: bash
        env:
          PUSH_BEFORE: ${{ github.event.before }}
          PR_HEAD: ${{ github.event.pull_request.head.sha }}
        run: .github/scripts/select-agentic-ts-currentness.sh "$GITHUB_EVENT_NAME" "$PUSH_BEFORE" "$PR_HEAD" >> "$GITHUB_OUTPUT"
      # Validation mode always checks the manifest-designated reports against their
      # recorded source hint and input hashes. For changed current reports, the
      # shared helper also recomputes those hashes from the measured source when
      # that commit is available locally; it never substitutes the checkout for it.
      - name: Validate agentic TypeScript reports
        shell: bash
        env:
          PERFORMANCE_REPORTS_TO_CHECK: ${{ steps.agentic-ts-currentness.outputs.reports-to-check }}
        run: |
          tools/performance-report-currentness.sh check agentic-ts -- \
            cargo test --test agentic_ts $CI_WASMTIME_FORK_FEATURES
      - name: Validate npm release reports
        shell: bash
        env:
          PERFORMANCE_REPORTS_TO_CHECK: ${{ steps.agentic-ts-currentness.outputs.npm-reports-to-check }}
        run: |
          tools/performance-report-currentness.sh check npm-metadata -- \
            cargo test --test npm_metadata $CI_WASMTIME_FORK_FEATURES
      - name: Compilation, DTS and error tests
        run: cargo test --test compilation --test dts --test errors $CI_WASMTIME_FORK_FEATURES -- --report-time --format ctrf --logfile target/ctrf.json
      - name: Fork-only runtime tests (Golem fork)
        # Streaming-redirect fetch depends on a wasmtime-wasi-http fix that only the Golem
        # fork carries; stock `test-runtime` skips these cases.
        run: cargo test --test runtime $CI_WASMTIME_FORK_FEATURES -- fetch_redirect_with_ --report-time
      - name: Optimizer copy budget contracts (Golem fork)
        # Full guest templates spawn Cargo/Wasmtime compiler pools. Reuse only
        # build artifacts and bound competing cases; runtime state stays fresh.
        env:
          WASM_RQUICKJS_TEST_ARTIFACT_CACHE: "1"
        run: cargo test --test optimize $CI_WASMTIME_FORK_FEATURES -- --test-threads 2
      - name: Collect Test Report
        uses: ./.github/actions/collect-test-report
        if: always()
        with:
          name: test-other

  test-p3:
    needs: [quick-checks]
    runs-on: blacksmith-16vcpu-ubuntu-2404
    strategy:
      fail-fast: false
      matrix:
        suite: [generation, async-values]
        include:
          - suite: generation
            test_args: --test p3_generation --test p3_exported_resource --test optimize
          - suite: async-values
            # Each case creates its own Tokio runtime and compiles a Wasmtime
            # component inside the timeout. Bound competing compiler/runtime pools.
            test_args: --test p3_async_values -- --test-threads 4
    env:
      WASM_RQUICKJS_TEST_ARTIFACT_CACHE: "1"
    steps:
      - uses: actions/checkout@v4
        with:
          submodules: true
      - uses: ./.github/actions/setup
        with:
          cache-key: stock
          component-cache-key: stock-${{ matrix.suite }}-shared
      # These tests run against the stock crates.io wasmtime (no
      # `enable-wasmtime-fork.sh`, no `use-golem-wasmtime`), which proves P3 works on
      # unforked wasmtime. Cases that need a fork-only fix run in `test-other`.
      - name: Install wasmtime CLI
        if: matrix.suite == 'generation'
        # `p3_generation` shells out to the `wasmtime` CLI to run generated P3
        # components. Pin it to the workspace wasmtime version (50.x) used by the
        # embedded-host P3 tests so both paths agree on the Component Model async ABI.
        run: |
          curl -sSf https://wasmtime.dev/install.sh | bash -s -- --version v50.0.1
          echo "$HOME/.wasmtime/bin" >> "$GITHUB_PATH"
      - name: WASI Preview 3 tests
        # These are ordinary libtest tests (default harness), so they do not take
        # the test-r `--format ctrf` reporter flags used by the other jobs.
        run: /usr/bin/time -v cargo test ${{ matrix.test_args }}

  # The full runtime suite on the WASI Preview 3 generation path. Like `test-p3`, it runs on the
  # stock crates.io wasmtime (no `enable-wasmtime-fork.sh`, no `use-golem-wasmtime`); the fork is
  # still built and linted by `build` and exercised by `test-other`.
  test-runtime:
    needs: [quick-checks]
    runs-on: blacksmith-16vcpu-ubuntu-2404
    strategy:
      fail-fast: false
      matrix:
        group: [1, 2, 3, 4, 5, 6, 7, 8, 9]
        include:
          - group: 9
            node_version: "22.14.0"
            test_args: "--test-threads 4"
    steps:
      - uses: actions/checkout@v4
        with:
          submodules: true
      - uses: ./.github/actions/setup
        with:
          cache-key: stock
          component-cache-key: stock-runtime-${{ matrix.group }}
      - uses: actions/setup-node@v4
        if: matrix.node_version
        with:
          node-version: ${{ matrix.node_version }}
      - name: Runtime tests (group ${{ matrix.group }}/9)
        run: cargo test --test runtime -- ${{ matrix.test_args }} --report-time --format ctrf --logfile target/ctrf.json ':tag:group${{ matrix.group }}'
        env:
          NODE_MODULES_APP_STRICT_NODE_BASELINE: "1"
      - name: Collect Test Report
        uses: ./.github/actions/collect-test-report
        if: always()
        with:
          name: test-runtime-group-${{ matrix.group }}

  # The full node_compat suite (same shard tags and config.jsonc allow-list) on the WASI Preview 3
  # generation path and stock crates.io wasmtime — see the note on `test-runtime`.
  test-node-compat:
    needs: [quick-checks]
    runs-on: blacksmith-16vcpu-ubuntu-2404
    strategy:
      fail-fast: false
      matrix:
        shard: [0, 1, 2, 3, 4, 5, 6, 7]
    steps:
      - uses: actions/checkout@v4
        with:
          submodules: true
      - uses: ./.github/actions/setup
        with:
          cache-key: stock
          component-cache-key: stock-node-${{ matrix.shard }}
      - name: Vendor Node.js test suite
        run: bash tests/node_compat/vendor.sh
      - name: Module inventory contracts
        if: matrix.shard == 0
        run: cargo test --test node_compat_report -- ':tag:report_contract' --report-time
      - name: Node compat tests (shard ${{ matrix.shard }}/8)
        run: cargo test --test node_compat -- --report-time --format ctrf --logfile target/ctrf.json ':tag:shard${{ matrix.shard }}'
      - name: Collect Test Report
        uses: ./.github/actions/collect-test-report
        if: always()
        with:
          name: test-node-compat-shard-${{ matrix.shard }}

  test-reports:
    if: ${{ always() && !cancelled() }}
    needs: [test-other, test-runtime, test-node-compat]
    runs-on: ubuntu-latest
    permissions:
      actions: read
      contents: read
      checks: write
      pull-requests: write
    steps:
      - uses: actions/checkout@v4
      - name: Select latest evidence per lane before downloading
        id: reports
        uses: actions/github-script@v7
        with:
          script: |
            const { selectArtifacts } = require('./.github/scripts/prepare-test-reports.cjs');
            await selectArtifacts({ github, context, core });
      - uses: actions/download-artifact@v4
        if: steps.reports.outputs.ids != ''
        with:
          # Partial and report-only reruns reuse the latest evidence per lane.
          artifact-ids: ${{ steps.reports.outputs.ids }}
          github-token: ${{ github.token }}
          path: test-reports
          merge-multiple: false
      - name: Preserve source name when downloading a single artifact
        if: steps.reports.outputs.single-name != ''
        env:
          ARTIFACT_NAME: ${{ steps.reports.outputs.single-name }}
        run: |
          if compgen -G 'test-reports/ctrf-*.json' > /dev/null; then
            mv test-reports single-test-report
            mkdir test-reports
            mv single-test-report "test-reports/${ARTIFACT_NAME}"
          fi
      - name: Preserve consolidated evidence
        uses: actions/upload-artifact@v4
        with:
          name: ci-test-reports-attempt${{ github.run_attempt }}
          path: test-reports
          retention-days: 35
          if-no-files-found: warn
      # Evidence collection is strict; optional GitHub presentation is not a
      # release gate. Re-running this job never needs to re-run the tests.
      - name: Prepare lane-qualified presentation
        if: hashFiles('test-reports/**/ctrf-*.json') != ''
        continue-on-error: true
        uses: actions/github-script@v7
        with:
          script: |
            const { prepareReports } = require('./.github/scripts/prepare-test-reports.cjs');
            await prepareReports('test-reports', 'rendered-reports', message => core.warning(message));
      - name: Publish Test Report
        uses: ctrf-io/github-test-reporter@v1
        continue-on-error: true
        with:
          report-path: 'rendered-reports/*/ctrf-*.json'
          summary: true
          summary-report: true
          failed-report: true
          # Historical crawling belongs outside the per-commit critical path.
          slowest-report: false
          github-report: true
          flaky-report: true
          collapse-large-reports: true
          exit-on-no-files: false
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

  release-binaries:
    needs: [build, test-other, test-runtime, test-node-compat, test-p3]
    if: "startsWith(github.ref, 'refs/tags/v')"
    strategy:
      matrix:
        include:
          - target: x86_64-unknown-linux-gnu
            os: blacksmith-16vcpu-ubuntu-2404
            archive: tar.gz
          - target: aarch64-unknown-linux-gnu
            os: blacksmith-16vcpu-ubuntu-2404
            archive: tar.gz
            cross: true
          - target: x86_64-apple-darwin
            os: macos-latest
            archive: tar.gz
          - target: aarch64-apple-darwin
            os: macos-latest
            archive: tar.gz
          - target: x86_64-pc-windows-msvc
            os: windows-latest
            archive: zip
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v4
        with:
          submodules: true
      - uses: dtolnay/rust-toolchain@stable
      - uses: useblacksmith/rust-cache@v3
        with:
          prefix-key: v1-rust
          shared-key: release-${{ matrix.target }}
          cache-all-crates: true
      - id: get_version
        uses: battila7/get-version-action@v2
      - name: Set version
        shell: bash
        run: |
          VERSION="${{ steps.get_version.outputs.version-without-v }}"
          if [[ "$RUNNER_OS" == "macOS" ]]; then
            sed -i '' "s/0.0.0/$VERSION/g" Cargo.toml
          else
            sed -i "s/0.0.0/$VERSION/g" Cargo.toml
          fi
      - name: Install cross-compilation tools
        if: matrix.cross
        run: |
          sudo apt-get update
          sudo apt-get install -y gcc-aarch64-linux-gnu
          echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
      - name: Add Rust target
        run: rustup target add ${{ matrix.target }}
      - name: Build release binary
        run: cargo build --release --target ${{ matrix.target }}
      - name: Package (unix)
        if: matrix.archive == 'tar.gz'
        shell: bash
        run: |
          ARCHIVE="wasm-rquickjs-cli-v${{ steps.get_version.outputs.version-without-v }}-${{ matrix.target }}.tar.gz"
          tar -czf "$ARCHIVE" -C target/${{ matrix.target }}/release wasm-rquickjs
          echo "ARCHIVE=$ARCHIVE" >> $GITHUB_ENV
      - name: Package (windows)
        if: matrix.archive == 'zip'
        shell: bash
        run: |
          ARCHIVE="wasm-rquickjs-cli-v${{ steps.get_version.outputs.version-without-v }}-${{ matrix.target }}.zip"
          cd target/${{ matrix.target }}/release
          7z a "../../../$ARCHIVE" wasm-rquickjs.exe
          cd ../../..
          echo "ARCHIVE=$ARCHIVE" >> $GITHUB_ENV
      - name: Upload release asset
        uses: softprops/action-gh-release@v2
        with:
          files: ${{ env.ARCHIVE }}

  publish:
    needs: [build, test-other, test-runtime, test-node-compat, test-p3]
    if: "startsWith(github.ref, 'refs/tags/v')"
    runs-on: blacksmith-16vcpu-ubuntu-2404
    steps:
      - uses: actions/checkout@v4
        with:
          submodules: true
      - uses: ./.github/actions/setup
        with:
          cache-key: release
      - id: get_version
        uses: battila7/get-version-action@v2
      - name: Publish crates
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
        run: |
          export VERSION="${{ steps.get_version.outputs.version-without-v }}"
          sed -i "s/0.0.0/$VERSION/g" Cargo.toml
          cargo publish -p wasm-rquickjs --features optimize --allow-dirty
          cargo publish -p wasm-rquickjs-cli --allow-dirty