name: Rust

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main, biscuit-6-0 ]

env:
  CARGO_TERM_COLOR: always

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v4
    - name: Cache
      uses: actions/cache@v4
      with:
        path: |
          ~/.cargo
          target/
        key: ${{ runner.os }}-${{ hashFiles('Cargo.toml') }}
        restore-keys: |
          ${{ runner.os }}-${{ hashFiles('Cargo.toml') }}
          ${{ runner.os }}-
    - name: Build
      run: cargo build --verbose
    - name: Clippy
      run: cargo clippy -- -D warnings
    - name: Format
      run: cargo fmt --check
    - name: Run tests
      run: |
        cargo test --verbose
        cargo build --example readme
        cargo build --example readme --features tracing
        cargo build --example configuration

