vpin 0.27.0

Rust library for working with Visual Pinball VPX files
Documentation
name: Rust

on:
  push:
    branches: [ "main" ]
  pull_request:
    branches: [ "main" ]

permissions:
  contents: read

env:
  CARGO_TERM_COLOR: always

jobs:
  build:
    strategy:
      matrix:
        platform:
          - os: ubuntu-latest
          - os: windows-latest
          - os: macos-latest

    runs-on: ${{ matrix.platform.os }}

    steps:
      - uses: actions/checkout@v7
      - name: Install minimal stable with clippy and rustfmt
        uses: dtolnay/rust-toolchain@stable
        with:
          toolchain: stable
          components: rustfmt, clippy
      - uses: Swatinem/rust-cache@v2.9.1
        with:
          # Work around https://github.com/Swatinem/rust-cache/issues/341 -
          # cache-bin: true collides with the rustup proxies on the new GitHub
          # macOS runner image, making `cargo` dispatch as `rustup-init` after
          # cache restore.
          cache-bin: false
      - name: Build
        run: cargo build --verbose
      - name: Run tests
        run: cargo test --verbose

  wasm32-wasip1:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v7
      - name: Install stable Rust
        uses: dtolnay/rust-toolchain@stable
        with:
          toolchain: stable
          targets: wasm32-wasip1
      - uses: Swatinem/rust-cache@v2.9.1
      # Downloads a prebuilt binary, building wasmtime from source takes over 5 minutes
      - name: Install wasmtime
        uses: taiki-e/install-action@v2
        with:
          tool: wasmtime
      - name: Run WASM tests
        run: cargo test --target wasm32-wasip1

  wasm32-unknown-unknown:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v7
      - name: Install stable Rust
        uses: dtolnay/rust-toolchain@stable
        with:
          toolchain: stable
          targets: wasm32-unknown-unknown
      - uses: Swatinem/rust-cache@v2.9.1
      # wasm-bindgen refuses to run when the cli and the crate versions diverge, so resolve
      # the version from cargo instead of hardcoding it here
      - name: Resolve wasm-bindgen version
        id: wasm-bindgen
        run: |
          version=$(cargo metadata --format-version 1 --features wasm \
            | jq -r '.packages[] | select(.name=="wasm-bindgen") | .version')
          echo "Using wasm-bindgen $version"
          echo "version=$version" >> "$GITHUB_OUTPUT"
      - name: Install wasm-bindgen
        uses: taiki-e/install-action@v2
        with:
          tool: wasm-bindgen@${{ steps.wasm-bindgen.outputs.version }}
      - name: Run WASM tests
        run: cargo test --target wasm32-unknown-unknown --features wasm