summaryrefslogtreecommitdiff
path: root/.github/workflows/test.yaml
blob: 47708fb844ce7d5bf70c8ca1b1b3b4bb23e42785 (plain)
name: Rust CI

on:
  push:
    branches: ["**"]
  pull_request:
    branches: ["next", "main"]

jobs:
  build-wasm:
    name: Build wasm
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          submodules: true
      - name: Install Rust toolchain & Binaryen
        run: rustup update && rustup target add wasm32-unknown-unknown && sudo apt-get install -y binaryen wabt
      - name: Build wasm
        run: ./examples/rust/build.sh
      - name: Save artifacts
        uses: actions/upload-artifact@v4
        with:
          name: wasm
          path: examples/rust/out

  run-tests:
    needs: build-wasm
    strategy:
      matrix:
        include:
          - os: ubuntu-latest
            rust: stable
            name: "Linux (stable)"
          - os: ubuntu-latest
            rust: nightly
            name: "Linux (nightly)"
          - os: ubuntu-latest
            rust: stable
            name: "Linux (stable, no default features)"
            args: "--no-default-features"
          - os: ubuntu-latest
            rust: nightly
            name: "Linux (nightly, no default features)"
            args: "--no-default-features"
          - os: macos-14
            rust: stable
            name: "macOS arm64 (Apple M1)"
          - os: ubuntu-latest
            rust: stable
            name: "armv7 (32-Bit Raspberry Pi)"
            target: armv7-unknown-linux-gnueabihf

    runs-on: ${{ matrix.os }}
    steps:
      - name: Checkout code
        uses: actions/checkout@v4
        with:
          submodules: true

      - name: Install Rust toolchain
        uses: actions-rust-lang/setup-rust-toolchain@v1
        with:
          toolchain: ${{ matrix.rust }}
          rustflags: ""
          components: rustfmt, clippy
        if: matrix.target == ''

      - name: Load wasm
        uses: actions/download-artifact@v4
        with:
          name: wasm

      - name: Run tests
        run: cargo test --workspace ${{ matrix.args }} && cargo run --example wasm-rust all
        if: matrix.target == ''

      - name: Run clippy
        run: cargo clippy --workspace --all-targets --all-features
        if: matrix.target == ''

      - name: Run tests (${{ matrix.target }})
        uses: houseabsolute/actions-rust-cross@v0.0.13
        with:
          command: test
          target: ${{ matrix.target }}
          toolchain: ${{ matrix.rust }}
        if: matrix.target != ''

      - name: Run clippy (${{ matrix.target }})
        uses: houseabsolute/actions-rust-cross@v0.0.13
        with:
          command: clippy
          target: ${{ matrix.target }}
          toolchain: ${{ matrix.rust }}
        if: matrix.target != ''