name: Rust

on:
  push:
    branches: ["master"]
  pull_request:
    branches: ["master"]

env:
  CARGO_TERM_COLOR: always

jobs:
  fmt:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - name: Check formatting
        run: cargo fmt --check

  clippy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - name: Install dependencies
        run: sudo apt-get update && sudo apt-get install -y pkg-config libssl-dev
      - name: Clippy
        run: cargo clippy --features all -- -D warnings

  test-all:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - name: Install dependencies
        run: sudo apt-get update && sudo apt-get install -y pkg-config libssl-dev
      - name: Build
        run: cargo build --verbose --features all
      - name: Test
        run: cargo test --verbose --features all
      - name: Doc tests
        run: cargo test --doc --features all

  test-metal:
    runs-on: macos-latest
    steps:
      - uses: actions/checkout@v6
      - name: Build
        run: cargo build --verbose --features metal-gpu
      - name: Test
        run: cargo test --verbose --features metal-gpu
