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 pulley-interpreter --features encode,decode,disas,interp && 554 cargo check -p wasmtime-wasi-io --no-default-features 555 # Use `cross` for illumos to have a C compiler/linker available. 556 - target: x86_64-unknown-illumos 557 os: ubuntu-latest 558 cross: true 559 test: cross build 560 - target: wasm32-wasip1 561 os: ubuntu-latest 562 test: cargo build --no-default-features --features compile,cranelift,all-arch 563 - target: aarch64-apple-ios 564 os: macos-latest 565 test: cargo build 566 env: 567 IPHONEOS_DEPLOYMENT_TARGET: 13.0 568 # Test that when Cranelift has no support for an architecture, even a 569 # 64-bit one, that Wasmtime still compiles. Note that this is also 570 # intended to test various fallbacks in the codebase where we have no 571 # support at all for a particular architecture. In theory if someone 572 # adds powerpc64 support to Wasmtime this should get switched to some 573 # other architecture. 574 - target: powerpc64le-unknown-linux-gnu 575 os: ubuntu-latest 576 test: cargo build 577 apt_packages: gcc-powerpc64le-linux-gnu 578 env: 579 CARGO_TARGET_POWERPC64LE_UNKNOWN_LINUX_GNU_LINKER: powerpc64le-linux-gnu-gcc 580 # A no_std target without 64-bit atomics 581 - target: riscv32imac-unknown-none-elf 582 os: ubuntu-latest 583 test: cargo check -p wasmtime --no-default-features --features runtime,gc,component-model,async 584 env: ${{ matrix.env || fromJSON('{}') }} 585 steps: 586 - uses: actions/checkout@v4 587 with: 588 submodules: true 589 - uses: ./.github/actions/install-rust 590 - run: rustup target add ${{ matrix.target }} 591 - name: Install cross 592 run: | 593 curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash 594 cargo binstall --no-confirm cross 595 if: ${{ matrix.cross }} 596 - name: Install apt packages 597 if: ${{ matrix.apt_packages }} 598 run: sudo apt-get update && sudo apt-get install -y ${{ matrix.apt_packages }} 599 - run: ${{ matrix.test }} 600 env: 601 CARGO_BUILD_TARGET: ${{ matrix.target }} 602 603 # Run tests that require a nightly compiler, such as building fuzz targets. 604 test_nightly: 605 needs: determine 606 if: needs.determine.outputs.test-nightly 607 name: Nightly tests 608 runs-on: ubuntu-latest 609 steps: 610 - uses: actions/checkout@v4 611 with: 612 submodules: true 613 # Note that nightly is pinned here to insulate us from breakage that might 614 # happen upstream. This is periodically updated through a PR. 615 - uses: ./.github/actions/install-rust 616 with: 617 toolchain: wasmtime-ci-pinned-nightly 618 619 # Check that `pulley-interpreter` works with tail calls enabled. 620 - run: cargo test -p pulley-interpreter --all-features 621 env: 622 RUSTFLAGS: "--cfg pulley_tail_calls" 623 - run: cargo check -p pulley-interpreter --all-features 624 env: 625 RUSTFLAGS: "--cfg pulley_disable_interp_simd" 626 - run: cargo test -p pulley-interpreter --all-features --release 627 env: 628 RUSTFLAGS: "--cfg pulley_assume_llvm_makes_tail_calls" 629 630 # Ensure that fuzzers still build. 631 # 632 # Install the OCaml packages necessary for fuzz targets that use the 633 # `wasm-spec-interpreter`. 634 - run: cargo install cargo-fuzz --vers "^0.11" --locked 635 - run: sudo apt-get update && sudo apt install -y ocaml-nox ocamlbuild ocaml-findlib libzarith-ocaml-dev 636 - run: cargo fetch 637 working-directory: ./fuzz 638 - run: cargo fuzz check --dev 639 - run: cargo fuzz check --dev --fuzz-dir ./cranelift/isle/fuzz 640 - run: cargo fuzz check --dev --fuzz-dir ./crates/environ/fuzz --features component-model 641 - run: cargo fuzz check --dev --fuzz-dir ./cranelift/assembler-x64/fuzz 642 - run: cargo fuzz check --dev --fuzz-dir ./crates/wizer/fuzz 643 644 # Perform all tests of the c-api 645 test_capi: 646 needs: determine 647 name: Test C-API ${{ matrix.name }} 648 runs-on: ${{ matrix.os }} 649 if: needs.determine.outputs.test-capi 650 651 strategy: 652 fail-fast: ${{ github.event_name != 'pull_request' }} 653 matrix: 654 include: 655 # This configuration will build C/C++ tests, examples, and Rust tests. 656 # Everything is linked against the C shared library to speed up 657 # linking, and this is intended to be the "main set of tests". 658 # 659 # Run this on windows/mac/linux 660 - os: ubuntu-24.04 661 # Only run the "plugins" example on Linux 662 flags: -DBUILD_SHARED_LIBS=ON -DBUILD_TESTS=ON -DBUILD_RUST_EXAMPLES=ON -DBUILD_RUST_PLUGINS_EXAMPLE=ON 663 name: Linux 664 - os: macos-15 665 flags: -DBUILD_SHARED_LIBS=ON -DBUILD_TESTS=ON -DBUILD_RUST_EXAMPLES=ON 666 name: macOS 667 - os: windows-2025 668 # Note that dynamic linking is disabled here because I don't want to 669 # have to deal with figuring out how to get `wasmtime.dll` onto 670 # `PATH` for various tests. 671 flags: -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTS=ON -DBUILD_RUST_EXAMPLES=ON 672 name: Windows 673 674 # This tests using static linking for examples but skips building the 675 # Rust examples as well as C/C++ tests. Intended to be a faster build 676 # which mostly just tests static linking. 677 - os: ubuntu-24.04 678 flags: -DBUILD_SHARED_LIBS=OFF -DBUILD_RUST_EXAMPLES=OFF 679 name: Linux (static linking) 680 681 # Run tests with ASAN for leak checking primarily. 682 - os: ubuntu-24.04 683 flags: -DCMAKE_C_FLAGS=-fsanitize=address -DCMAKE_CXX_FLAGS=-fsanitize=address -DBUILD_SHARED_LIBS=ON -DBUILD_TESTS=ON 684 name: Linux (ASAN) 685 steps: 686 - uses: actions/checkout@v4 687 with: 688 submodules: true 689 - uses: ./.github/actions/install-rust 690 - run: rustup target add wasm32-wasip2 691 692 - uses: ./.github/actions/install-plugins-prerequisites 693 if: runner.os == 'Linux' 694 695 - uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 696 # An ode to MinGW: man you're a pain to work around sometimes 697 - run: rm /usr/bin/link 698 if: runner.os == 'Windows' 699 700 - run: cmake -G Ninja -Sexamples -DCMAKE_BUILD_TYPE=Debug -Bexamples/build ${{ matrix.flags }} 701 - run: ninja -C examples/build 702 - run: ninja -C examples/build test 703 env: 704 CTEST_OUTPUT_ON_FAILURE: 1 705 CTEST_PARALLEL_LEVEL: 4 706 707 # Perform all tests (debug mode) for `wasmtime`. 708 # 709 # Note that the full matrix for what may run here is defined within 710 # `./ci/build-test-matrix.js` and the execution of the `determine` step will 711 # calculate whether the tests are actually run as part of PRs and such. 712 test: 713 needs: determine 714 name: ${{ matrix.name }} 715 runs-on: ${{ matrix.os }} 716 env: 717 QEMU_BUILD_VERSION: 10.0.3 718 SDE_BUILD_VERSION: 9.58.0-2025-06-16 719 strategy: 720 fail-fast: ${{ github.event_name != 'pull_request' }} 721 matrix: ${{ fromJson(needs.determine.outputs.test-matrix) }} 722 steps: 723 - uses: actions/checkout@v4 724 with: 725 submodules: true 726 - uses: ./.github/actions/install-rust 727 with: 728 toolchain: ${{ matrix.rust }} 729 730 # Install targets in order to build various tests throughout the repo 731 - run: rustup target add wasm32-wasip1 wasm32-unknown-unknown ${{ matrix.target }} 732 - run: echo CARGO_BUILD_TARGET=${{ matrix.target }} >> $GITHUB_ENV 733 if: matrix.target != '' 734 735 # Fix an ICE for now in gcc when compiling zstd with debuginfo (??) 736 - run: echo CFLAGS=-g0 >> $GITHUB_ENV 737 if: matrix.target == 'x86_64-pc-windows-gnu' 738 739 # Update binutils if MinGW due to https://github.com/rust-lang/rust/issues/112368 740 - run: C:/msys64/usr/bin/pacman.exe -S --needed mingw-w64-x86_64-gcc --noconfirm 741 if: matrix.target == 'x86_64-pc-windows-gnu' 742 - shell: pwsh 743 run: echo "C:\msys64\mingw64\bin" >> $Env:GITHUB_PATH 744 if: matrix.target == 'x86_64-pc-windows-gnu' 745 746 - run: cargo fetch --locked 747 748 - name: Install cross-compilation tools 749 run: | 750 set -ex 751 752 sudo apt-get update 753 sudo apt-get install -y ${{ matrix.gcc_package }} 754 755 # Configure Cargo for cross compilation and tell it how it can run 756 # cross executables 757 upcase=$(echo ${{ matrix.target }} | awk '{ print toupper($0) }' | sed 's/-/_/g') 758 echo CARGO_TARGET_${upcase}_LINKER=${{ matrix.gcc }} >> $GITHUB_ENV 759 if: matrix.gcc != '' 760 761 - uses: actions/cache@v4 762 with: 763 path: ${{ runner.tool_cache }}/qemu 764 key: qemu-${{ matrix.target }}-${{ env.QEMU_BUILD_VERSION }}-patchcpuinfo 765 if: matrix.qemu != '' 766 767 - uses: actions/cache@v4 768 with: 769 path: ${{ runner.tool_cache }}/sde 770 key: sde-${{ env.SDE_BUILD_VERSION }} 771 if: matrix.sde != '' 772 773 - name: Install qemu 774 run: | 775 set -ex 776 777 upcase=$(echo ${{ matrix.target }} | awk '{ print toupper($0) }' | sed 's/-/_/g') 778 echo CARGO_TARGET_${upcase}_RUNNER=${{ runner.tool_cache }}/qemu/bin/${{ matrix.qemu }} >> $GITHUB_ENV 779 780 # QEMU emulation is not always the speediest, so total testing time 781 # goes down if we build the libs in release mode when running tests. 782 echo CARGO_PROFILE_DEV_OPT_LEVEL=2 >> $GITHUB_ENV 783 784 # See comments in the source for why we enable this during QEMU 785 # emulation. 786 echo WASMTIME_TEST_NO_HOG_MEMORY=1 >> $GITHUB_ENV 787 788 # See if qemu is already in the cache 789 if [ -f ${{ runner.tool_cache }}/qemu/built ]; then 790 exit 0 791 fi 792 793 # Install build dependencies of QEMU itself. 794 sudo apt-get install -y libglib2.0-dev ninja-build 795 796 # Download and build qemu from source since the most recent release is 797 # way faster at arm emulation than the current version github actions' 798 # ubuntu image uses. Disable as much as we can to get it to build 799 # quickly. 800 curl --retry 5 --retry-all-errors -o qemu.tar.xz https://download.qemu.org/qemu-$QEMU_BUILD_VERSION.tar.xz 801 tar xJf qemu.tar.xz 802 rm qemu.tar.xz 803 cd qemu-$QEMU_BUILD_VERSION 804 ./configure --target-list=${{ matrix.qemu_target }} --prefix=${{ runner.tool_cache}}/qemu --disable-tools --disable-slirp --disable-fdt --disable-capstone --disable-docs 805 ninja -C build install 806 touch ${{ runner.tool_cache }}/qemu/built 807 if: matrix.qemu != '' 808 809 - name: Install Intel SDE 810 run: | 811 set -ex 812 813 # Set up SDE as runner for x86_64 targets 814 echo "CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER=${{ runner.tool_cache }}/sde/sde64 -future --" >> $GITHUB_ENV 815 816 # SDE emulation is very slow, so use release mode for better performance 817 echo CARGO_PROFILE_DEV_OPT_LEVEL=2 >> $GITHUB_ENV 818 819 # Enable environment variable to indicate SDE is being used 820 echo WASMTIME_TEST_SDE=1 >> $GITHUB_ENV 821 822 # Generic variable for skipping tests that are problematic under SDE (performance, compatibility, etc.) 823 echo WASMTIME_TEST_NO_SDE=1 >> $GITHUB_ENV 824 825 # Similar to QEMU, reduce memory usage during SDE emulation 826 echo WASMTIME_TEST_NO_HOG_MEMORY=1 >> $GITHUB_ENV 827 828 # See if SDE is already in the cache 829 if [ -f ${{ runner.tool_cache }}/sde/sde64 ]; then 830 exit 0 831 fi 832 833 curl --retry 5 --retry-all-errors -o sde.tar.xz \ 834 https://downloadmirror.intel.com/859732/sde-external-${{ env.SDE_BUILD_VERSION }}-lin.tar.xz 835 836 mkdir -p ${{ runner.tool_cache }}/sde 837 tar xJf sde.tar.xz --strip-components=1 -C ${{ runner.tool_cache }}/sde 838 rm sde.tar.xz 839 840 chmod +x ${{ runner.tool_cache }}/sde/sde64 841 if: matrix.sde != '' 842 843 - name: Configure ASAN 844 run: | 845 echo CARGO_PROFILE_DEV_OPT_LEVEL=2 >> $GITHUB_ENV 846 echo CARGO_PROFILE_TEST_OPT_LEVEL=2 >> $GITHUB_ENV 847 echo RUSTFLAGS=-Zsanitizer=address >> $GITHUB_ENV 848 echo RUSTDOCFLAGS="-Zsanitizer=address -Copt-level=2 -Ccodegen-units=16" >> $GITHUB_ENV 849 if: ${{ contains(matrix.name, 'ASAN') }} 850 851 # Record some CPU details; this is helpful information if tests fail due 852 # to CPU-specific features. 853 - name: CPU information 854 run: lscpu 855 if: runner.os == 'Linux' 856 - name: CPU information 857 run: sysctl hw 858 if: runner.os == 'macOS' 859 - name: CPU information 860 run: Get-WmiObject Win32_Processor 861 shell: pwsh 862 if: runner.os == 'Windows' 863 864 # Since MPK (PKU) is not present on some GitHub runners, we check if it is 865 # available before force-enabling it. This occasional testing is better than 866 # none at all; ideally we would test in a system-mode QEMU VM. 867 - name: Force-run with MPK enabled, if available 868 if: ${{ contains(matrix.name, 'MPK') }} 869 run: | 870 if cargo run --example mpk-available; then 871 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." 872 echo WASMTIME_TEST_FORCE_MPK=1 >> $GITHUB_ENV 873 else 874 echo "::warning::This CI run will not test MPK; it has been detected as not available on this machine (\`cargo run --example mpk-available\`)." 875 fi 876 877 # Install VTune, see `cli_tests::profile_with_vtune`. 878 - name: Install VTune 879 if: matrix.filter == 'linux-x64' && contains(matrix.bucket, 'wasmtime-cli') 880 uses: abrown/install-vtune-action@v3 881 882 # Build and test all features. 883 # 884 # Note that this uses a different shell, notably not `bash` on Windows. In 885 # the past `bash` would add more items to `PATH` on Windows which would 886 # interfere and cause the `gcc.exe` executable to fail and exit with 1 and 887 # no output. It's believed that `bash` adds things like `/usr/bin` to PATH 888 # which is the wrong DLL or something like that. 889 - run: python3 ./ci/run-tests.py --locked ${{ matrix.bucket }} 890 if: runner.os == 'Windows' 891 shell: pwsh 892 - run: python3 ./ci/run-tests.py --locked ${{ matrix.bucket }} 893 if: runner.os != 'Windows' 894 895 # Test `wasmtime-wasi-nn` in its own job, as not all of its backends are 896 # compatible with all targets, and each must be tested separately anyways. 897 test_wasi_nn: 898 strategy: 899 matrix: 900 feature: ["openvino", "onnx-download"] 901 os: ["ubuntu-24.04", "windows-2025"] 902 include: 903 - os: windows-2025 904 feature: winml 905 name: Test wasi-nn (${{ matrix.feature }}, ${{ matrix.os }}) 906 runs-on: ${{ matrix.os }} 907 needs: determine 908 if: needs.determine.outputs.run-full 909 steps: 910 - uses: actions/checkout@v4 911 with: 912 submodules: true 913 - uses: ./.github/actions/install-rust 914 915 # Install OpenVINO 916 - uses: abrown/install-openvino-action@v10 917 if: runner.arch == 'X64' 918 919 # Install WinML for testing wasi-nn WinML backend. WinML is only available 920 # on Windows clients and Windows Server with desktop experience enabled. 921 # GitHub Actions Window Server image doesn't have desktop experience 922 # enabled, so we download the standalone library from ONNX Runtime project. 923 - uses: nuget/setup-nuget@v2 924 if: (runner.os == 'Windows') && (matrix.feature == 'winml') 925 - run: nuget install Microsoft.AI.MachineLearning 926 if: (runner.os == 'Windows') && (matrix.feature == 'winml') 927 928 # Install Rust targets. 929 - run: rustup target add wasm32-wasip1 930 931 # Run the tests! 932 - run: cargo test -p wasmtime-wasi-nn --features ${{ matrix.feature }} 933 934 # Test `wasmtime-wasi-tls-nativetls` in its own job. This is because it 935 # depends on OpenSSL, which is not easily available on all platforms. 936 test_wasi_tls_nativetls: 937 name: Test wasi-tls using native-tls provider 938 needs: determine 939 if: needs.determine.outputs.run-full 940 runs-on: ${{ matrix.os }} 941 strategy: 942 matrix: 943 os: [ubuntu-latest, windows-latest, macos-latest] 944 steps: 945 - uses: actions/checkout@v4 946 with: 947 submodules: true 948 - uses: ./.github/actions/install-rust 949 - run: cargo test -p wasmtime-wasi-tls-nativetls 950 951 # Test the `wasmtime-fuzzing` crate. Split out from the main tests because 952 # `--all-features` brings in OCaml, which is a pain to get setup for all 953 # targets. 954 test_fuzzing: 955 needs: determine 956 if: needs.determine.outputs.run-full 957 name: Test wasmtime-fuzzing 958 runs-on: 'ubuntu-latest' 959 steps: 960 - uses: actions/checkout@v4 961 with: 962 submodules: true 963 - uses: ./.github/actions/install-rust 964 965 # Run the tests 966 - run: | 967 cargo test -p wasmtime-fuzzing -p wasm-spec-interpreter 968 969 # Test debug (DWARF) related functionality. 970 test_debug_dwarf: 971 needs: determine 972 if: needs.determine.outputs.run-dwarf 973 name: Test DWARF debugging 974 runs-on: ubuntu-24.04 975 steps: 976 - uses: actions/checkout@v4 977 with: 978 submodules: true 979 - uses: ./.github/actions/install-rust 980 - run: | 981 rustup target add wasm32-wasip1 wasm32-unknown-unknown 982 cd /tmp 983 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 984 tar -xzf wasi-sdk-28.0-x86_64-linux.tar.gz 985 mv wasi-sdk-28.0-x86_64-linux wasi-sdk 986 - run: | 987 sudo apt-get update && sudo apt-get install -y gdb lldb-18 llvm 988 # workaround for https://bugs.launchpad.net/ubuntu/+source/llvm-defaults/+bug/1972855 989 sudo mkdir -p /usr/lib/local/lib/python3.10/dist-packages/lldb 990 sudo ln -s /usr/lib/llvm-15/lib/python3.10/dist-packages/lldb/* /usr/lib/python3/dist-packages/lldb/ 991 # Only testing release since it is more likely to expose issues with our low-level symbol handling. 992 cargo test --release --test all -- --ignored --test-threads 1 native_debug:: 993 env: 994 LLDB: lldb-18 995 WASI_SDK_PATH: /tmp/wasi-sdk 996 997 build-preview1-component-adapter: 998 name: Build wasi-preview1-component-adapter 999 needs: determine 1000 if: needs.determine.outputs.preview1-adapter 1001 runs-on: ubuntu-latest 1002 permissions: 1003 deployments: write 1004 contents: write 1005 steps: 1006 - uses: actions/checkout@v4 1007 with: 1008 submodules: true 1009 - uses: ./.github/actions/install-rust 1010 - run: rustup target add wasm32-wasip1 wasm32-unknown-unknown 1011 1012 - name: Install wasm-tools 1013 run: | 1014 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 1015 tar xfz wasm-tools.tar.gz 1016 rm wasm-tools.tar.gz 1017 echo `pwd`/wasm-tools-1.0.27-x86_64-linux >> $GITHUB_PATH 1018 1019 - run: ./ci/build-wasi-preview1-component-adapter.sh 1020 env: 1021 VERSION: ${{ github.sha }} 1022 1023 - uses: actions/upload-artifact@v4 1024 with: 1025 name: bins-wasi-preview1-component-adapter 1026 path: target/wasm32-unknown-unknown/release/wasi_snapshot_preview1.*.wasm 1027 1028 build-preview1-component-adapter-provider: 1029 name: Build wasi-preview1-component-adapter-provider 1030 needs: build-preview1-component-adapter 1031 runs-on: ubuntu-latest 1032 steps: 1033 - uses: actions/checkout@v4 1034 with: 1035 submodules: true 1036 - uses: ./.github/actions/install-rust 1037 - uses: ./.github/actions/build-adapter-provider 1038 with: 1039 run-id: ${{ github.run_id }} 1040 1041 # Verify the "min platform" example still works. 1042 test-min-platform-example: 1043 name: Test the min-platform example 1044 needs: determine 1045 if: needs.determine.outputs.run-full 1046 runs-on: ubuntu-latest 1047 steps: 1048 - uses: actions/checkout@v4 1049 with: 1050 submodules: true 1051 - uses: ./.github/actions/install-rust 1052 - run: cargo install [email protected] --locked 1053 - run: rustup target add x86_64-unknown-none 1054 - run: rustup target add wasm32-wasip2 1055 - run: ./build.sh x86_64-unknown-none 1056 working-directory: ./examples/min-platform 1057 1058 # Afterwards make sure the generated header file is up to date by ensuring 1059 # that the regeneration process didn't change anything in-tree. 1060 - run: git diff --exit-code 1061 1062 # Test some other feature combinations 1063 - run: ./build.sh x86_64-unknown-none 1064 working-directory: ./examples/min-platform 1065 env: 1066 WASMTIME_SIGNALS_BASED_TRAPS: 1 1067 1068 - run: ./build.sh x86_64-unknown-none 1069 working-directory: ./examples/min-platform 1070 env: 1071 WASMTIME_SIGNALS_BASED_TRAPS: 1 1072 MIN_PLATFORM_TEST_DISABLE_WASI: 1 1073 1074 # Add the `wasmtime-platform.h` file as a release artifact 1075 - uses: actions/upload-artifact@v4 1076 with: 1077 name: wasmtime-platform-header 1078 path: examples/min-platform/embedding/wasmtime-platform.h 1079 1080 bench: 1081 needs: determine 1082 if: needs.determine.outputs.run-full 1083 name: Run benchmarks 1084 runs-on: ubuntu-latest 1085 steps: 1086 - uses: actions/checkout@v4 1087 with: 1088 submodules: true 1089 - uses: ./.github/actions/install-rust 1090 - run: rustup target add wasm32-wasip1 1091 - run: cargo test --benches --release 1092 1093 # Verify that cranelift's code generation is deterministic 1094 meta_deterministic_check: 1095 needs: determine 1096 if: needs.determine.outputs.run-full 1097 name: Meta deterministic check 1098 runs-on: ubuntu-latest 1099 steps: 1100 - uses: actions/checkout@v4 1101 with: 1102 submodules: true 1103 - uses: ./.github/actions/install-rust 1104 - run: cd cranelift/codegen && cargo build --features all-arch 1105 - run: ci/ensure_deterministic_build.sh 1106 1107 verify-publish: 1108 needs: determine 1109 if: github.repository == 'bytecodealliance/wasmtime' && needs.determine.outputs.run-full 1110 runs-on: ubuntu-latest 1111 steps: 1112 - uses: actions/checkout@v4 1113 with: 1114 submodules: true 1115 - uses: ./.github/actions/install-rust 1116 - run: | 1117 cd ${{ runner.tool_cache }} 1118 curl --retry 5 --retry-all-errors -L -o sccache.tar.gz \ 1119 https://github.com/mozilla/sccache/releases/download/0.2.13/sccache-0.2.13-x86_64-unknown-linux-musl.tar.gz 1120 tar xzf sccache.tar.gz 1121 rm sccache.tar.gz 1122 echo "`pwd`/sccache-0.2.13-x86_64-unknown-linux-musl" >> $GITHUB_PATH 1123 echo RUSTC_WRAPPER=sccache >> $GITHUB_ENV 1124 - run: rustc scripts/publish.rs 1125 # Make sure the tree is publish-able as-is 1126 - run: ./publish verify 1127 # Make sure we can bump version numbers for the next release 1128 - run: ./publish bump 1129 1130 # Run a subset of tests under MIRI on CI to help check the `unsafe` code in 1131 # Wasmtime to make sure it's at least not obviously incorrect for basic usage. 1132 # Note that this doesn't run the full test suite since MIRI can't actually run 1133 # WebAssembly itself at this time (aka it doesn't support a JIT). There are a 1134 # number of annotations throughout the code which gates some tests on MIRI not 1135 # being run. 1136 # 1137 # Note that `cargo nextest` is used here additionally to get parallel test 1138 # execution by default to help cut down on the time in CI. 1139 miri: 1140 strategy: 1141 matrix: 1142 include: 1143 - crate: "wasmtime" 1144 - crate: "wasmtime-cli" 1145 - crate: "wasmtime-environ --all-features" 1146 - crate: "pulley-interpreter --all-features" 1147 - crate: "wasmtime-internal-error" 1148 - crate: "wasmtime-internal-error --all-features" 1149 - script: ./ci/miri-provenance-test.sh 1150 - script: ./ci/miri-wast.sh ./tests/spec_testsuite/table.wast 1151 needs: determine 1152 if: needs.determine.outputs.test-miri && github.repository == 'bytecodealliance/wasmtime' 1153 name: Miri 1154 runs-on: ubuntu-latest 1155 env: 1156 CARGO_NEXTEST_VERSION: 0.9.88 1157 MIRIFLAGS: -Zmiri-permissive-provenance 1158 steps: 1159 - uses: actions/checkout@v4 1160 with: 1161 submodules: true 1162 - uses: ./.github/actions/install-rust 1163 with: 1164 toolchain: wasmtime-ci-pinned-nightly 1165 - run: rustup component add rust-src miri 1166 - uses: actions/cache@v4 1167 with: 1168 path: ${{ runner.tool_cache }}/cargo-nextest 1169 key: cargo-nextest-bin-${{ env.CARGO_NEXTEST_VERSION }} 1170 - run: echo "${{ runner.tool_cache }}/cargo-nextest/bin" >> $GITHUB_PATH 1171 - run: cargo install --root ${{ runner.tool_cache }}/cargo-nextest --version ${{ env.CARGO_NEXTEST_VERSION }} cargo-nextest --locked 1172 - run: | 1173 cargo miri nextest run -j4 --no-fail-fast -p ${{ matrix.crate }} 1174 if: ${{ matrix.crate }} 1175 - run: ${{ matrix.script }} 1176 if: ${{ matrix.script }} 1177 1178 # Perform release builds of `wasmtime` and `libwasmtime.so`. Builds a variety 1179 # of platforms and architectures and then uploads the release artifacts to 1180 # this workflow run's list of artifacts. 1181 # 1182 # Note that the full matrix is computed by `ci/build-build-matrix.js`. 1183 build: 1184 needs: determine 1185 if: needs.determine.outputs.run-full 1186 name: Release build for ${{ matrix.build }} 1187 runs-on: ${{ matrix.os }} 1188 strategy: 1189 fail-fast: ${{ github.event_name != 'pull_request' }} 1190 matrix: ${{ fromJson(needs.determine.outputs.build-matrix) }} 1191 env: ${{ matrix.env || fromJSON('{}') }} 1192 steps: 1193 - uses: actions/checkout@v4 1194 with: 1195 submodules: true 1196 1197 - uses: ./.github/actions/install-ninja 1198 - uses: ./.github/actions/install-rust 1199 with: 1200 toolchain: ${{ matrix.rust }} 1201 - run: | 1202 rustup component add rust-src 1203 rustup target add ${{ matrix.target }} 1204 1205 # On one builder produce the source tarball since there's no need to produce 1206 # it everywhere 1207 - run: ./ci/build-src-tarball.sh 1208 if: matrix.build == 'x86_64-linux' 1209 1210 - uses: ./.github/actions/android-ndk 1211 if: contains(matrix.target, 'android') 1212 with: 1213 target: ${{ matrix.target }} 1214 1215 - run: ./ci/build-release-artifacts.sh "${{ matrix.build }}" "${{ matrix.target }}" 1216 1217 # Assemble release artifacts appropriate for this platform, then upload them 1218 # unconditionally to this workflow's files so we have a copy of them. 1219 - run: ./ci/build-tarballs.sh "${{ matrix.build }}" "${{ matrix.target }}" 1220 1221 - uses: actions/upload-artifact@v4 1222 with: 1223 name: bins-${{ matrix.build }} 1224 path: dist 1225 1226 # This is a "join node" which depends on all prior workflows. The merge queue, 1227 # for example, gates on this to ensure that everything has executed 1228 # successfully. 1229 # 1230 # Note that this is required currently for odd reasons with github. Notably 1231 # the set of checks to enter the merge queue and leave the merge queue must 1232 # be the same which means that the "build" step for example shows as skipped 1233 # for PRs but expands to many different steps for merge-queue-based PRs. That 1234 # means that for that step there's no single name to gate on, so it's required 1235 # to have a "join" node here which joins everything. 1236 # 1237 # Note that this currently always runs to always report a status, even on 1238 # cancellation and even if dependency steps fail. Each dependency tries to 1239 # cancel the whole run if it fails, so if a test matrix entry fails, for 1240 # example, it cancels the build matrix entries too. This step then tries to 1241 # fail on cancellation to ensure that the dependency failures are propagated 1242 # correctly. 1243 ci-status: 1244 name: Record the result of testing and building steps 1245 runs-on: ubuntu-latest 1246 needs: 1247 - test 1248 - test_capi 1249 - test_debug_dwarf 1250 - test_fuzzing 1251 - test_wasi_nn 1252 - test_nightly 1253 - build 1254 - rustfmt 1255 - clangformat 1256 - cargo_deny 1257 - cargo_vet 1258 - doc 1259 - micro_checks 1260 - special_tests 1261 - test_wasi_tls_nativetls 1262 - clippy 1263 - monolith_checks 1264 - platform_checks 1265 - bench 1266 - meta_deterministic_check 1267 - verify-publish 1268 - determine 1269 - miri 1270 - build-preview1-component-adapter 1271 - build-preview1-component-adapter-provider 1272 - test-min-platform-example 1273 - check_js 1274 if: always() 1275 steps: 1276 # Calculate the exit status of the whole CI workflow. 1277 # If all dependent jobs were successful, this exits with 0 (and the 1278 # outcome job continues successfully). If a some dependent job has 1279 # failed, this exits with 1. 1280 - name: calculate the correct exit status 1281 run: jq --exit-status 'all(.result == "success" or .result == "skipped")' <<< '${{ toJson(needs) }}' 1282 1283 # The purpose of this jobs is to watch for changes on the `release-*` 1284 # branches of this repository and look for the term 1285 # "automatically-tag-and-release-this-commit" within merged PRs/commits. Once 1286 # that term is found the current version of `Cargo.toml`, the `wasmtime-cli` 1287 # Cargo.toml, is created as a tag and the tag is pushed to the repo. 1288 # Currently the tag is created through the GitHub API with an access token to 1289 # ensure that CI is further triggered for the tag itself which performs the 1290 # full release process. 1291 # 1292 # Note that this depends on the `ci-status` step above which is the "join" 1293 # point of this workflow for when everything succeeds. the purpose of that is 1294 # so that the tag is only created after the aftifacts have been uploaded for 1295 # this workflow as the `publish-artifacts.yml` workflow will download these 1296 # artifacts and then publish them to the tag. 1297 push-tag: 1298 runs-on: ubuntu-latest 1299 needs: ci-status 1300 if: | 1301 always() 1302 && needs.ci-status.result == 'success' 1303 && github.event_name == 'push' 1304 && startsWith(github.ref, 'refs/heads/release-') 1305 && github.repository == 'bytecodealliance/wasmtime' 1306 steps: 1307 - uses: actions/checkout@v4 1308 with: 1309 submodules: true 1310 fetch-depth: 0 1311 - name: Test if tag is needed 1312 run: | 1313 git log ${{ github.event.before }}...${{ github.event.after }} | tee main.log 1314 version=$(grep '^version =' Cargo.toml | head -n 1 | sed 's/.*"\(.*\)"/\1/') 1315 echo "version: $version" 1316 echo "version=$version" >> $GITHUB_OUTPUT 1317 echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT 1318 if grep -q "automatically-tag-and-release-this-commit" main.log; then 1319 echo push-tag 1320 echo "push_tag=yes" >> $GITHUB_OUTPUT 1321 else 1322 echo no-push-tag 1323 echo "push_tag=no" >> $GITHUB_OUTPUT 1324 fi 1325 id: tag 1326 - name: Push the tag 1327 run: | 1328 git_refs_url=$(jq .repository.git_refs_url $GITHUB_EVENT_PATH | tr -d '"' | sed 's/{\/sha}//g') 1329 curl -iX POST $git_refs_url \ 1330 -H "Authorization: token ${{ secrets.PERSONAL_ACCESS_TOKEN }}" \ 1331 -d @- << EOF 1332 { 1333 "ref": "refs/tags/v${{ steps.tag.outputs.version }}", 1334 "sha": "${{ steps.tag.outputs.sha }}" 1335 } 1336 EOF 1337 if: steps.tag.outputs.push_tag == 'yes' 1338 1339 # File an issue on the repo if this run failed and was triggered via 1340 # `workflow_dispatch`, which mostly means that 1341 # `.github/workflows/trigger-release-branch-ci.yml` will file issues on 1342 # failure so we get to see a notification when a build fails for a historical 1343 # release branch. 1344 file-issue-on-error: 1345 name: File an issue if this build failed and was cron-triggered 1346 runs-on: ubuntu-latest 1347 needs: ci-status 1348 if: | 1349 always() 1350 && needs.ci-status.result != 'success' 1351 && github.event_name == 'workflow_dispatch' 1352 permissions: 1353 issues: write 1354 steps: 1355 - uses: actions/github-script@v7 1356 with: 1357 script: | 1358 github.rest.issues.create({ 1359 owner: context.repo.owner, 1360 repo: context.repo.repo, 1361 title: `Failed CI build for ${context.ref}`, 1362 body: `See https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`, 1363 }) 1364