walrus 0.26.0

A library for performing WebAssembly transformations
Documentation
name: CI
on: [push, pull_request]

jobs:
  test:
    name: Test
    runs-on: ubuntu-latest
    strategy:
      matrix:
        rust: [stable, beta, nightly]
    steps:
    - uses: actions/checkout@v4
      with:
        submodules: true
    - name: Install Rust
      run: rustup update ${{ matrix.rust }} && rustup default ${{ matrix.rust }}
    - uses: cargo-bins/cargo-binstall@main
    - name: Install wasm-tools (need json-from-wast subcommand)
      run: cargo binstall wasm-tools -y
    - name: Install wabt
      run: |
        set -e
        curl -L https://github.com/WebAssembly/wabt/releases/download/1.0.40/wabt-1.0.40-linux-x64.tar.gz | tar xzf -
        echo "`pwd`/wabt-1.0.40/bin" > $GITHUB_PATH
    - name: Install binaryen
      run: |
        set -e
        curl -L https://github.com/WebAssembly/binaryen/releases/download/version_117/binaryen-version_117-x86_64-linux.tar.gz | tar xzf -
        echo "`pwd`/binaryen-version_117/bin" > $GITHUB_PATH
    - run: cargo build --all
    - run: cargo test --all
    - run: cargo check --benches
    - run: cargo test --features parallel
    - run: cargo test --features parallel --manifest-path crates/tests/Cargo.toml

  fuzz_crate:
    name: Fuzz Crate
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - name: Install Rust
      run: rustup update stable && rustup default stable
    - name: Install wabt
      run: |
        set -e
        curl -L https://github.com/WebAssembly/wabt/releases/download/1.0.40/wabt-1.0.40-linux-x64.tar.gz | tar xzf -
        echo "`pwd`/wabt-1.0.40/bin" > $GITHUB_PATH
    - name: Install binaryen
      run: |
        set -e
        curl -L https://github.com/WebAssembly/binaryen/releases/download/version_117/binaryen-version_117-x86_64-linux.tar.gz | tar xzf -
        echo "`pwd`/binaryen-version_117/bin" > $GITHUB_PATH
    - name: Run fuzzer
      run: cargo test -p walrus-fuzz-utils > fuzz.log || (tail -n 1000 fuzz.log && exit 1)
      env:
        # 300 seconds = 5 minutes.
        WALRUS_FUZZ_TIMEOUT: 300

  fuzz:
    name: Fuzz
    runs-on: ubuntu-latest
    strategy:
      matrix:
        # Pure-Rust fuzzers — no external tool dependencies, high throughput.
        test: [raw, gc-smith]
    steps:
    - uses: actions/checkout@v4
    - name: Install Rust
      run: rustup update nightly && rustup default nightly
    - run: cargo install cargo-fuzz
    - name: Run fuzzer
      run: |
        cargo fuzz run ${{ matrix.test }} -- -max_total_time=300 -rss_limit_mb=4096 > fuzz.log 2>&1 || (tail -n 1000 fuzz.log && exit 1)

  fuzz_slow:
    name: Fuzz (subprocess)
    runs-on: ubuntu-latest
    strategy:
      matrix:
        # These fuzzers spawn wasm-opt / wasm-interp per iteration, so they
        # are much slower (~1000 runs in 300s vs millions for the pure-Rust
        # targets). They run in a separate job to avoid blocking the fast
        # fuzzers.
        test: [watgen, wasm-opt-ttf]
    steps:
    - uses: actions/checkout@v4
    - name: Install Rust
      run: rustup update nightly && rustup default nightly
    - run: cargo install cargo-fuzz
    - name: Install wabt
      run: |
        set -e
        curl -L https://github.com/WebAssembly/wabt/releases/download/1.0.40/wabt-1.0.40-linux-x64.tar.gz | tar xzf -
        echo "`pwd`/wabt-1.0.40/bin" > $GITHUB_PATH
    - name: Install binaryen
      run: |
        set -e
        curl -L https://github.com/WebAssembly/binaryen/releases/download/version_117/binaryen-version_117-x86_64-linux.tar.gz | tar xzf -
        echo "`pwd`/binaryen-version_117/bin" > $GITHUB_PATH
    - name: Run fuzzer
      run: |
        cargo fuzz run ${{ matrix.test }} -- -max_total_time=300 -rss_limit_mb=4096 > fuzz.log 2>&1 || (tail -n 1000 fuzz.log && exit 1)

  rustfmt:
    name: Rustfmt
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - name: Install Rust
      run: rustup update stable && rustup default stable && rustup component add rustfmt
    - run: cargo fmt -- --check