name: Build and Test Nova

permissions:
  contents: read
  pull-requests: write

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

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
      - name: Build
        uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
      - uses: actions-rs/cargo@v1
        with:
          command: build
          args: --examples --benches --verbose

  build-wasm:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
      - name: Wasm build
        uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
          target: wasm32-unknown-unknown
      - uses: actions-rs/cargo@v1
        with:
          command: build
          args: --no-default-features --target wasm32-unknown-unknown

  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
      - name: Run tests
        uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
      - uses: actions-rs/cargo@v1
        with:
          command: test
          args: --release --verbose

  fmt:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
      - name: Check Rustfmt Code Style
        uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
          components: rustfmt
      - uses: actions-rs/cargo@v1
        with:
          command: fmt
          args: --all -- --check

  clippy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
      - name: Check clippy warnings
        uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
          components: clippy
      - uses: actions-rs/cargo@v1
        with:
          command: clippy
          args: --all-targets -- -D warnings

  spelling:
    runs-on: ubuntu-latest
    steps:
    - name: Checkout Actions Repository
      uses: actions/checkout@v5
    - name: Spell Check Repo
      uses: crate-ci/typos@685eb3d55be2f85191e8c84acb9f44d7756f84ab
