name: Rust CI

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

jobs:
  build:
    name: test ${{ matrix.rust }} 
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        rust: ["stable", "beta", "nightly"]
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - name: Set up Rust
        run: | 
          rustup update ${{ matrix.rust }} 
          rustup default ${{ matrix.rust }}
          rustup component add rustfmt
          rustup component add clippy
      - uses: Swatinem/rust-cache@v2
      - name: Check 
        run: | 
          cargo check 
      - name: Fmt 
        run: |
          cargo fmt --all --check
      - name: Lint 
        run: |
          cargo clippy --all --all-features -- -D warnings
      - name: Run tests 'core'
        run: | 
          cargo test --lib -- --nocapture
