1name: CI
2on:
3  # Run CI for PRs to `main` and to release branches.
4  #
5  # Note that PRs to `main` will run a subset of tests and PRs to the
6  # `release-*` branches will run full CI.
7  pull_request:
8    branches:
9    - main
10    - 'release-*'
11
12  # This is the CI that runs for PRs-to-merge.
13  merge_group:
14
15  push:
16    branches:
17    # Right now merge queues can't be used with wildcards in branch protections
18    # so full CI runs both on PRs to release branches as well as merges to
19    # release branches. Note that the merge to a release branch may produce a
20    # tag at the end of CI if successful and the tag will trigger the artifact
21    # uploads as well as publication to crates.io.
22    - 'release-*'
23
24  # Allow manually triggering this request via a button or another workflow.
25  workflow_dispatch:
26
27defaults:
28  run:
29    shell: bash
30
31# Cancel any in-flight jobs for the same PR/branch so there's only one active
32# at a time
33concurrency:
34  group: ${{ github.workflow }}-${{ github.ref }}2
35  cancel-in-progress: true
36
37jobs:
38  # Check Code style quickly by running `rustfmt` over all code
39  rustfmt:
40    name: Rustfmt
41    runs-on: ubuntu-latest
42    steps:
43    - uses: actions/checkout@v4
44      with:
45        submodules: true
46    - uses: ./.github/actions/install-rust
47    - run: rustup component add rustfmt
48    - run: cargo fmt --all -- --check
49
50  # Quick JS formatting/linting checks for the little bits of JS we have for the
51  # `wasmtime explore` UI.
52  check_js:
53    name: Check JS
54    runs-on: ubuntu-latest
55    steps:
56    - uses: actions/checkout@v4
57    - run: npm install
58      working-directory: ./crates/explorer
59    - run: npm run lint
60      working-directory: ./crates/explorer
61    - run: npm run fmt-check
62      working-directory: ./crates/explorer
63
64  # Check Code style quickly by running `clang-format` over all the C/C++ code
65  #
66  # Note that `wasmtime-platform.h` is excluded here as it's auto-generated.
67  clangformat:
68    name: Clang format
69    runs-on: ubuntu-24.04
70    steps:
71    - uses: actions/checkout@v4
72      with:
73        submodules: true
74    - run: |
75        git ls-files '*.h' '*.c' '*.cpp' '*.hh' '*.cc' | \
76          grep -v wasmtime-platform.h | \
77          grep -v wasm.h | \
78          xargs clang-format-18 --dry-run --Werror --verbose
79    # Make sure our `clangformat.sh` helper script keeps running and stays
80    # in-sync with the previous check.
81    - run: crates/c-api/clangformat.sh
82    - run: git diff --exit-code
83
84  # Lint dependency graph for security advisories, duplicate versions, and
85  # incompatible licences
86  cargo_deny:
87    name: Cargo deny
88    needs: determine
89    if: needs.determine.outputs.audit
90    runs-on: ubuntu-latest
91    steps:
92    - uses: actions/checkout@v4
93      with:
94        submodules: true
95    - uses: ./.github/actions/install-rust
96    - run: |
97        set -e
98        curl --retry 5 --retry-all-errors -L -o cargo-deny.tar.gz https://github.com/EmbarkStudios/cargo-deny/releases/download/0.18.2/cargo-deny-0.18.2-x86_64-unknown-linux-musl.tar.gz
99        tar xzf cargo-deny.tar.gz
100        rm cargo-deny.tar.gz
101        mv cargo-deny-*-x86_64-unknown-linux-musl/cargo-deny cargo-deny
102        echo `pwd` >> $GITHUB_PATH
103    - run: cargo deny check bans licenses
104
105  # Ensure dependencies are vetted. See https://mozilla.github.io/cargo-vet/
106  #
107  # Note that this step, on PRs only, is allowed to fail. This is then followed
108  # up with the `cargo_vet_failure_for_prs` step below. The intention is to
109  # avoid causing this check to fail PRs while still enabling it to fail the
110  # merge queue checks. That way PRs can enter the merge queue when this step is
111  # failing if `main` has picked up `cargo vet` entries in the meantime for the
112  # failures.
113  cargo_vet:
114    name: Cargo vet
115    needs: determine
116    if: github.repository == 'bytecodealliance/wasmtime' && needs.determine.outputs.audit
117    runs-on: ubuntu-latest
118    outputs:
119      outcome: ${{ steps.vet.outcome }}
120    steps:
121    - uses: actions/checkout@v4
122      with:
123        submodules: true
124    - uses: ./.github/actions/install-rust
125    - uses: ./.github/actions/install-cargo-vet
126    - id: vet
127      run: cargo vet --locked
128      continue-on-error: ${{ github.event_name == 'pull_request' }}
129
130    # Double-check that if versions are bumped that `cargo vet` still works.
131    # This is intended to weed out mistakes such as #9115 from happening again.
132    - run: rustc scripts/publish.rs && ./publish bump-patch && cargo vet
133      name: Ensure `cargo vet` works if versions are bumped
134
135  cargo_vet_failure_for_prs:
136    name: Cargo vet failed on a Pull Request
137    needs:
138    - determine
139    - cargo_vet
140    if: |
141      needs.determine.outputs.audit
142      && github.event_name == 'pull_request'
143      && needs.cargo_vet.outputs.outcome == 'failure'
144    runs-on: ubuntu-latest
145    steps:
146    # NB: this message ideally would link back to the previous step, but I'm not
147    # sure how to easily do that.
148    - run: |
149        echo 'failed to run "cargo vet", see previous `Cargo vet` step'
150        echo 'exiting with a nonzero status now to alert PR authors'
151        echo 'note, though, that this PR can still enter the merge queue'
152        echo ''
153        echo 'See https://docs.wasmtime.dev/contributing-coding-guidelines.html#cargo-vet-for-contributors'
154        echo 'for more information about the vetting process for Wasmtime'
155        exit 1
156
157  # This job is a dependency of many of the jobs below. This calculates what's
158  # actually being run for this workflow. For example:
159  #
160  # * Pushes to branches, which is currently both pushes to merge queue branches
161  #   as well as release branches, perform full CI.
162  # * PRs to release branches (not `main`) run full CI.
163  # * PRs to `main` will only run a few smoke tests above plus some elements of
164  #   the test matrix. The test matrix here is determined dynamically by the
165  #   `./ci/build-test-matrix.js` script given the commits that happened and
166  #   the files modified.
167  determine:
168    name: Determine CI jobs to run
169    runs-on: ubuntu-latest
170    outputs:
171      run-full: ${{ steps.calculate.outputs.run-full }}
172      test-matrix: ${{ steps.calculate.outputs.test-matrix }}
173      build-matrix: ${{ steps.calculate.outputs.build-matrix }}
174      test-capi: ${{ steps.calculate.outputs.test-capi }}
175      test-nightly: ${{ steps.calculate.outputs.test-nightly }}
176      test-miri: ${{ steps.calculate.outputs.test-miri }}
177      audit: ${{ steps.calculate.outputs.audit }}
178      preview1-adapter: ${{ steps.calculate.outputs.preview1-adapter }}
179      run-dwarf: ${{ steps.calculate.outputs.run-dwarf }}
180      platform-checks: ${{ steps.calculate.outputs.platform-checks }}
181    steps:
182    - uses: actions/checkout@v4
183    - id: calculate
184      env:
185        GH_TOKEN: ${{ github.token }}
186      run: |
187        touch commits.log names.log
188        # Note that CI doesn't run on pushes to `main`, only pushes to merge
189        # queue branches and release branches, so this only runs full CI in
190        # those locations.
191        if [ "${{ github.event_name }}" != "pull_request" ]; then
192          run_full=true
193        else
194          pr=${{ github.event.number }}
195          gh pr view $pr --json commits | tee commits.log
196          gh pr diff $pr --name-only | tee names.log || echo "failed to get files"
197          if [ "${{ github.base_ref }}" != "main" ]; then
198            run_full=true
199          elif grep -q 'prtest:full' commits.log; then
200            run_full=true
201          elif grep -q 'prtest:debug' commits.log; then
202            echo run-dwarf=true >> $GITHUB_OUTPUT
203          elif grep -q 'prtest:platform-checks' commits.log; then
204            echo platform-checks=true >> $GITHUB_OUTPUT
205          elif grep -q 'prtest:miri' commits.log; then
206            echo test-miri=true >> $GITHUB_OUTPUT
207          elif grep -q 'prtest:capi' commits.log; then
208            echo test-capi=true >> $GITHUB_OUTPUT
209          fi
210          if grep -q crates.c-api names.log; then
211            echo test-capi=true >> $GITHUB_OUTPUT
212          fi
213          if grep -q fuzz names.log; then
214            echo test-nightly=true >> $GITHUB_OUTPUT
215          fi
216          if grep -q sys.custom names.log; then
217            echo test-nightly=true >> $GITHUB_OUTPUT
218          fi
219          if grep -q Cargo.lock names.log; then
220            echo audit=true >> $GITHUB_OUTPUT
221          fi
222          if grep -q supply-chain names.log; then
223            echo audit=true >> $GITHUB_OUTPUT
224          fi
225          if grep -q component-adapter names.log; then
226            echo preview1-adapter=true >> $GITHUB_OUTPUT
227          fi
228          if grep -q debug names.log; then
229            echo run-dwarf=true >> $GITHUB_OUTPUT
230          fi
231          if grep -q pulley names.log; then
232            echo test-nightly=true >> $GITHUB_OUTPUT
233          fi
234        fi
235        matrix="$(node ./ci/build-test-matrix.js ./commits.log ./names.log $run_full)"
236        echo "test-matrix={\"include\":$(echo $matrix)}" >> $GITHUB_OUTPUT
237        echo "$matrix"
238
239        matrix="$(node ./ci/build-build-matrix.js)"
240        echo "build-matrix={\"include\":$(echo $matrix)}" >> $GITHUB_OUTPUT
241
242        if [ "$run_full" = "true" ]; then
243            echo run-full=true >> $GITHUB_OUTPUT
244            echo test-capi=true >> $GITHUB_OUTPUT
245            echo test-nightly=true >> $GITHUB_OUTPUT
246            echo test-miri=true >> $GITHUB_OUTPUT
247            echo audit=true >> $GITHUB_OUTPUT
248            echo preview1-adapter=true >> $GITHUB_OUTPUT
249            echo run-dwarf=true >> $GITHUB_OUTPUT
250            echo platform-checks=true >> $GITHUB_OUTPUT
251        fi
252
253  # Build all documentation of Wasmtime, including the C API documentation,
254  # mdbook documentation, etc. This produces a `gh-pages` artifact which is what
255  # gets uploaded to the `gh-pages` branch later on.
256  doc:
257    needs: determine
258    if: needs.determine.outputs.run-full
259    name: Doc build
260    runs-on: ubuntu-latest
261    env:
262      MDBOOK_VERSION: 0.4.37
263      MDBOOK_LANGTABS_VERSION: 0.1.1
264      RUSTDOCFLAGS: -Dbroken_intra_doc_links --cfg docsrs
265      OPENVINO_SKIP_LINKING: 1
266    steps:
267    - uses: actions/checkout@v4
268      with:
269        submodules: true
270    - uses: ./.github/actions/install-rust
271      with:
272        toolchain: wasmtime-ci-pinned-nightly
273
274    # Build C API documentation
275    - run: |
276        curl --retry 5 --retry-all-errors -o doxygen.tar.gz -L https://github.com/doxygen/doxygen/releases/download/Release_1_9_3/doxygen-1.9.3.linux.bin.tar.gz
277        tar xzf doxygen.tar.gz
278        rm doxygen.tar.gz
279    - run: echo "`pwd`/doxygen-1.9.3/bin" >> $GITHUB_PATH
280    - run: cmake -S crates/c-api -B target/c-api
281    - run: cmake --build target/c-api --target doc
282
283    # install mdbook, build the docs, and test the docs
284    - uses: actions/cache@v4
285      with:
286        path: ${{ runner.tool_cache }}/mdbook
287        key: cargo-mdbook-${{ env.MDBOOK_VERSION }}-langtabs-${{ env.MDBOOK_LANGTABS_VERSION }}
288    - run: |
289        echo "${{ runner.tool_cache }}/mdbook/bin" >> $GITHUB_PATH
290        cargo install --root ${{ runner.tool_cache }}/mdbook --version ${{ env.MDBOOK_VERSION }} mdbook --locked
291        cargo install --root ${{ runner.tool_cache }}/mdbook --version ${{ env.MDBOOK_LANGTABS_VERSION }} mdbook-langtabs --locked
292    - run: (cd docs && mdbook build)
293
294    # Build Rust API documentation.
295    #
296    # Enable extra features in crates as well to ensure they're documented
297    - run: |
298        cargo doc --no-deps --workspace \
299          --exclude wasmtime-cli \
300          --exclude test-programs \
301          --exclude cranelift-codegen-meta \
302          --exclude wasmtime-wasi-nn \
303          --exclude wasmtime-fuzzing \
304          --exclude wasm-spec-interpreter \
305          --exclude calculator \
306          --all-features
307      env:
308        RUSTDOCFLAGS: --cfg=docsrs
309    - run: cargo doc --package cranelift-codegen-meta --document-private-items
310      env:
311        RUSTDOCFLAGS: --cfg=docsrs
312
313    # Assemble the documentation, and always upload it as an artifact for
314    # inspection on PRs and such.
315    - run: |
316        mv docs/book gh-pages
317        mv crates/c-api/html gh-pages/c-api
318        mv target/doc gh-pages/api
319        tar czf gh-pages.tar.gz gh-pages
320    - uses: actions/upload-artifact@v4
321      with:
322        name: gh-pages
323        path: gh-pages.tar.gz
324
325  # Checks of various feature combinations and whether things compile. The goal
326  # here isn't to run tests, mostly just serve as a double-check that Rust code
327  # compiles and is likely to work everywhere else.
328  micro_checks:
329    name: Check ${{matrix.name}}
330    strategy:
331      fail-fast: ${{ github.event_name != 'pull_request' }}
332      matrix:
333        include:
334          - name: wasmtime
335            checks: |
336              -p wasmtime --no-default-features
337              -p wasmtime --no-default-features --features wat
338              -p wasmtime --no-default-features --features profiling
339              -p wasmtime --no-default-features --features cache
340              -p wasmtime --no-default-features --features async
341              -p wasmtime --no-default-features --features std
342              -p wasmtime --no-default-features --features pooling-allocator
343              -p wasmtime --no-default-features --features cranelift
344              -p wasmtime --no-default-features --features component-model
345              -p wasmtime --no-default-features --features component-model-async
346              -p wasmtime --no-default-features --features runtime,component-model
347              -p wasmtime --no-default-features --features cranelift,wat,async,std,cache
348              -p wasmtime --no-default-features --features winch
349              -p wasmtime --no-default-features --features wmemcheck
350              -p wasmtime --no-default-features --features wmemcheck,cranelift,runtime
351              -p wasmtime --no-default-features --features demangle
352              -p wasmtime --no-default-features --features addr2line
353              -p wasmtime --no-default-features --features gc
354              -p wasmtime --no-default-features --features runtime,gc
355              -p wasmtime --no-default-features --features cranelift,gc
356              -p wasmtime --no-default-features --features gc-drc
357              -p wasmtime --no-default-features --features runtime,gc-drc
358              -p wasmtime --no-default-features --features cranelift,gc-drc
359              -p wasmtime --no-default-features --features gc-null
360              -p wasmtime --no-default-features --features runtime,gc-null
361              -p wasmtime --no-default-features --features cranelift,gc-null
362              -p wasmtime --no-default-features --features runtime
363              -p wasmtime --no-default-features --features threads
364              -p wasmtime --no-default-features --features runtime,threads
365              -p wasmtime --no-default-features --features cranelift,threads
366              -p wasmtime --no-default-features --features stack-switching
367              -p wasmtime --no-default-features --features cranelift,stack-switching
368              -p wasmtime --no-default-features --features runtime,stack-switching
369              -p wasmtime --no-default-features --features debug
370              -p wasmtime --no-default-features --features debug,gc
371              -p wasmtime --features incremental-cache
372              -p wasmtime --features profile-pulley
373              -p wasmtime --all-features
374
375          - name: wasmtime-fiber
376            checks: |
377              -p wasmtime-internal-fiber --no-default-features
378              -p wasmtime-internal-fiber --no-default-features --features std
379              -p wasmtime-internal-fiber --all-features
380
381          - name: wasmtime-cli
382            checks: |
383              -p wasmtime-cli --no-default-features
384              -p wasmtime-cli --no-default-features --features pooling-allocator
385              -p wasmtime-cli --no-default-features --features run
386              -p wasmtime-cli --no-default-features --features run,component-model
387              -p wasmtime-cli --no-default-features --features run,pooling-allocator
388              -p wasmtime-cli --no-default-features --features compile
389              -p wasmtime-cli --no-default-features --features compile,cranelift
390              -p wasmtime-cli --no-default-features --features compile,cranelift,component-model
391              -p wasmtime-cli --no-default-features --features objdump
392              -p wasmtime-cli --no-default-features --features wizer
393              -p wasmtime-cli --all-features
394              -p wasmtime-cli --features component-model
395
396          - name: cranelift-codegen
397            checks: |
398              -p cranelift-codegen --benches
399              -p cranelift-codegen --no-default-features --features std,unwind,pulley
400
401          - name: cranelift-entity
402            checks: |
403              -p cranelift-entity --no-default-features
404              -p cranelift-entity --no-default-features --features enable-serde
405
406          - name: wasmtime-bench-api
407            checks: |
408              -p wasmtime-bench-api
409
410          - name: wasmtime-c-api
411            checks: |
412              -p wasmtime-c-api --no-default-features
413              -p wasmtime-c-api --no-default-features --features wat
414              -p wasmtime-c-api --no-default-features --features wasi
415
416          - name: wasmtime-wasi-http
417            checks: |
418              -p wasmtime-wasi-http --no-default-features
419
420          - name: wasmtime-wasi
421            checks: |
422              -p wasmtime-wasi --no-default-features
423              -p wasmtime-wasi --no-default-features --features p0
424              -p wasmtime-wasi --no-default-features --features p1
425              -p wasmtime-wasi --no-default-features --features p2
426              -p wasmtime-wasi --no-default-features --features p3
427
428          - name: wasmtime-wizer
429            checks: |
430              -p wasmtime-wizer --no-default-features
431              -p wasmtime-wizer --no-default-features --features wasmtime
432              -p wasmtime-wizer --no-default-features --features wasmprinter
433              -p wasmtime-wizer --no-default-features --features component-model
434              -p wasmtime-wizer --no-default-features --all-features
435    runs-on: ubuntu-latest
436    steps:
437    - uses: actions/checkout@v4
438      with:
439        submodules: true
440    - uses: ./.github/actions/install-rust
441
442    # Run the check.
443    - run: |
444        checks=$(cat <<END
445        ${{ matrix.checks }}
446        END
447        )
448        echo "$checks" | xargs -I CHECK sh -c 'echo "=== cargo check CHECK ==="; cargo check CHECK'
449
450  special_tests:
451    name: One-off special tests
452    runs-on: ubuntu-latest
453    needs: determine
454    if: needs.determine.outputs.run-full
455    steps:
456    - uses: actions/checkout@v4
457      with:
458        submodules: true
459    - uses: ./.github/actions/install-rust
460    - run: cargo test -p wasmtime-internal-fiber --no-default-features
461    - run: cargo test -p cranelift-tools --test logged-filetests
462
463  # Check that Clippy lints are passing.
464  clippy:
465    name: Clippy
466    runs-on: ubuntu-latest
467    env:
468      CARGO_NDK_VERSION: 2.12.2
469    steps:
470    - uses: actions/checkout@v4
471      with:
472        submodules: true
473    - uses: ./.github/actions/install-rust
474
475    - run: rustup component add clippy
476    - run: cargo clippy --workspace --all-targets --features p3,component-model-async
477
478  # Similar to `micro_checks` but where we need to install some more state
479  # (e.g. Android NDK) and we haven't factored support for those things out into
480  # a parallel jobs yet.
481  monolith_checks:
482    name: Monolith Checks
483    runs-on: ubuntu-latest
484    env:
485      CARGO_NDK_VERSION: 2.12.2
486    steps:
487    - uses: actions/checkout@v4
488      with:
489        submodules: true
490    - uses: ./.github/actions/install-rust
491
492    # Check that wasmtime compiles with panic=abort since there's some `#[cfg]`
493    # for specifically panic=abort there.
494    - run: cargo check -p wasmtime
495      env:
496        RUSTFLAGS: -Cpanic=abort
497
498    # Check a few builds of the cranelift backend
499    # - only x86 backend support,
500    # - only arm64 backend support,
501    # - no debug_assertions.
502    - run: cargo check --manifest-path=./cranelift/Cargo.toml --bin clif-util --no-default-features --features=cranelift-codegen/arm64
503    - run: cargo check --manifest-path=./cranelift/Cargo.toml --bin clif-util --no-default-features --features=cranelift-codegen/x86
504    - run: cargo check --manifest-path=./cranelift/Cargo.toml --bin clif-util
505      env:
506        CARGO_PROFILE_DEV_DEBUG_ASSERTIONS: false
507
508    # Re-vendor all WIT files and ensure that they're all up-to-date by ensuring
509    # that there's no git changes.
510    - name: Re-vendor WIT
511      run: ./ci/vendor-wit.sh
512    - run: git diff --exit-code
513
514    # Re-vendor the C API and make sure it's up-to-date.
515    - name: Re-vendor C API
516      run: ./ci/vendor-c-api-headers.sh
517    - run: git diff --exit-code
518
519  # Various checks that Wasmtime builds for a variety of platforms. Each
520  # platform may not include the entire dependency tree and maybe just a few
521  # features here and there, see the `include` matrix for more details.
522  platform_checks:
523    needs: determine
524    if: needs.determine.outputs.platform-checks
525    name: "Platform: ${{ matrix.target }}"
526    runs-on: ${{ matrix.os }}
527    strategy:
528      fail-fast: ${{ github.event_name != 'pull_request' }}
529      matrix:
530        include:
531        - target: x86_64-unknown-freebsd
532          os: ubuntu-latest
533          test: cargo check
534        - target: aarch64-pc-windows-msvc
535          os: windows-latest
536          test: cargo check
537        # While we're here testing a windows target also test a feature'd build
538        # on Windows. Note that this isn't covered by `micro_checks` above since
539        # that's for unix platforms, not Windows, so include a small check here
540        # which isn't the full `micro_checks` matrix but hopefully enough bang
541        # for our buck.
542        - target: i686-pc-windows-msvc
543          os: windows-latest
544          test: cargo check && cargo build -p wasmtime --no-default-features --features runtime
545        # This is used for general compatibility with `#![no_std]` targets and a
546        # variety of crates are tested here.
547        - target: x86_64-unknown-none
548          os: ubuntu-latest
549          test: >
550            cargo check -p wasmtime --no-default-features --features runtime,component-model &&
551            cargo check -p wasmtime --no-default-features --features runtime,gc,component-model,async,debug-builtins &&
552            cargo check -p cranelift-control --no-default-features &&
553            cargo check -p cranelift-assembler-x64 --lib &&
554            cargo check -p pulley-interpreter --features encode,decode,disas,interp &&
555            cargo check -p wasmtime-wasi-io --no-default-features
556        # Use `cross` for illumos to have a C compiler/linker available.
557        - target: x86_64-unknown-illumos
558          os: ubuntu-latest
559          cross: true
560          test: cross build
561        - target: wasm32-wasip1
562          os: ubuntu-latest
563          test: cargo build --no-default-features --features compile,cranelift,all-arch
564        - target: aarch64-apple-ios
565          os: macos-latest
566          test: cargo build
567          env:
568            IPHONEOS_DEPLOYMENT_TARGET: 13.0
569        # Test that when Cranelift has no support for an architecture, even a
570        # 64-bit one, that Wasmtime still compiles. Note that this is also
571        # intended to test various fallbacks in the codebase where we have no
572        # support at all for a particular architecture. In theory if someone
573        # adds powerpc64 support to Wasmtime this should get switched to some
574        # other architecture.
575        - target: powerpc64le-unknown-linux-gnu
576          os: ubuntu-latest
577          test: cargo build
578          apt_packages: gcc-powerpc64le-linux-gnu
579          env:
580            CARGO_TARGET_POWERPC64LE_UNKNOWN_LINUX_GNU_LINKER: powerpc64le-linux-gnu-gcc
581        # A no_std target without 64-bit atomics
582        - target: riscv32imac-unknown-none-elf
583          os: ubuntu-latest
584          test: cargo check -p wasmtime --no-default-features --features runtime,gc,component-model,async
585    env: ${{ matrix.env || fromJSON('{}') }}
586    steps:
587    - uses: actions/checkout@v4
588      with:
589        submodules: true
590    - uses: ./.github/actions/install-rust
591    - run: rustup target add ${{ matrix.target }}
592    - name: Install cross
593      run: |
594        curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
595        cargo binstall --no-confirm cross
596      if: ${{ matrix.cross }}
597    - name: Install apt packages
598      if: ${{ matrix.apt_packages }}
599      run: sudo apt-get update && sudo apt-get install -y ${{ matrix.apt_packages }}
600    - run: ${{ matrix.test }}
601      env:
602        CARGO_BUILD_TARGET: ${{ matrix.target }}
603
604  # Run tests that require a nightly compiler, such as building fuzz targets.
605  test_nightly:
606    needs: determine
607    if: needs.determine.outputs.test-nightly
608    name: Nightly tests
609    runs-on: ubuntu-latest
610    steps:
611    - uses: actions/checkout@v4
612      with:
613        submodules: true
614    # Note that nightly is pinned here to insulate us from breakage that might
615    # happen upstream. This is periodically updated through a PR.
616    - uses: ./.github/actions/install-rust
617      with:
618        toolchain: wasmtime-ci-pinned-nightly
619
620    # Check that `pulley-interpreter` works with tail calls enabled.
621    - run: cargo test -p pulley-interpreter --all-features
622      env:
623        RUSTFLAGS: "--cfg pulley_tail_calls"
624    - run: cargo check -p pulley-interpreter --all-features
625      env:
626        RUSTFLAGS: "--cfg pulley_disable_interp_simd"
627    - run: cargo test -p pulley-interpreter --all-features --release
628      env:
629        RUSTFLAGS: "--cfg pulley_assume_llvm_makes_tail_calls"
630
631    # Ensure that fuzzers still build.
632    #
633    # Install the OCaml packages necessary for fuzz targets that use the
634    # `wasm-spec-interpreter`.
635    - run: cargo install cargo-fuzz --vers "^0.11" --locked
636    - run: sudo apt-get update && sudo apt install -y ocaml-nox ocamlbuild ocaml-findlib libzarith-ocaml-dev
637    - run: cargo fetch
638      working-directory: ./fuzz
639    - run: cargo fuzz check --dev
640    - run: cargo fuzz check --dev --fuzz-dir ./cranelift/isle/fuzz
641    - run: cargo fuzz check --dev --fuzz-dir ./crates/environ/fuzz --features component-model
642    - run: cargo fuzz check --dev --fuzz-dir ./cranelift/assembler-x64/fuzz
643    - run: cargo fuzz check --dev --fuzz-dir ./crates/wizer/fuzz
644
645  # Perform all tests of the c-api
646  test_capi:
647    needs: determine
648    name: Test C-API ${{ matrix.name }}
649    runs-on: ${{ matrix.os }}
650    if: needs.determine.outputs.test-capi
651
652    strategy:
653      fail-fast: ${{ github.event_name != 'pull_request' }}
654      matrix:
655        include:
656          # This configuration will build C/C++ tests, examples, and Rust tests.
657          # Everything is linked against the C shared library to speed up
658          # linking, and this is intended to be the "main set of tests".
659          #
660          # Run this on windows/mac/linux
661          - os: ubuntu-24.04
662            # Only run the "plugins" example on Linux
663            flags: -DBUILD_SHARED_LIBS=ON -DBUILD_TESTS=ON -DBUILD_RUST_EXAMPLES=ON -DBUILD_RUST_PLUGINS_EXAMPLE=ON
664            name: Linux
665          - os: macos-15
666            flags: -DBUILD_SHARED_LIBS=ON -DBUILD_TESTS=ON -DBUILD_RUST_EXAMPLES=ON
667            name: macOS
668          - os: windows-2025
669            # Note that dynamic linking is disabled here because I don't want to
670            # have to deal with figuring out how to get `wasmtime.dll` onto
671            # `PATH` for various tests.
672            flags: -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTS=ON -DBUILD_RUST_EXAMPLES=ON
673            name: Windows
674
675          # This tests using static linking for examples but skips building the
676          # Rust examples as well as C/C++ tests. Intended to be a faster build
677          # which mostly just tests static linking.
678          - os: ubuntu-24.04
679            flags: -DBUILD_SHARED_LIBS=OFF -DBUILD_RUST_EXAMPLES=OFF
680            name: Linux (static linking)
681
682          # Run tests with ASAN for leak checking primarily.
683          - os: ubuntu-24.04
684            flags: -DCMAKE_C_FLAGS=-fsanitize=address -DCMAKE_CXX_FLAGS=-fsanitize=address -DBUILD_SHARED_LIBS=ON -DBUILD_TESTS=ON
685            name: Linux (ASAN)
686    steps:
687    - uses: actions/checkout@v4
688      with:
689        submodules: true
690    - uses: ./.github/actions/install-rust
691    - run: rustup target add wasm32-wasip2
692
693    - uses: ./.github/actions/install-plugins-prerequisites
694      if: runner.os == 'Linux'
695
696    - uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756
697    # An ode to MinGW: man you're a pain to work around sometimes
698    - run: rm /usr/bin/link
699      if: runner.os == 'Windows'
700
701    - run: cmake -G Ninja -Sexamples -DCMAKE_BUILD_TYPE=Debug -Bexamples/build ${{ matrix.flags }}
702    - run: ninja -C examples/build
703    - run: ninja -C examples/build test
704      env:
705        CTEST_OUTPUT_ON_FAILURE: 1
706        CTEST_PARALLEL_LEVEL: 4
707
708  # Perform all tests (debug mode) for `wasmtime`.
709  #
710  # Note that the full matrix for what may run here is defined within
711  # `./ci/build-test-matrix.js` and the execution of the `determine` step will
712  # calculate whether the tests are actually run as part of PRs and such.
713  test:
714    needs: determine
715    name: ${{ matrix.name }}
716    runs-on: ${{ matrix.os }}
717    env:
718      QEMU_BUILD_VERSION: 10.0.3
719      SDE_BUILD_VERSION: 9.58.0-2025-06-16
720    strategy:
721      fail-fast: ${{ github.event_name != 'pull_request' }}
722      matrix: ${{ fromJson(needs.determine.outputs.test-matrix) }}
723    steps:
724    - uses: actions/checkout@v4
725      with:
726        submodules: true
727    - uses: ./.github/actions/install-rust
728      with:
729        toolchain: ${{ matrix.rust }}
730
731    # Install targets in order to build various tests throughout the repo
732    - run: rustup target add wasm32-wasip1 wasm32-unknown-unknown ${{ matrix.target }}
733    - run: echo CARGO_BUILD_TARGET=${{ matrix.target }} >> $GITHUB_ENV
734      if: matrix.target != ''
735
736    # Fix an ICE for now in gcc when compiling zstd with debuginfo (??)
737    - run: echo CFLAGS=-g0 >> $GITHUB_ENV
738      if: matrix.target == 'x86_64-pc-windows-gnu'
739
740    # Update binutils if MinGW due to https://github.com/rust-lang/rust/issues/112368
741    - run: C:/msys64/usr/bin/pacman.exe -S --needed mingw-w64-x86_64-gcc --noconfirm
742      if: matrix.target == 'x86_64-pc-windows-gnu'
743    - shell: pwsh
744      run: echo "C:\msys64\mingw64\bin" >> $Env:GITHUB_PATH
745      if: matrix.target == 'x86_64-pc-windows-gnu'
746
747    - run: cargo fetch --locked
748
749    - name: Install cross-compilation tools
750      run: |
751        set -ex
752
753        sudo apt-get update
754        sudo apt-get install -y ${{ matrix.gcc_package }}
755
756        # Configure Cargo for cross compilation and tell it how it can run
757        # cross executables
758        upcase=$(echo ${{ matrix.target }} | awk '{ print toupper($0) }' | sed 's/-/_/g')
759        echo CARGO_TARGET_${upcase}_LINKER=${{ matrix.gcc }} >> $GITHUB_ENV
760      if: matrix.gcc != ''
761
762    - uses: actions/cache@v4
763      with:
764        path: ${{ runner.tool_cache }}/qemu
765        key: qemu-${{ matrix.target }}-${{ env.QEMU_BUILD_VERSION }}-patchcpuinfo
766      if: matrix.qemu != ''
767
768    - uses: actions/cache@v4
769      with:
770        path: ${{ runner.tool_cache }}/sde
771        key: sde-${{ env.SDE_BUILD_VERSION }}
772      if: matrix.sde != ''
773
774    - name: Install qemu
775      run: |
776        set -ex
777
778        upcase=$(echo ${{ matrix.target }} | awk '{ print toupper($0) }' | sed 's/-/_/g')
779        echo CARGO_TARGET_${upcase}_RUNNER=${{ runner.tool_cache }}/qemu/bin/${{ matrix.qemu }} >> $GITHUB_ENV
780
781        # QEMU emulation is not always the speediest, so total testing time
782        # goes down if we build the libs in release mode when running tests.
783        echo CARGO_PROFILE_DEV_OPT_LEVEL=2 >> $GITHUB_ENV
784
785        # See comments in the source for why we enable this during QEMU
786        # emulation.
787        echo WASMTIME_TEST_NO_HOG_MEMORY=1 >> $GITHUB_ENV
788
789        # See if qemu is already in the cache
790        if [ -f ${{ runner.tool_cache }}/qemu/built ]; then
791          exit 0
792        fi
793
794        # Install build dependencies of QEMU itself.
795        sudo apt-get install -y libglib2.0-dev ninja-build
796
797        # Download and build qemu from source since the most recent release is
798        # way faster at arm emulation than the current version github actions'
799        # ubuntu image uses. Disable as much as we can to get it to build
800        # quickly.
801        curl --retry 5 --retry-all-errors -o qemu.tar.xz https://download.qemu.org/qemu-$QEMU_BUILD_VERSION.tar.xz
802        tar xJf qemu.tar.xz
803        rm qemu.tar.xz
804        cd qemu-$QEMU_BUILD_VERSION
805        ./configure --target-list=${{ matrix.qemu_target }} --prefix=${{ runner.tool_cache}}/qemu --disable-tools --disable-slirp --disable-fdt --disable-capstone --disable-docs
806        ninja -C build install
807        touch ${{ runner.tool_cache }}/qemu/built
808      if: matrix.qemu != ''
809
810    - name: Install Intel SDE
811      run: |
812        set -ex
813
814        # Set up SDE as runner for x86_64 targets
815        echo "CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER=${{ runner.tool_cache }}/sde/sde64 -future --" >> $GITHUB_ENV
816
817        # SDE emulation is very slow, so use release mode for better performance
818        echo CARGO_PROFILE_DEV_OPT_LEVEL=2 >> $GITHUB_ENV
819
820        # Enable environment variable to indicate SDE is being used
821        echo WASMTIME_TEST_SDE=1 >> $GITHUB_ENV
822
823        # Generic variable for skipping tests that are problematic under SDE (performance, compatibility, etc.)
824        echo WASMTIME_TEST_NO_SDE=1 >> $GITHUB_ENV
825
826        # Similar to QEMU, reduce memory usage during SDE emulation
827        echo WASMTIME_TEST_NO_HOG_MEMORY=1 >> $GITHUB_ENV
828
829        # See if SDE is already in the cache
830        if [ -f ${{ runner.tool_cache }}/sde/sde64 ]; then
831          exit 0
832        fi
833
834        curl --retry 5 --retry-all-errors -o sde.tar.xz \
835          https://downloadmirror.intel.com/859732/sde-external-${{ env.SDE_BUILD_VERSION }}-lin.tar.xz
836
837        mkdir -p ${{ runner.tool_cache }}/sde
838        tar xJf sde.tar.xz --strip-components=1 -C ${{ runner.tool_cache }}/sde
839        rm sde.tar.xz
840
841        chmod +x ${{ runner.tool_cache }}/sde/sde64
842      if: matrix.sde != ''
843
844    - name: Configure ASAN
845      run: |
846        echo CARGO_PROFILE_DEV_OPT_LEVEL=2 >> $GITHUB_ENV
847        echo CARGO_PROFILE_TEST_OPT_LEVEL=2 >> $GITHUB_ENV
848        echo RUSTFLAGS=-Zsanitizer=address >> $GITHUB_ENV
849        echo RUSTDOCFLAGS="-Zsanitizer=address -Copt-level=2 -Ccodegen-units=16" >> $GITHUB_ENV
850      if: ${{ contains(matrix.name, 'ASAN') }}
851
852    # Record some CPU details; this is helpful information if tests fail due
853    # to CPU-specific features.
854    - name: CPU information
855      run: lscpu
856      if: runner.os == 'Linux'
857    - name: CPU information
858      run: sysctl hw
859      if: runner.os == 'macOS'
860    - name: CPU information
861      run: Get-WmiObject Win32_Processor
862      shell: pwsh
863      if: runner.os == 'Windows'
864
865    # Since MPK (PKU) is not present on some GitHub runners, we check if it is
866    # available before force-enabling it. This occasional testing is better than
867    # none at all; ideally we would test in a system-mode QEMU VM.
868    - name: Force-run with MPK enabled, if available
869      if: ${{ contains(matrix.name, 'MPK') }}
870      run: |
871        if cargo run --example mpk-available; then
872          echo "::notice::This CI run will force-enable MPK; this ensures tests conditioned with the \`WASMTIME_TEST_FORCE_MPK\` environment variable will run with MPK-protected memory pool stripes."
873          echo WASMTIME_TEST_FORCE_MPK=1 >> $GITHUB_ENV
874        else
875          echo "::warning::This CI run will not test MPK; it has been detected as not available on this machine (\`cargo run --example mpk-available\`)."
876        fi
877
878    # Install VTune, see `cli_tests::profile_with_vtune`.
879    - name: Install VTune
880      if: matrix.filter == 'linux-x64' && contains(matrix.bucket, 'wasmtime-cli')
881      uses: abrown/install-vtune-action@v3
882
883    # Build and test all features.
884    #
885    # Note that this uses a different shell, notably not `bash` on Windows. In
886    # the past `bash` would add more items to `PATH` on Windows which would
887    # interfere and cause the `gcc.exe` executable to fail and exit with 1 and
888    # no output. It's believed that `bash` adds things like `/usr/bin` to PATH
889    # which is the wrong DLL or something like that.
890    - run: python3 ./ci/run-tests.py --locked ${{ matrix.bucket }}
891      if: runner.os == 'Windows'
892      shell: pwsh
893    - run: python3 ./ci/run-tests.py --locked ${{ matrix.bucket }}
894      if: runner.os != 'Windows'
895
896  # Test `wasmtime-wasi-nn` in its own job, as not all of its backends are
897  # compatible with all targets, and each must be tested separately anyways.
898  test_wasi_nn:
899    strategy:
900      matrix:
901        feature: ["openvino", "onnx-download"]
902        os: ["ubuntu-24.04", "windows-2025"]
903        include:
904          - os: windows-2025
905            feature: winml
906    name: Test wasi-nn (${{ matrix.feature }}, ${{ matrix.os }})
907    runs-on: ${{ matrix.os }}
908    needs: determine
909    if: needs.determine.outputs.run-full
910    steps:
911    - uses: actions/checkout@v4
912      with:
913        submodules: true
914    - uses: ./.github/actions/install-rust
915
916    # Install OpenVINO
917    - uses: abrown/install-openvino-action@v10
918      if: runner.arch == 'X64'
919
920    # Install WinML for testing wasi-nn WinML backend. WinML is only available
921    # on Windows clients and Windows Server with desktop experience enabled.
922    # GitHub Actions Window Server image doesn't have desktop experience
923    # enabled, so we download the standalone library from ONNX Runtime project.
924    - uses: nuget/setup-nuget@v2
925      if: (runner.os == 'Windows') && (matrix.feature == 'winml')
926    - run: nuget install Microsoft.AI.MachineLearning
927      if: (runner.os == 'Windows') && (matrix.feature == 'winml')
928
929    # Install Rust targets.
930    - run: rustup target add wasm32-wasip1
931
932    # Run the tests!
933    - run: cargo test -p wasmtime-wasi-nn --features ${{ matrix.feature }}
934
935  # Test `wasmtime-wasi-tls-nativetls` in its own job. This is because it
936  # depends on OpenSSL, which is not easily available on all platforms.
937  test_wasi_tls_nativetls:
938    name: Test wasi-tls using native-tls provider
939    needs: determine
940    if: needs.determine.outputs.run-full
941    runs-on: ${{ matrix.os }}
942    strategy:
943      matrix:
944        os: [ubuntu-latest, windows-latest, macos-latest]
945    steps:
946    - uses: actions/checkout@v4
947      with:
948        submodules: true
949    - uses: ./.github/actions/install-rust
950    - run: cargo test -p wasmtime-wasi-tls-nativetls
951
952  # Test the `wasmtime-fuzzing` crate. Split out from the main tests because
953  # `--all-features` brings in OCaml, which is a pain to get setup for all
954  # targets.
955  test_fuzzing:
956    needs: determine
957    if: needs.determine.outputs.run-full
958    name: Test wasmtime-fuzzing
959    runs-on: 'ubuntu-latest'
960    steps:
961    - uses: actions/checkout@v4
962      with:
963        submodules: true
964    - uses: ./.github/actions/install-rust
965
966    # Run the tests
967    - run: |
968        cargo test -p wasmtime-fuzzing -p wasm-spec-interpreter
969
970  # Test debug (DWARF) related functionality.
971  test_debug_dwarf:
972    needs: determine
973    if: needs.determine.outputs.run-dwarf
974    name: Test DWARF debugging
975    runs-on: ubuntu-24.04
976    steps:
977    - uses: actions/checkout@v4
978      with:
979        submodules: true
980    - uses: ./.github/actions/install-rust
981    - run: |
982        rustup target add wasm32-wasip1 wasm32-unknown-unknown
983        cd /tmp
984        curl --retry 5 --retry-all-errors -OL https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-28/wasi-sdk-28.0-x86_64-linux.tar.gz
985        tar -xzf wasi-sdk-28.0-x86_64-linux.tar.gz
986        mv wasi-sdk-28.0-x86_64-linux wasi-sdk
987    - run: |
988        sudo apt-get update && sudo apt-get install -y gdb lldb-18 llvm
989        # workaround for https://bugs.launchpad.net/ubuntu/+source/llvm-defaults/+bug/1972855
990        sudo mkdir -p /usr/lib/local/lib/python3.10/dist-packages/lldb
991        sudo ln -s /usr/lib/llvm-15/lib/python3.10/dist-packages/lldb/* /usr/lib/python3/dist-packages/lldb/
992        # Only testing release since it is more likely to expose issues with our low-level symbol handling.
993        cargo test --release --test all -- --ignored --test-threads 1 native_debug::
994      env:
995        LLDB: lldb-18
996        WASI_SDK_PATH: /tmp/wasi-sdk
997
998  build-preview1-component-adapter:
999    name: Build wasi-preview1-component-adapter
1000    needs: determine
1001    if: needs.determine.outputs.preview1-adapter
1002    runs-on: ubuntu-latest
1003    permissions:
1004      deployments: write
1005      contents: write
1006    steps:
1007    - uses: actions/checkout@v4
1008      with:
1009        submodules: true
1010    - uses: ./.github/actions/install-rust
1011    - run: rustup target add wasm32-wasip1 wasm32-unknown-unknown
1012
1013    - name: Install wasm-tools
1014      run: |
1015        curl --retry 5 --retry-all-errors -o wasm-tools.tar.gz -L https://github.com/bytecodealliance/wasm-tools/releases/download/wasm-tools-1.0.27/wasm-tools-1.0.27-x86_64-linux.tar.gz
1016        tar xfz wasm-tools.tar.gz
1017        rm wasm-tools.tar.gz
1018        echo `pwd`/wasm-tools-1.0.27-x86_64-linux >> $GITHUB_PATH
1019
1020    - run: ./ci/build-wasi-preview1-component-adapter.sh
1021      env:
1022        VERSION: ${{ github.sha }}
1023
1024    - uses: actions/upload-artifact@v4
1025      with:
1026        name: bins-wasi-preview1-component-adapter
1027        path: target/wasm32-unknown-unknown/release/wasi_snapshot_preview1.*.wasm
1028
1029  build-preview1-component-adapter-provider:
1030    name: Build wasi-preview1-component-adapter-provider
1031    needs: build-preview1-component-adapter
1032    runs-on: ubuntu-latest
1033    steps:
1034    - uses: actions/checkout@v4
1035      with:
1036        submodules: true
1037    - uses: ./.github/actions/install-rust
1038    - uses: ./.github/actions/build-adapter-provider
1039      with:
1040        run-id: ${{ github.run_id }}
1041
1042  # Verify the "min platform" example still works.
1043  test-min-platform-example:
1044    name: Test the min-platform example
1045    needs: determine
1046    if: needs.determine.outputs.run-full
1047    runs-on: ubuntu-latest
1048    steps:
1049    - uses: actions/checkout@v4
1050      with:
1051        submodules: true
1052    - uses: ./.github/actions/install-rust
1053    - run: cargo install [email protected] --locked
1054    - run: rustup target add x86_64-unknown-none
1055    - run: rustup target add wasm32-wasip2
1056    - run: ./build.sh x86_64-unknown-none
1057      working-directory: ./examples/min-platform
1058
1059    # Afterwards make sure the generated header file is up to date by ensuring
1060    # that the regeneration process didn't change anything in-tree.
1061    - run: git diff --exit-code
1062
1063    # Test some other feature combinations
1064    - run: ./build.sh x86_64-unknown-none
1065      working-directory: ./examples/min-platform
1066      env:
1067        WASMTIME_SIGNALS_BASED_TRAPS: 1
1068
1069    - run: ./build.sh x86_64-unknown-none
1070      working-directory: ./examples/min-platform
1071      env:
1072        WASMTIME_SIGNALS_BASED_TRAPS: 1
1073        MIN_PLATFORM_TEST_DISABLE_WASI: 1
1074
1075    # Add the `wasmtime-platform.h` file as a release artifact
1076    - uses: actions/upload-artifact@v4
1077      with:
1078        name: wasmtime-platform-header
1079        path: examples/min-platform/embedding/wasmtime-platform.h
1080
1081  bench:
1082    needs: determine
1083    if: needs.determine.outputs.run-full
1084    name: Run benchmarks
1085    runs-on: ubuntu-latest
1086    steps:
1087    - uses: actions/checkout@v4
1088      with:
1089        submodules: true
1090    - uses: ./.github/actions/install-rust
1091    - run: rustup target add wasm32-wasip1
1092    - run: cargo test --benches --release
1093
1094  # Verify that cranelift's code generation is deterministic
1095  meta_deterministic_check:
1096    needs: determine
1097    if: needs.determine.outputs.run-full
1098    name: Meta deterministic check
1099    runs-on: ubuntu-latest
1100    steps:
1101    - uses: actions/checkout@v4
1102      with:
1103        submodules: true
1104    - uses: ./.github/actions/install-rust
1105    - run: cd cranelift/codegen && cargo build --features all-arch
1106    - run: ci/ensure_deterministic_build.sh
1107
1108  verify-publish:
1109    needs: determine
1110    if: github.repository == 'bytecodealliance/wasmtime' && needs.determine.outputs.run-full
1111    runs-on: ubuntu-latest
1112    steps:
1113    - uses: actions/checkout@v4
1114      with:
1115        submodules: true
1116    - uses: ./.github/actions/install-rust
1117    - run: |
1118        cd ${{ runner.tool_cache }}
1119        curl --retry 5 --retry-all-errors -L -o sccache.tar.gz \
1120          https://github.com/mozilla/sccache/releases/download/0.2.13/sccache-0.2.13-x86_64-unknown-linux-musl.tar.gz
1121        tar xzf sccache.tar.gz
1122        rm sccache.tar.gz
1123        echo "`pwd`/sccache-0.2.13-x86_64-unknown-linux-musl" >> $GITHUB_PATH
1124        echo RUSTC_WRAPPER=sccache >> $GITHUB_ENV
1125    - run: rustc scripts/publish.rs
1126    # Make sure the tree is publish-able as-is
1127    - run: ./publish verify
1128    # Make sure we can bump version numbers for the next release
1129    - run: ./publish bump
1130
1131  # Run a subset of tests under MIRI on CI to help check the `unsafe` code in
1132  # Wasmtime to make sure it's at least not obviously incorrect for basic usage.
1133  # Note that this doesn't run the full test suite since MIRI can't actually run
1134  # WebAssembly itself at this time (aka it doesn't support a JIT). There are a
1135  # number of annotations throughout the code which gates some tests on MIRI not
1136  # being run.
1137  #
1138  # Note that `cargo nextest` is used here additionally to get parallel test
1139  # execution by default to help cut down on the time in CI.
1140  miri:
1141    strategy:
1142      matrix:
1143        include:
1144          - crate: "wasmtime"
1145          - crate: "wasmtime-cli"
1146          - crate: "wasmtime-environ --all-features"
1147          - crate: "pulley-interpreter --all-features"
1148          - crate: "wasmtime-internal-error"
1149          - crate: "wasmtime-internal-error --all-features"
1150          - script: ./ci/miri-provenance-test.sh
1151          - script: ./ci/miri-wast.sh ./tests/spec_testsuite/table.wast
1152    needs: determine
1153    if: needs.determine.outputs.test-miri && github.repository == 'bytecodealliance/wasmtime'
1154    name: Miri
1155    runs-on: ubuntu-latest
1156    env:
1157      CARGO_NEXTEST_VERSION: 0.9.88
1158      MIRIFLAGS: -Zmiri-permissive-provenance
1159    steps:
1160    - uses: actions/checkout@v4
1161      with:
1162        submodules: true
1163    - uses: ./.github/actions/install-rust
1164      with:
1165        toolchain: wasmtime-ci-pinned-nightly
1166    - run: rustup component add rust-src miri
1167    - uses: actions/cache@v4
1168      with:
1169        path: ${{ runner.tool_cache }}/cargo-nextest
1170        key: cargo-nextest-bin-${{ env.CARGO_NEXTEST_VERSION }}
1171    - run: echo "${{ runner.tool_cache }}/cargo-nextest/bin" >> $GITHUB_PATH
1172    - run: cargo install --root ${{ runner.tool_cache }}/cargo-nextest --version ${{ env.CARGO_NEXTEST_VERSION }} cargo-nextest --locked
1173    - run: |
1174        cargo miri nextest run -j4 --no-fail-fast -p ${{ matrix.crate }}
1175      if: ${{ matrix.crate }}
1176    - run: ${{ matrix.script }}
1177      if: ${{ matrix.script }}
1178
1179  # Perform release builds of `wasmtime` and `libwasmtime.so`. Builds a variety
1180  # of platforms and architectures and then uploads the release artifacts to
1181  # this workflow run's list of artifacts.
1182  #
1183  # Note that the full matrix is computed by `ci/build-build-matrix.js`.
1184  build:
1185    needs: determine
1186    if: needs.determine.outputs.run-full
1187    name: Release build for ${{ matrix.build }}
1188    runs-on: ${{ matrix.os }}
1189    strategy:
1190      fail-fast: ${{ github.event_name != 'pull_request' }}
1191      matrix: ${{ fromJson(needs.determine.outputs.build-matrix) }}
1192    env: ${{ matrix.env || fromJSON('{}') }}
1193    steps:
1194    - uses: actions/checkout@v4
1195      with:
1196        submodules: true
1197
1198    - uses: ./.github/actions/install-ninja
1199    - uses: ./.github/actions/install-rust
1200      with:
1201        toolchain: ${{ matrix.rust }}
1202    - run: |
1203        rustup component add rust-src
1204        rustup target add ${{ matrix.target }}
1205
1206    # On one builder produce the source tarball since there's no need to produce
1207    # it everywhere
1208    - run: ./ci/build-src-tarball.sh
1209      if: matrix.build == 'x86_64-linux'
1210
1211    - uses: ./.github/actions/android-ndk
1212      if: contains(matrix.target, 'android')
1213      with:
1214        target: ${{ matrix.target }}
1215
1216    - run: ./ci/build-release-artifacts.sh "${{ matrix.build }}" "${{ matrix.target }}"
1217
1218    # Assemble release artifacts appropriate for this platform, then upload them
1219    # unconditionally to this workflow's files so we have a copy of them.
1220    - run: ./ci/build-tarballs.sh "${{ matrix.build }}" "${{ matrix.target }}"
1221
1222    - uses: actions/upload-artifact@v4
1223      with:
1224        name: bins-${{ matrix.build }}
1225        path: dist
1226
1227  # This is a "join node" which depends on all prior workflows. The merge queue,
1228  # for example, gates on this to ensure that everything has executed
1229  # successfully.
1230  #
1231  # Note that this is required currently for odd reasons with github. Notably
1232  # the set of checks to enter the merge queue and leave the merge queue must
1233  # be the same which means that the "build" step for example shows as skipped
1234  # for PRs but expands to many different steps for merge-queue-based PRs. That
1235  # means that for that step there's no single name to gate on, so it's required
1236  # to have a "join" node here which joins everything.
1237  #
1238  # Note that this currently always runs to always report a status, even on
1239  # cancellation and even if dependency steps fail. Each dependency tries to
1240  # cancel the whole run if it fails, so if a test matrix entry fails, for
1241  # example, it cancels the build matrix entries too. This step then tries to
1242  # fail on cancellation to ensure that the dependency failures are propagated
1243  # correctly.
1244  ci-status:
1245    name: Record the result of testing and building steps
1246    runs-on: ubuntu-latest
1247    needs:
1248      - test
1249      - test_capi
1250      - test_debug_dwarf
1251      - test_fuzzing
1252      - test_wasi_nn
1253      - test_nightly
1254      - build
1255      - rustfmt
1256      - clangformat
1257      - cargo_deny
1258      - cargo_vet
1259      - doc
1260      - micro_checks
1261      - special_tests
1262      - test_wasi_tls_nativetls
1263      - clippy
1264      - monolith_checks
1265      - platform_checks
1266      - bench
1267      - meta_deterministic_check
1268      - verify-publish
1269      - determine
1270      - miri
1271      - build-preview1-component-adapter
1272      - build-preview1-component-adapter-provider
1273      - test-min-platform-example
1274      - check_js
1275    if: always()
1276    steps:
1277    # Calculate the exit status of the whole CI workflow.
1278    # If all dependent jobs were successful, this exits with 0 (and the
1279    # outcome job continues successfully). If a some dependent job has
1280    # failed, this exits with 1.
1281    - name: calculate the correct exit status
1282      run: jq --exit-status 'all(.result == "success" or .result == "skipped")' <<< '${{ toJson(needs) }}'
1283
1284  # The purpose of this jobs is to watch for changes on the `release-*`
1285  # branches of this repository and look for the term
1286  # "automatically-tag-and-release-this-commit" within merged PRs/commits. Once
1287  # that term is found the current version of `Cargo.toml`, the `wasmtime-cli`
1288  # Cargo.toml, is created as a tag and the tag is pushed to the repo.
1289  # Currently the tag is created through the GitHub API with an access token to
1290  # ensure that CI is further triggered for the tag itself which performs the
1291  # full release process.
1292  #
1293  # Note that this depends on the `ci-status` step above which is the "join"
1294  # point of this workflow for when everything succeeds. the purpose of that is
1295  # so that the tag is only created after the aftifacts have been uploaded for
1296  # this workflow as the `publish-artifacts.yml` workflow will download these
1297  # artifacts and then publish them to the tag.
1298  push-tag:
1299    runs-on: ubuntu-latest
1300    needs: ci-status
1301    if: |
1302      always()
1303      && needs.ci-status.result == 'success'
1304      && github.event_name == 'push'
1305      && startsWith(github.ref, 'refs/heads/release-')
1306      && github.repository == 'bytecodealliance/wasmtime'
1307    steps:
1308    - uses: actions/checkout@v4
1309      with:
1310        submodules: true
1311        fetch-depth: 0
1312    - name: Test if tag is needed
1313      run: |
1314        git log ${{ github.event.before }}...${{ github.event.after }} | tee main.log
1315        version=$(grep '^version =' Cargo.toml | head -n 1 | sed 's/.*"\(.*\)"/\1/')
1316        echo "version: $version"
1317        echo "version=$version" >> $GITHUB_OUTPUT
1318        echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
1319        if grep -q "automatically-tag-and-release-this-commit" main.log; then
1320          echo push-tag
1321          echo "push_tag=yes" >> $GITHUB_OUTPUT
1322        else
1323          echo no-push-tag
1324          echo "push_tag=no" >> $GITHUB_OUTPUT
1325        fi
1326      id: tag
1327    - name: Push the tag
1328      run: |
1329        git_refs_url=$(jq .repository.git_refs_url $GITHUB_EVENT_PATH | tr -d '"' | sed 's/{\/sha}//g')
1330        curl -iX POST $git_refs_url \
1331          -H "Authorization: token ${{ secrets.PERSONAL_ACCESS_TOKEN }}" \
1332          -d @- << EOF
1333        {
1334          "ref": "refs/tags/v${{ steps.tag.outputs.version }}",
1335          "sha": "${{ steps.tag.outputs.sha }}"
1336        }
1337        EOF
1338      if: steps.tag.outputs.push_tag == 'yes'
1339
1340  # File an issue on the repo if this run failed and was triggered via
1341  # `workflow_dispatch`, which mostly means that
1342  # `.github/workflows/trigger-release-branch-ci.yml` will file issues on
1343  # failure so we get to see a notification when a build fails for a historical
1344  # release branch.
1345  file-issue-on-error:
1346    name: File an issue if this build failed and was cron-triggered
1347    runs-on: ubuntu-latest
1348    needs: ci-status
1349    if: |
1350      always()
1351      && needs.ci-status.result != 'success'
1352      && github.event_name == 'workflow_dispatch'
1353    permissions:
1354      issues: write
1355    steps:
1356    - uses: actions/github-script@v7
1357      with:
1358        script: |
1359          github.rest.issues.create({
1360            owner: context.repo.owner,
1361            repo: context.repo.repo,
1362            title: `Failed CI build for ${context.ref}`,
1363            body: `See https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`,
1364          })
1365