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