name: emit

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
        run: cargo test --all-features

      - name: Docs
        run: cargo doc --all-features

      - name: Build powerset
        run: cargo hack build --feature-powerset --lib

      - name: Test powerset
        run: cargo hack test --feature-powerset --lib

      - name: Minimal versions
        run: cargo hack test --feature-powerset --lib -Z minimal-versions
  
  embedded:
    name: Build (embedded)
    runs-on: ubuntu-latest
    steps:
      - name: Checkout sources
        uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab

      - name: Install Rust toolchain
        run: |
          rustup default nightly
          rustup target add thumbv6m-none-eabi

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

      - name: Powerset
        run: cargo hack check --each-feature --exclude-features default,std,alloc,implicit_rt,implicit_internal_rt -Z avoid-dev-deps --target thumbv6m-none-eabi

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

      - name: Install Miri
        run: |
          rustup toolchain install nightly --component miri
          cargo +nightly miri setup

      - name: Default features
        run: cargo +nightly miri test --lib

      - name: No features
        run: cargo +nightly miri test --lib --no-default-features

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

      - name: Install Wasmtime
        run: curl https://wasmtime.dev/install.sh -sSf | bash

      - name: Add Wasmtime to path
        run: echo "$HOME/.wasmtime/bin" >> $GITHUB_PATH

      - name: Install Rust toolchain
        run: rustup default nightly

      - name: Install wasm32-wasip2 target
        run: rustup target add wasm32-wasip2

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

      - name: All
        run: cargo test --target wasm32-wasip2 --all-features

      - name: Build powerset
        run: cargo hack build --target wasm32-wasip2 --feature-powerset --lib

  wasm:
    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 wasm-pack
        run: cargo install wasm-pack

      - name: Default
        run: wasm-pack test --node

      - name: All
        run: wasm-pack test --node --all-features

      - name: None
        run: wasm-pack test --node --no-default-features

      - name: Web
        run: wasm-pack test --node --no-default-features --features web
