name: batcher

on: [push, pull_request]

env:
  CARGO_TERM_COLOR: always

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout sources
        uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab

      - name: Install Rust toolchain
        run: rustup default nightly

      - name: Install cargo-hack
        run: cargo install cargo-hack

      - name: All
        working-directory: ./batcher
        run: cargo test --all-features

      - name: Docs
        working-directory: ./batcher
        run: cargo doc --all-features

      - name: Build powerset
        working-directory: ./batcher
        run: cargo hack build --feature-powerset --lib

      - name: Test powerset
        working-directory: ./batcher
        run: cargo hack test --feature-powerset --lib

      - name: Minimal versions
        working-directory: ./batcher
        run: cargo hack test --feature-powerset --lib -Z minimal-versions

  web:
    name: Test (Node)
    runs-on: ubuntu-latest
    steps:
      - name: Checkout sources
        uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab

      - name: Setup Node
        uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020
        with:
          node-version: 24.x

      - name: Install Rust toolchain
        run: rustup default nightly

      - name: Install wasm-pack
        run: cargo install wasm-pack

      - name: Default
        working-directory: ./batcher
        run: wasm-pack test --node

      - name: Web
        working-directory: ./batcher
        run: wasm-pack test --node --features web
