on:
  workflow_dispatch:
  pull_request:
  push:
    branches:
      - master

name: ci

jobs:
  check:
    name: Check
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          submodules: true
      - uses: dtolnay/rust-toolchain@1.81
      - run: cargo check --all --all-features --locked

  test:
    name: Test Suite
    strategy:
      matrix:
        os: [ubuntu-latest, windows-latest]
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v4
        with:
          submodules: true
      - uses: dtolnay/rust-toolchain@1.81
      - run: cargo install wasm-pack --version 0.12.1 --locked
      - run: cargo test --all --no-default-features --locked
      - run: cargo test --all --all-features --locked
      - run: wasm-pack test --node --all --locked

  fmt:
    name: Rustfmt
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          submodules: true
      - uses: dtolnay/rust-toolchain@1.81
      - run: rustup component add rustfmt clippy
      - run: cargo fmt --all -- --check
      - run: cargo clippy --all-features -- --deny warnings
