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@v6 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@v6 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@v6 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@v6 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@v6 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@v6 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: -Dwarnings --cfg docsrs 265 OPENVINO_SKIP_LINKING: 1 266 steps: 267 - uses: actions/checkout@v6 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@v5 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 - run: cargo doc --package cranelift-codegen-meta --document-private-items 308 309 # Assemble the documentation, and always upload it as an artifact for 310 # inspection on PRs and such. 311 - run: | 312 mv docs/book gh-pages 313 mv crates/c-api/html gh-pages/c-api 314 mv target/doc gh-pages/api 315 tar czf gh-pages.tar.gz gh-pages 316 - uses: actions/upload-artifact@v6 317 with: 318 name: gh-pages 319 path: gh-pages.tar.gz 320 321 # Checks of various feature combinations and whether things compile. The goal 322 # here isn't to run tests, mostly just serve as a double-check that Rust code 323 # compiles and is likely to work everywhere else. 324 micro_checks: 325 name: Check ${{matrix.name}} 326 strategy: 327 fail-fast: ${{ github.event_name != 'pull_request' }} 328 matrix: 329 include: 330 - name: wasmtime 331 checks: | 332 -p wasmtime --no-default-features 333 -p wasmtime --no-default-features --features wat 334 -p wasmtime --no-default-features --features profiling 335 -p wasmtime --no-default-features --features cache 336 -p wasmtime --no-default-features --features async 337 -p wasmtime --no-default-features --features std 338 -p wasmtime --no-default-features --features pooling-allocator 339 -p wasmtime --no-default-features --features cranelift 340 -p wasmtime --no-default-features --features component-model 341 -p wasmtime --no-default-features --features component-model-async 342 -p wasmtime --no-default-features --features runtime,component-model 343 -p wasmtime --no-default-features --features cranelift,wat,async,std,cache 344 -p wasmtime --no-default-features --features winch 345 -p wasmtime --no-default-features --features wmemcheck 346 -p wasmtime --no-default-features --features wmemcheck,cranelift,runtime 347 -p wasmtime --no-default-features --features demangle 348 -p wasmtime --no-default-features --features addr2line 349 -p wasmtime --no-default-features --features gc 350 -p wasmtime --no-default-features --features runtime,gc 351 -p wasmtime --no-default-features --features cranelift,gc 352 -p wasmtime --no-default-features --features gc-drc 353 -p wasmtime --no-default-features --features runtime,gc-drc 354 -p wasmtime --no-default-features --features cranelift,gc-drc 355 -p wasmtime --no-default-features --features gc-null 356 -p wasmtime --no-default-features --features runtime,gc-null 357 -p wasmtime --no-default-features --features cranelift,gc-null 358 -p wasmtime --no-default-features --features runtime 359 -p wasmtime --no-default-features --features threads 360 -p wasmtime --no-default-features --features runtime,threads 361 -p wasmtime --no-default-features --features cranelift,threads 362 -p wasmtime --no-default-features --features stack-switching 363 -p wasmtime --no-default-features --features cranelift,stack-switching 364 -p wasmtime --no-default-features --features runtime,stack-switching 365 -p wasmtime --no-default-features --features debug 366 -p wasmtime --no-default-features --features debug,gc 367 -p wasmtime --no-default-features --features runtime,cache 368 -p wasmtime --features incremental-cache 369 -p wasmtime --features profile-pulley 370 -p wasmtime --all-features 371 372 - name: wasmtime-fiber 373 checks: | 374 -p wasmtime-internal-fiber --no-default-features 375 -p wasmtime-internal-fiber --no-default-features --features std 376 -p wasmtime-internal-fiber --all-features 377 378 - name: wasmtime-cli 379 checks: | 380 -p wasmtime-cli --no-default-features 381 -p wasmtime-cli --no-default-features --features pooling-allocator 382 -p wasmtime-cli --no-default-features --features run 383 -p wasmtime-cli --no-default-features --features run,component-model 384 -p wasmtime-cli --no-default-features --features run,pooling-allocator 385 -p wasmtime-cli --no-default-features --features compile 386 -p wasmtime-cli --no-default-features --features compile,cranelift 387 -p wasmtime-cli --no-default-features --features compile,cranelift,component-model 388 -p wasmtime-cli --no-default-features --features objdump 389 -p wasmtime-cli --no-default-features --features wizer 390 -p wasmtime-cli --no-default-features --features gdbstub 391 -p wasmtime-cli --all-features 392 -p wasmtime-cli --features component-model 393 394 - name: cranelift-codegen 395 checks: | 396 -p cranelift-codegen --benches 397 -p cranelift-codegen --no-default-features --features std,unwind,pulley 398 399 - name: cranelift-entity 400 checks: | 401 -p cranelift-entity --no-default-features 402 -p cranelift-entity --no-default-features --features enable-serde 403 404 - name: wasmtime-bench-api 405 checks: | 406 -p wasmtime-bench-api 407 408 - name: wasmtime-c-api 409 checks: | 410 -p wasmtime-c-api --no-default-features 411 -p wasmtime-c-api --no-default-features --features wat 412 -p wasmtime-c-api --no-default-features --features wasi 413 414 - name: wasmtime-wasi-http 415 checks: | 416 -p wasmtime-wasi-http --no-default-features 417 -p wasmtime-wasi-http --no-default-features --features p2 418 -p wasmtime-wasi-http --no-default-features --features p3 419 -p wasmtime-wasi-http --no-default-features --features p3 --all-targets 420 421 - name: wasmtime-wasi 422 checks: | 423 -p wasmtime-wasi --no-default-features 424 -p wasmtime-wasi --no-default-features --features p0 425 -p wasmtime-wasi --no-default-features --features p1 426 -p wasmtime-wasi --no-default-features --features p2 427 -p wasmtime-wasi --no-default-features --features p3 428 429 - name: wasmtime-wasi-tls 430 checks: | 431 -p wasmtime-wasi-tls --no-default-features 432 -p wasmtime-wasi-tls --no-default-features --features rustls 433 -p wasmtime-wasi-tls --no-default-features --features nativetls 434 -p wasmtime-wasi-tls --no-default-features --features openssl 435 436 - name: wasmtime-wizer 437 checks: | 438 -p wasmtime-wizer --no-default-features 439 -p wasmtime-wizer --no-default-features --features wasmtime 440 -p wasmtime-wizer --no-default-features --features wasmprinter 441 -p wasmtime-wizer --no-default-features --features component-model 442 -p wasmtime-wizer --no-default-features --features rayon 443 -p wasmtime-wizer --no-default-features --all-features 444 runs-on: ubuntu-latest 445 steps: 446 - uses: actions/checkout@v6 447 with: 448 submodules: true 449 - uses: ./.github/actions/install-rust 450 451 # Run the check. 452 - run: | 453 checks=$(cat <<END 454 ${{ matrix.checks }} 455 END 456 ) 457 echo "$checks" | xargs -I CHECK sh -c 'echo "=== cargo check CHECK ==="; cargo check CHECK' 458 459 special_tests: 460 name: One-off special tests 461 runs-on: ubuntu-latest 462 needs: determine 463 if: needs.determine.outputs.run-full 464 steps: 465 - uses: actions/checkout@v6 466 with: 467 submodules: true 468 - uses: ./.github/actions/install-rust 469 - run: cargo test -p wasmtime-internal-fiber --no-default-features 470 - run: cargo test -p cranelift-tools --test logged-filetests 471 472 # Check that Clippy lints are passing. 473 clippy: 474 name: Clippy 475 runs-on: ubuntu-latest 476 env: 477 CARGO_NDK_VERSION: 2.12.2 478 steps: 479 - uses: actions/checkout@v6 480 with: 481 submodules: true 482 - uses: ./.github/actions/install-rust 483 484 - run: rustup component add clippy 485 - run: cargo clippy --workspace --all-targets --features p3,component-model-async 486 487 # Similar to `micro_checks` but where we need to install some more state 488 # (e.g. Android NDK) and we haven't factored support for those things out into 489 # a parallel jobs yet. 490 monolith_checks: 491 name: Monolith Checks 492 runs-on: ubuntu-latest 493 env: 494 CARGO_NDK_VERSION: 2.12.2 495 steps: 496 - uses: actions/checkout@v6 497 with: 498 submodules: true 499 - uses: ./.github/actions/install-rust 500 501 # Check that wasmtime compiles with panic=abort since there's some `#[cfg]` 502 # for specifically panic=abort there. 503 - run: cargo check -p wasmtime 504 env: 505 RUSTFLAGS: -Cpanic=abort 506 507 # Check a few builds of the cranelift backend 508 # - only x86 backend support, 509 # - only arm64 backend support, 510 # - no debug_assertions. 511 - run: cargo check --manifest-path=./cranelift/Cargo.toml --bin clif-util --no-default-features --features=cranelift-codegen/arm64 512 - run: cargo check --manifest-path=./cranelift/Cargo.toml --bin clif-util --no-default-features --features=cranelift-codegen/x86 513 - run: cargo check --manifest-path=./cranelift/Cargo.toml --bin clif-util 514 env: 515 CARGO_PROFILE_DEV_DEBUG_ASSERTIONS: false 516 517 # Re-vendor all WIT files and ensure that they're all up-to-date by ensuring 518 # that there's no git changes. 519 - name: Install wkg 520 run: | 521 curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash 522 cargo binstall --no-confirm [email protected] 523 - name: Re-vendor WIT 524 run: ./ci/vendor-wit.sh 525 - run: git diff --exit-code 526 527 # Re-vendor the C API and make sure it's up-to-date. 528 - name: Re-vendor C API 529 run: ./ci/vendor-c-api-headers.sh 530 - run: git diff --exit-code 531 532 # Various checks that Wasmtime builds for a variety of platforms. Each 533 # platform may not include the entire dependency tree and maybe just a few 534 # features here and there, see the `include` matrix for more details. 535 platform_checks: 536 needs: determine 537 if: needs.determine.outputs.platform-checks 538 name: "Platform: ${{ matrix.target }}" 539 runs-on: ${{ matrix.os }} 540 strategy: 541 fail-fast: ${{ github.event_name != 'pull_request' }} 542 matrix: 543 include: 544 - target: x86_64-unknown-freebsd 545 os: ubuntu-latest 546 test: cargo check 547 - target: aarch64-pc-windows-msvc 548 os: windows-latest 549 test: cargo check 550 # While we're here testing a windows target also test a feature'd build 551 # on Windows. Note that this isn't covered by `micro_checks` above since 552 # that's for unix platforms, not Windows, so include a small check here 553 # which isn't the full `micro_checks` matrix but hopefully enough bang 554 # for our buck. 555 - target: i686-pc-windows-msvc 556 os: windows-latest 557 test: cargo check && cargo build -p wasmtime --no-default-features --features runtime 558 # This is used for general compatibility with `#![no_std]` targets and a 559 # variety of crates are tested here. 560 - target: x86_64-unknown-none 561 os: ubuntu-latest 562 test: > 563 cargo check -p wasmtime --no-default-features --features runtime,component-model && 564 cargo check -p wasmtime --no-default-features --features runtime,gc,component-model,pulley,async,debug,debug-builtins,demangle,anyhow && 565 cargo check -p cranelift-control --no-default-features && 566 cargo check -p cranelift-assembler-x64 --lib && 567 cargo check -p cranelift-codegen --no-default-features --features x86,arm64 && 568 cargo check -p pulley-interpreter --features encode,decode,disas,interp && 569 cargo check -p wasmtime-wasi-io --no-default-features 570 # Use `cross` for illumos to have a C compiler/linker available. 571 - target: x86_64-unknown-illumos 572 os: ubuntu-latest 573 cross: true 574 test: cross build 575 - target: wasm32-wasip1 576 os: ubuntu-latest 577 test: cargo build --no-default-features --features compile,cranelift,all-arch 578 - target: aarch64-apple-ios 579 os: macos-latest 580 test: cargo build 581 env: 582 IPHONEOS_DEPLOYMENT_TARGET: 13.0 583 # Test that when Cranelift has no support for an architecture, even a 584 # 64-bit one, that Wasmtime still compiles. Note that this is also 585 # intended to test various fallbacks in the codebase where we have no 586 # support at all for a particular architecture. In theory if someone 587 # adds powerpc64 support to Wasmtime this should get switched to some 588 # other architecture. 589 - target: powerpc64le-unknown-linux-gnu 590 os: ubuntu-latest 591 test: cargo build 592 apt_packages: gcc-powerpc64le-linux-gnu 593 env: 594 CARGO_TARGET_POWERPC64LE_UNKNOWN_LINUX_GNU_LINKER: powerpc64le-linux-gnu-gcc 595 # A no_std target without 64-bit atomics 596 - target: riscv32imac-unknown-none-elf 597 os: ubuntu-latest 598 test: cargo check -p wasmtime --no-default-features --features runtime,gc,component-model,async 599 env: ${{ matrix.env || fromJSON('{}') }} 600 steps: 601 - uses: actions/checkout@v6 602 with: 603 submodules: true 604 - uses: ./.github/actions/install-rust 605 - run: rustup target add ${{ matrix.target }} 606 - name: Install cross 607 run: | 608 curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash 609 cargo binstall --no-confirm cross 610 if: ${{ matrix.cross }} 611 - name: Install apt packages 612 if: ${{ matrix.apt_packages }} 613 run: sudo apt-get update && sudo apt-get install -y ${{ matrix.apt_packages }} 614 - run: ${{ matrix.test }} 615 env: 616 CARGO_BUILD_TARGET: ${{ matrix.target }} 617 618 # Run tests that require a nightly compiler, such as building fuzz targets. 619 test_nightly: 620 needs: determine 621 if: needs.determine.outputs.test-nightly 622 name: Nightly tests 623 runs-on: ubuntu-latest 624 steps: 625 - uses: actions/checkout@v6 626 with: 627 submodules: true 628 - uses: ./.github/actions/install-rust 629 with: 630 # This is pinned to match the version of Rust used on OSS-Fuzz to build 631 # Wasmtime. Do not change this `toolchain` version. 632 toolchain: wasmtime-ci-oss-fuzz-pin 633 634 # Check that `pulley-interpreter` works with tail calls enabled. 635 - run: cargo test -p pulley-interpreter --all-features 636 env: 637 RUSTFLAGS: "--cfg pulley_tail_calls" 638 - run: cargo check -p pulley-interpreter --all-features 639 env: 640 RUSTFLAGS: "--cfg pulley_disable_interp_simd" 641 - run: cargo test -p pulley-interpreter --all-features --release 642 env: 643 RUSTFLAGS: "--cfg pulley_assume_llvm_makes_tail_calls" 644 645 # Run OOM tests with `Arc::try_new` usage enabled. 646 - run: cargo test -p wasmtime-fuzzing --test oom 647 env: 648 RUSTFLAGS: "--cfg arc_try_new" 649 650 # Ensure that fuzzers still build. 651 # 652 # Install the OCaml packages necessary for fuzz targets that use the 653 # `wasm-spec-interpreter`. 654 - run: cargo install cargo-fuzz --vers "^0.11" --locked 655 - run: sudo apt-get update && sudo apt install -y ocaml-nox ocamlbuild ocaml-findlib libzarith-ocaml-dev 656 - run: cargo fetch 657 working-directory: ./fuzz 658 - run: cargo fuzz check --dev 659 - run: cargo fuzz check --dev --fuzz-dir ./cranelift/isle/fuzz 660 - run: cargo fuzz check --dev --fuzz-dir ./crates/environ/fuzz --features component-model 661 - run: cargo fuzz check --dev --fuzz-dir ./cranelift/assembler-x64/fuzz 662 - run: cargo fuzz check --dev --fuzz-dir ./crates/wizer/fuzz 663 664 # Perform all tests of the c-api 665 test_capi: 666 needs: determine 667 name: Test C-API ${{ matrix.name }} 668 runs-on: ${{ matrix.os }} 669 if: needs.determine.outputs.test-capi 670 671 strategy: 672 fail-fast: ${{ github.event_name != 'pull_request' }} 673 matrix: 674 include: 675 # This configuration will build C/C++ tests, examples, and Rust tests. 676 # Everything is linked against the C shared library to speed up 677 # linking, and this is intended to be the "main set of tests". 678 # 679 # Run this on windows/mac/linux 680 - os: ubuntu-24.04 681 # Only run the "plugins" example on Linux 682 flags: -DBUILD_SHARED_LIBS=ON -DBUILD_TESTS=ON -DBUILD_RUST_EXAMPLES=ON -DBUILD_RUST_PLUGINS_EXAMPLE=ON 683 name: Linux 684 - os: macos-15 685 flags: -DBUILD_SHARED_LIBS=ON -DBUILD_TESTS=ON -DBUILD_RUST_EXAMPLES=ON 686 name: macOS 687 - os: windows-2025 688 # Note that dynamic linking is disabled here because I don't want to 689 # have to deal with figuring out how to get `wasmtime.dll` onto 690 # `PATH` for various tests. 691 flags: -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTS=ON -DBUILD_RUST_EXAMPLES=ON 692 name: Windows 693 694 # This tests using static linking for examples but skips building the 695 # Rust examples as well as C/C++ tests. Intended to be a faster build 696 # which mostly just tests static linking. 697 - os: ubuntu-24.04 698 flags: -DBUILD_SHARED_LIBS=OFF -DBUILD_RUST_EXAMPLES=OFF 699 name: Linux (static linking) 700 701 # Run tests with ASAN for leak checking primarily. 702 - os: ubuntu-24.04 703 flags: -DCMAKE_C_FLAGS=-fsanitize=address -DCMAKE_CXX_FLAGS=-fsanitize=address -DBUILD_SHARED_LIBS=ON -DBUILD_TESTS=ON 704 name: Linux (ASAN) 705 steps: 706 - uses: actions/checkout@v6 707 with: 708 submodules: true 709 - uses: ./.github/actions/install-rust 710 - run: rustup target add wasm32-wasip2 711 712 - uses: ./.github/actions/install-plugins-prerequisites 713 if: runner.os == 'Linux' 714 715 - uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 716 # An ode to MinGW: man you're a pain to work around sometimes 717 - run: rm /usr/bin/link 718 if: runner.os == 'Windows' 719 720 - run: cmake -G Ninja -Sexamples -DCMAKE_BUILD_TYPE=Debug -Bexamples/build ${{ matrix.flags }} 721 - run: ninja -C examples/build 722 - run: ninja -C examples/build test 723 env: 724 CTEST_OUTPUT_ON_FAILURE: 1 725 CTEST_PARALLEL_LEVEL: 4 726 727 # Perform all tests (debug mode) for `wasmtime`. 728 # 729 # Note that the full matrix for what may run here is defined within 730 # `./ci/build-test-matrix.js` and the execution of the `determine` step will 731 # calculate whether the tests are actually run as part of PRs and such. 732 test: 733 needs: determine 734 name: ${{ matrix.name }} 735 runs-on: ${{ matrix.os }} 736 env: 737 QEMU_BUILD_VERSION: 10.0.3 738 SDE_BUILD_VERSION: 9.58.0-2025-06-16 739 strategy: 740 fail-fast: ${{ github.event_name != 'pull_request' }} 741 matrix: ${{ fromJson(needs.determine.outputs.test-matrix) }} 742 steps: 743 - uses: actions/checkout@v6 744 with: 745 submodules: true 746 - uses: ./.github/actions/install-rust 747 with: 748 toolchain: ${{ matrix.rust }} 749 750 # Install targets in order to build various tests throughout the repo 751 - run: rustup target add wasm32-wasip1 wasm32-unknown-unknown wasm32-wasip2 ${{ matrix.target }} 752 - run: echo CARGO_BUILD_TARGET=${{ matrix.target }} >> $GITHUB_ENV 753 if: matrix.target != '' 754 755 # Fix an ICE for now in gcc when compiling zstd with debuginfo (??) 756 - run: echo CFLAGS=-g0 >> $GITHUB_ENV 757 if: matrix.target == 'x86_64-pc-windows-gnu' 758 759 # Update binutils if MinGW due to https://github.com/rust-lang/rust/issues/112368 760 - run: C:/msys64/usr/bin/pacman.exe -S --needed mingw-w64-x86_64-gcc --noconfirm 761 if: matrix.target == 'x86_64-pc-windows-gnu' 762 - shell: pwsh 763 run: echo "C:\msys64\mingw64\bin" >> $Env:GITHUB_PATH 764 if: matrix.target == 'x86_64-pc-windows-gnu' 765 766 - run: cargo fetch --locked 767 768 - name: Install cross-compilation tools 769 run: | 770 set -ex 771 772 sudo apt-get update 773 sudo apt-get install -y ${{ matrix.gcc_package }} 774 775 # Configure Cargo for cross compilation and tell it how it can run 776 # cross executables 777 upcase=$(echo ${{ matrix.target }} | awk '{ print toupper($0) }' | sed 's/-/_/g') 778 echo CARGO_TARGET_${upcase}_LINKER=${{ matrix.gcc }} >> $GITHUB_ENV 779 if: matrix.gcc != '' 780 781 - uses: actions/cache@v5 782 with: 783 path: ${{ runner.tool_cache }}/qemu 784 key: qemu-${{ matrix.target }}-${{ env.QEMU_BUILD_VERSION }}-patchcpuinfo 785 if: matrix.qemu != '' 786 787 - uses: actions/cache@v5 788 with: 789 path: ${{ runner.tool_cache }}/sde 790 key: sde-${{ env.SDE_BUILD_VERSION }} 791 if: matrix.sde != '' 792 793 - name: Install qemu 794 run: | 795 set -ex 796 797 upcase=$(echo ${{ matrix.target }} | awk '{ print toupper($0) }' | sed 's/-/_/g') 798 echo CARGO_TARGET_${upcase}_RUNNER=${{ runner.tool_cache }}/qemu/bin/${{ matrix.qemu }} >> $GITHUB_ENV 799 800 # QEMU emulation is not always the speediest, so total testing time 801 # goes down if we build the libs in release mode when running tests. 802 echo CARGO_PROFILE_DEV_OPT_LEVEL=2 >> $GITHUB_ENV 803 804 # See comments in the source for why we enable this during QEMU 805 # emulation. 806 echo WASMTIME_TEST_NO_HOG_MEMORY=1 >> $GITHUB_ENV 807 808 # See if qemu is already in the cache 809 if [ -f ${{ runner.tool_cache }}/qemu/built ]; then 810 exit 0 811 fi 812 813 # Install build dependencies of QEMU itself. 814 sudo apt-get install -y libglib2.0-dev ninja-build 815 816 # Download and build qemu from source since the most recent release is 817 # way faster at arm emulation than the current version github actions' 818 # ubuntu image uses. Disable as much as we can to get it to build 819 # quickly. 820 curl --retry 5 --retry-all-errors -o qemu.tar.xz https://download.qemu.org/qemu-$QEMU_BUILD_VERSION.tar.xz 821 tar xJf qemu.tar.xz 822 rm qemu.tar.xz 823 cd qemu-$QEMU_BUILD_VERSION 824 ./configure --target-list=${{ matrix.qemu_target }} --prefix=${{ runner.tool_cache}}/qemu --disable-tools --disable-slirp --disable-fdt --disable-capstone --disable-docs 825 ninja -C build install 826 touch ${{ runner.tool_cache }}/qemu/built 827 if: matrix.qemu != '' 828 829 - name: Install Intel SDE 830 run: | 831 set -ex 832 833 # Set up SDE as runner for x86_64 targets 834 echo "CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER=${{ runner.tool_cache }}/sde/sde64 -future --" >> $GITHUB_ENV 835 836 # SDE emulation is very slow, so use release mode for better performance 837 echo CARGO_PROFILE_DEV_OPT_LEVEL=2 >> $GITHUB_ENV 838 839 # Enable environment variable to indicate SDE is being used 840 echo WASMTIME_TEST_SDE=1 >> $GITHUB_ENV 841 842 # Generic variable for skipping tests that are problematic under SDE (performance, compatibility, etc.) 843 echo WASMTIME_TEST_NO_SDE=1 >> $GITHUB_ENV 844 845 # Similar to QEMU, reduce memory usage during SDE emulation 846 echo WASMTIME_TEST_NO_HOG_MEMORY=1 >> $GITHUB_ENV 847 848 # See if SDE is already in the cache 849 if [ -f ${{ runner.tool_cache }}/sde/sde64 ]; then 850 exit 0 851 fi 852 853 curl --retry 5 --retry-all-errors -o sde.tar.xz \ 854 https://downloadmirror.intel.com/859732/sde-external-${{ env.SDE_BUILD_VERSION }}-lin.tar.xz 855 856 mkdir -p ${{ runner.tool_cache }}/sde 857 tar xJf sde.tar.xz --strip-components=1 -C ${{ runner.tool_cache }}/sde 858 rm sde.tar.xz 859 860 chmod +x ${{ runner.tool_cache }}/sde/sde64 861 if: matrix.sde != '' 862 863 - name: Configure ASAN 864 run: | 865 echo CARGO_PROFILE_DEV_OPT_LEVEL=2 >> $GITHUB_ENV 866 echo CARGO_PROFILE_TEST_OPT_LEVEL=2 >> $GITHUB_ENV 867 echo RUSTFLAGS=-Zsanitizer=address >> $GITHUB_ENV 868 echo RUSTDOCFLAGS="-Zsanitizer=address -Copt-level=2 -Ccodegen-units=16" >> $GITHUB_ENV 869 if: ${{ contains(matrix.name, 'ASAN') }} 870 871 # Record some CPU details; this is helpful information if tests fail due 872 # to CPU-specific features. 873 - name: CPU information 874 run: lscpu 875 if: runner.os == 'Linux' 876 - name: CPU information 877 run: sysctl hw 878 if: runner.os == 'macOS' 879 - name: CPU information 880 run: Get-WmiObject Win32_Processor 881 shell: pwsh 882 if: runner.os == 'Windows' 883 884 # Since MPK (PKU) is not present on some GitHub runners, we check if it is 885 # available before force-enabling it. This occasional testing is better than 886 # none at all; ideally we would test in a system-mode QEMU VM. 887 - name: Force-run with MPK enabled, if available 888 if: ${{ contains(matrix.name, 'MPK') }} 889 run: | 890 if cargo run --example mpk-available; then 891 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." 892 echo WASMTIME_TEST_FORCE_MPK=1 >> $GITHUB_ENV 893 else 894 echo "::warning::This CI run will not test MPK; it has been detected as not available on this machine (\`cargo run --example mpk-available\`)." 895 fi 896 897 # Install VTune, see `cli_tests::profile_with_vtune`. 898 - name: Install VTune 899 if: matrix.filter == 'linux-x64' && contains(matrix.bucket, 'wasmtime-cli') 900 uses: abrown/install-vtune-action@v3 901 902 # Build and test all features. 903 # 904 # Note that this uses a different shell, notably not `bash` on Windows. In 905 # the past `bash` would add more items to `PATH` on Windows which would 906 # interfere and cause the `gcc.exe` executable to fail and exit with 1 and 907 # no output. It's believed that `bash` adds things like `/usr/bin` to PATH 908 # which is the wrong DLL or something like that. 909 - run: python3 ./ci/run-tests.py --locked ${{ matrix.bucket }} 910 if: runner.os == 'Windows' 911 shell: pwsh 912 - run: python3 ./ci/run-tests.py --locked ${{ matrix.bucket }} 913 if: runner.os != 'Windows' 914 915 # Test `wasmtime-wasi-nn` in its own job, as not all of its backends are 916 # compatible with all targets, and each must be tested separately anyways. 917 test_wasi_nn: 918 strategy: 919 matrix: 920 feature: ["openvino", "onnx-download"] 921 os: ["ubuntu-24.04", "windows-2025"] 922 include: 923 - os: windows-2025 924 feature: winml 925 name: Test wasi-nn (${{ matrix.feature }}, ${{ matrix.os }}) 926 runs-on: ${{ matrix.os }} 927 needs: determine 928 if: needs.determine.outputs.run-full 929 steps: 930 - uses: actions/checkout@v6 931 with: 932 submodules: true 933 - uses: ./.github/actions/install-rust 934 935 # Install OpenVINO 936 - uses: abrown/install-openvino-action@v10 937 if: runner.arch == 'X64' 938 939 # Install WinML for testing wasi-nn WinML backend. WinML is only available 940 # on Windows clients and Windows Server with desktop experience enabled. 941 # GitHub Actions Window Server image doesn't have desktop experience 942 # enabled, so we download the standalone library from ONNX Runtime project. 943 - uses: nuget/setup-nuget@v2 944 if: (runner.os == 'Windows') && (matrix.feature == 'winml') 945 - run: nuget install Microsoft.AI.MachineLearning 946 if: (runner.os == 'Windows') && (matrix.feature == 'winml') 947 948 # Install Rust targets. 949 - run: rustup target add wasm32-wasip1 wasm32-wasip2 950 951 # Run the tests! 952 - run: cargo test -p wasmtime-wasi-nn --features ${{ matrix.feature }} 953 954 # Test `wasmtime-wasi-tls` in its own job, as not all of its providers are 955 # compatible with all targets. The primary culprit is the OpenSSL dependency, 956 # which is not easily available on all platforms. 957 # 958 # The Windows base image has OpenSSL installed by default, but not in a way 959 # that is automatically discoverable by `openssl-sys`. We need to configure 960 # the OPENSSL_DIR & OPENSSL_LIB_DIR paths manually. 961 # Additionally, the GH actions Windows image does not ship with a CA cert 962 # bundle, so we use the one from cUrl. 963 test_wasi_tls: 964 name: Test wasi-tls 965 needs: determine 966 if: needs.determine.outputs.run-full 967 runs-on: ${{ matrix.os }} 968 strategy: 969 matrix: 970 os: [ubuntu-latest, windows-latest, macos-latest] 971 steps: 972 - uses: actions/checkout@v6 973 with: 974 submodules: true 975 - uses: ./.github/actions/install-rust 976 - name: Configure OpenSSL (Windows) 977 if: runner.os == 'Windows' 978 shell: pwsh 979 run: | 980 mkdir "C:\Program Files\OpenSSL\certs" 981 $sslCertFile = "C:\Program Files\OpenSSL\certs\cacert.pem" 982 $opensslDir = "C:\Program Files\OpenSSL" 983 $opensslLibDir = "C:\Program Files\OpenSSL\lib\VC\x64\MD" 984 curl.exe -o $sslCertFile https://curl.se/ca/cacert.pem 985 "SSL_CERT_FILE=$sslCertFile" | Out-File -FilePath $env:GITHUB_ENV -Append 986 "OPENSSL_DIR=$opensslDir" | Out-File -FilePath $env:GITHUB_ENV -Append 987 "OPENSSL_LIB_DIR=$opensslLibDir" | Out-File -FilePath $env:GITHUB_ENV -Append 988 - run: cargo test -p wasmtime-wasi-tls --all-features 989 990 # Test the `wasmtime-fuzzing` crate. Split out from the main tests because 991 # `--all-features` brings in OCaml, which is a pain to get setup for all 992 # targets. 993 test_fuzzing: 994 needs: determine 995 if: needs.determine.outputs.run-full 996 name: Test wasmtime-fuzzing 997 runs-on: 'ubuntu-latest' 998 steps: 999 - uses: actions/checkout@v6 1000 with: 1001 submodules: true 1002 - uses: ./.github/actions/install-rust 1003 1004 # Run the tests 1005 - run: | 1006 cargo test -p wasmtime-fuzzing -p wasm-spec-interpreter 1007 1008 # Test debug (DWARF) related functionality. 1009 test_debug_dwarf: 1010 needs: determine 1011 if: needs.determine.outputs.run-dwarf 1012 name: Test DWARF debugging 1013 runs-on: ubuntu-24.04 1014 steps: 1015 - uses: actions/checkout@v6 1016 with: 1017 submodules: true 1018 - uses: ./.github/actions/install-rust 1019 - run: | 1020 rustup target add wasm32-wasip2 wasm32-wasip1 wasm32-unknown-unknown 1021 cd /tmp 1022 curl --retry 5 --retry-all-errors -OL https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-30/wasi-sdk-30.0-x86_64-linux.tar.gz 1023 tar -xzf wasi-sdk-30.0-x86_64-linux.tar.gz 1024 mv wasi-sdk-30.0-x86_64-linux wasi-sdk 1025 - run: | 1026 sudo apt-get update && sudo apt-get install -y gdb lldb-18 llvm 1027 # workaround for https://bugs.launchpad.net/ubuntu/+source/llvm-defaults/+bug/1972855 1028 sudo mkdir -p /usr/lib/local/lib/python3.10/dist-packages/lldb 1029 sudo ln -s /usr/lib/llvm-15/lib/python3.10/dist-packages/lldb/* /usr/lib/python3/dist-packages/lldb/ 1030 # Only testing release since it is more likely to expose issues with our low-level symbol handling. 1031 cargo test --release --test all -- --ignored --test-threads 1 native_debug:: 1032 env: 1033 LLDB: lldb-18 1034 WASI_SDK_PATH: /tmp/wasi-sdk 1035 1036 build-preview1-component-adapter: 1037 name: Build wasi-preview1-component-adapter 1038 needs: determine 1039 if: needs.determine.outputs.preview1-adapter 1040 runs-on: ubuntu-latest 1041 permissions: 1042 deployments: write 1043 contents: write 1044 steps: 1045 - uses: actions/checkout@v6 1046 with: 1047 submodules: true 1048 - uses: ./.github/actions/install-rust 1049 - run: rustup target add wasm32-wasip2 wasm32-wasip1 wasm32-unknown-unknown 1050 1051 - name: Install wasm-tools 1052 run: | 1053 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 1054 tar xfz wasm-tools.tar.gz 1055 rm wasm-tools.tar.gz 1056 echo `pwd`/wasm-tools-1.0.27-x86_64-linux >> $GITHUB_PATH 1057 1058 - run: ./ci/build-wasi-preview1-component-adapter.sh 1059 env: 1060 VERSION: ${{ github.sha }} 1061 1062 - uses: actions/upload-artifact@v6 1063 with: 1064 name: bins-wasi-preview1-component-adapter 1065 path: target/wasm32-unknown-unknown/release/wasi_snapshot_preview1.*.wasm 1066 1067 build-preview1-component-adapter-provider: 1068 name: Build wasi-preview1-component-adapter-provider 1069 needs: build-preview1-component-adapter 1070 runs-on: ubuntu-latest 1071 steps: 1072 - uses: actions/checkout@v6 1073 with: 1074 submodules: true 1075 - uses: ./.github/actions/install-rust 1076 - uses: ./.github/actions/build-adapter-provider 1077 with: 1078 run-id: ${{ github.run_id }} 1079 1080 # Verify the "min platform" example still works. 1081 test-min-platform-example: 1082 name: Test the min-platform example 1083 needs: determine 1084 if: needs.determine.outputs.run-full 1085 runs-on: ubuntu-latest 1086 steps: 1087 - uses: actions/checkout@v6 1088 with: 1089 submodules: true 1090 - uses: ./.github/actions/install-rust 1091 - run: cargo install [email protected] --locked 1092 - run: rustup target add x86_64-unknown-none 1093 - run: rustup target add wasm32-wasip2 1094 - run: ./build.sh x86_64-unknown-none 1095 working-directory: ./examples/min-platform 1096 1097 # Afterwards make sure the generated header file is up to date by ensuring 1098 # that the regeneration process didn't change anything in-tree. 1099 - run: git diff --exit-code 1100 1101 # Test some other feature combinations 1102 - run: ./build.sh x86_64-unknown-none 1103 working-directory: ./examples/min-platform 1104 env: 1105 WASMTIME_SIGNALS_BASED_TRAPS: 1 1106 1107 - run: ./build.sh x86_64-unknown-none 1108 working-directory: ./examples/min-platform 1109 env: 1110 WASMTIME_SIGNALS_BASED_TRAPS: 1 1111 MIN_PLATFORM_TEST_DISABLE_WASI: 1 1112 1113 # Add the `wasmtime-platform.h` file as a release artifact 1114 - uses: actions/upload-artifact@v6 1115 with: 1116 name: wasmtime-platform-header 1117 path: examples/min-platform/embedding/wasmtime-platform.h 1118 1119 bench: 1120 needs: determine 1121 if: needs.determine.outputs.run-full 1122 name: Run benchmarks 1123 runs-on: ubuntu-latest 1124 steps: 1125 - uses: actions/checkout@v6 1126 with: 1127 submodules: true 1128 - uses: ./.github/actions/install-rust 1129 - run: rustup target add wasm32-wasip2 wasm32-wasip1 1130 - run: cargo test --benches --release 1131 1132 # Verify that cranelift's code generation is deterministic 1133 meta_deterministic_check: 1134 needs: determine 1135 if: needs.determine.outputs.run-full 1136 name: Meta deterministic check 1137 runs-on: ubuntu-latest 1138 steps: 1139 - uses: actions/checkout@v6 1140 with: 1141 submodules: true 1142 - uses: ./.github/actions/install-rust 1143 - run: cd cranelift/codegen && cargo build --features all-arch 1144 - run: ci/ensure_deterministic_build.sh 1145 1146 verify-publish: 1147 needs: determine 1148 if: github.repository == 'bytecodealliance/wasmtime' && needs.determine.outputs.run-full 1149 runs-on: ubuntu-latest 1150 steps: 1151 - uses: actions/checkout@v6 1152 with: 1153 submodules: true 1154 - uses: ./.github/actions/install-rust 1155 - run: | 1156 cd ${{ runner.tool_cache }} 1157 curl --retry 5 --retry-all-errors -L -o sccache.tar.gz \ 1158 https://github.com/mozilla/sccache/releases/download/0.2.13/sccache-0.2.13-x86_64-unknown-linux-musl.tar.gz 1159 tar xzf sccache.tar.gz 1160 rm sccache.tar.gz 1161 echo "`pwd`/sccache-0.2.13-x86_64-unknown-linux-musl" >> $GITHUB_PATH 1162 echo RUSTC_WRAPPER=sccache >> $GITHUB_ENV 1163 - run: rustc scripts/publish.rs 1164 # Make sure the tree is publish-able as-is 1165 - run: ./publish verify 1166 # Make sure we can bump version numbers for the next release 1167 - run: ./publish bump 1168 1169 # Run a subset of tests under MIRI on CI to help check the `unsafe` code in 1170 # Wasmtime to make sure it's at least not obviously incorrect for basic usage. 1171 # Note that this doesn't run the full test suite since MIRI can't actually run 1172 # WebAssembly itself at this time (aka it doesn't support a JIT). There are a 1173 # number of annotations throughout the code which gates some tests on MIRI not 1174 # being run. 1175 # 1176 # Note that `cargo nextest` is used here additionally to get parallel test 1177 # execution by default to help cut down on the time in CI. 1178 miri: 1179 strategy: 1180 matrix: 1181 include: 1182 - crate: "wasmtime" 1183 - crate: "wasmtime-cli" 1184 - crate: "wasmtime-environ --all-features" 1185 - crate: "pulley-interpreter --all-features" 1186 - crate: "wasmtime-internal-core" 1187 - crate: "wasmtime-internal-core --all-features" 1188 - script: ./ci/miri-provenance-test.sh 1189 - script: ./ci/miri-wast.sh ./tests/spec_testsuite/table.wast 1190 needs: determine 1191 if: needs.determine.outputs.test-miri && github.repository == 'bytecodealliance/wasmtime' 1192 name: Miri 1193 runs-on: ubuntu-latest 1194 env: 1195 CARGO_NEXTEST_VERSION: 0.9.88 1196 MIRIFLAGS: -Zmiri-permissive-provenance 1197 steps: 1198 - uses: actions/checkout@v6 1199 with: 1200 submodules: true 1201 - uses: ./.github/actions/install-rust 1202 with: 1203 toolchain: wasmtime-ci-pinned-nightly 1204 - run: rustup component add rust-src miri 1205 - uses: actions/cache@v5 1206 with: 1207 path: ${{ runner.tool_cache }}/cargo-nextest 1208 key: cargo-nextest-bin-${{ env.CARGO_NEXTEST_VERSION }} 1209 - run: echo "${{ runner.tool_cache }}/cargo-nextest/bin" >> $GITHUB_PATH 1210 - run: cargo install --root ${{ runner.tool_cache }}/cargo-nextest --version ${{ env.CARGO_NEXTEST_VERSION }} cargo-nextest --locked 1211 - run: | 1212 cargo miri nextest run -j4 --no-fail-fast -p ${{ matrix.crate }} 1213 if: ${{ matrix.crate }} 1214 - run: ${{ matrix.script }} 1215 if: ${{ matrix.script }} 1216 1217 # Perform release builds of `wasmtime` and `libwasmtime.so`. Builds a variety 1218 # of platforms and architectures and then uploads the release artifacts to 1219 # this workflow run's list of artifacts. 1220 # 1221 # Note that the full matrix is computed by `ci/build-build-matrix.js`. 1222 build: 1223 needs: determine 1224 if: needs.determine.outputs.run-full 1225 name: Release build for ${{ matrix.build }} 1226 runs-on: ${{ matrix.os }} 1227 strategy: 1228 fail-fast: ${{ github.event_name != 'pull_request' }} 1229 matrix: ${{ fromJson(needs.determine.outputs.build-matrix) }} 1230 env: ${{ matrix.env || fromJSON('{}') }} 1231 steps: 1232 - uses: actions/checkout@v6 1233 with: 1234 submodules: true 1235 1236 - uses: ./.github/actions/install-ninja 1237 - uses: ./.github/actions/install-rust 1238 with: 1239 toolchain: ${{ matrix.rust }} 1240 - run: | 1241 rustup component add rust-src 1242 rustup target add ${{ matrix.target }} 1243 1244 # On one builder produce the source tarball since there's no need to produce 1245 # it everywhere 1246 - run: ./ci/build-src-tarball.sh 1247 if: matrix.build == 'x86_64-linux' 1248 1249 - uses: ./.github/actions/android-ndk 1250 if: contains(matrix.target, 'android') 1251 with: 1252 target: ${{ matrix.target }} 1253 1254 - run: ./ci/build-release-artifacts.sh "${{ matrix.build }}" "${{ matrix.target }}" 1255 1256 # Assemble release artifacts appropriate for this platform, then upload them 1257 # unconditionally to this workflow's files so we have a copy of them. 1258 - run: ./ci/build-tarballs.sh "${{ matrix.build }}" "${{ matrix.target }}" 1259 1260 - uses: actions/upload-artifact@v6 1261 with: 1262 name: bins-${{ matrix.build }} 1263 path: dist 1264 1265 # This is a "join node" which depends on all prior workflows. The merge queue, 1266 # for example, gates on this to ensure that everything has executed 1267 # successfully. 1268 # 1269 # Note that this is required currently for odd reasons with github. Notably 1270 # the set of checks to enter the merge queue and leave the merge queue must 1271 # be the same which means that the "build" step for example shows as skipped 1272 # for PRs but expands to many different steps for merge-queue-based PRs. That 1273 # means that for that step there's no single name to gate on, so it's required 1274 # to have a "join" node here which joins everything. 1275 # 1276 # Note that this currently always runs to always report a status, even on 1277 # cancellation and even if dependency steps fail. Each dependency tries to 1278 # cancel the whole run if it fails, so if a test matrix entry fails, for 1279 # example, it cancels the build matrix entries too. This step then tries to 1280 # fail on cancellation to ensure that the dependency failures are propagated 1281 # correctly. 1282 ci-status: 1283 name: Record the result of testing and building steps 1284 runs-on: ubuntu-latest 1285 needs: 1286 - test 1287 - test_capi 1288 - test_debug_dwarf 1289 - test_fuzzing 1290 - test_wasi_nn 1291 - test_nightly 1292 - build 1293 - rustfmt 1294 - clangformat 1295 - cargo_deny 1296 - cargo_vet 1297 - doc 1298 - micro_checks 1299 - special_tests 1300 - test_wasi_tls 1301 - clippy 1302 - monolith_checks 1303 - platform_checks 1304 - bench 1305 - meta_deterministic_check 1306 - verify-publish 1307 - determine 1308 - miri 1309 - build-preview1-component-adapter 1310 - build-preview1-component-adapter-provider 1311 - test-min-platform-example 1312 - check_js 1313 if: always() 1314 steps: 1315 # Calculate the exit status of the whole CI workflow. 1316 # If all dependent jobs were successful, this exits with 0 (and the 1317 # outcome job continues successfully). If a some dependent job has 1318 # failed, this exits with 1. 1319 - name: calculate the correct exit status 1320 run: jq --exit-status 'all(.result == "success" or .result == "skipped")' <<< '${{ toJson(needs) }}' 1321 1322 # The purpose of this jobs is to watch for changes on the `release-*` 1323 # branches of this repository and look for the term 1324 # "automatically-tag-and-release-this-commit" within merged PRs/commits. Once 1325 # that term is found the current version of `Cargo.toml`, the `wasmtime-cli` 1326 # Cargo.toml, is created as a tag and the tag is pushed to the repo. 1327 # Currently the tag is created through the GitHub API with an access token to 1328 # ensure that CI is further triggered for the tag itself which performs the 1329 # full release process. 1330 # 1331 # Note that this depends on the `ci-status` step above which is the "join" 1332 # point of this workflow for when everything succeeds. the purpose of that is 1333 # so that the tag is only created after the aftifacts have been uploaded for 1334 # this workflow as the `publish-artifacts.yml` workflow will download these 1335 # artifacts and then publish them to the tag. 1336 push-tag: 1337 runs-on: ubuntu-latest 1338 needs: ci-status 1339 if: | 1340 always() 1341 && needs.ci-status.result == 'success' 1342 && github.event_name == 'push' 1343 && startsWith(github.ref, 'refs/heads/release-') 1344 && github.repository == 'bytecodealliance/wasmtime' 1345 steps: 1346 - uses: actions/checkout@v6 1347 with: 1348 submodules: true 1349 fetch-depth: 0 1350 - name: Test if tag is needed 1351 run: | 1352 git log ${{ github.event.before }}...${{ github.event.after }} | tee main.log 1353 version=$(grep '^version =' Cargo.toml | head -n 1 | sed 's/.*"\(.*\)"/\1/') 1354 echo "version: $version" 1355 echo "version=$version" >> $GITHUB_OUTPUT 1356 echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT 1357 if grep -q "automatically-tag-and-release-this-commit" main.log; then 1358 echo push-tag 1359 echo "push_tag=yes" >> $GITHUB_OUTPUT 1360 else 1361 echo no-push-tag 1362 echo "push_tag=no" >> $GITHUB_OUTPUT 1363 fi 1364 id: tag 1365 - name: Push the tag 1366 run: | 1367 git_refs_url=$(jq .repository.git_refs_url $GITHUB_EVENT_PATH | tr -d '"' | sed 's/{\/sha}//g') 1368 curl -iX POST $git_refs_url \ 1369 -H "Authorization: token ${{ secrets.PERSONAL_ACCESS_TOKEN }}" \ 1370 -d @- << EOF 1371 { 1372 "ref": "refs/tags/v${{ steps.tag.outputs.version }}", 1373 "sha": "${{ steps.tag.outputs.sha }}" 1374 } 1375 EOF 1376 if: steps.tag.outputs.push_tag == 'yes' 1377 1378 # File an issue on the repo if this run failed and was triggered via 1379 # `workflow_dispatch`, which mostly means that 1380 # `.github/workflows/trigger-release-branch-ci.yml` will file issues on 1381 # failure so we get to see a notification when a build fails for a historical 1382 # release branch. 1383 file-issue-on-error: 1384 name: File an issue if this build failed and was cron-triggered 1385 runs-on: ubuntu-latest 1386 needs: ci-status 1387 if: | 1388 always() 1389 && needs.ci-status.result != 'success' 1390 && github.event_name == 'workflow_dispatch' 1391 permissions: 1392 issues: write 1393 steps: 1394 - uses: actions/github-script@v8 1395 with: 1396 script: | 1397 github.rest.issues.create({ 1398 owner: context.repo.owner, 1399 repo: context.repo.repo, 1400 title: `Failed CI build for ${context.ref}`, 1401 body: `See https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`, 1402 }) 1403