name: Rust

on:
  push:
    branches:
      - '*'
  pull_request:
    branches:
      - '*'

env:
  CARGO_TERM_COLOR: always

jobs:
  build:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest, windows-latest, macos-latest]
        rust: [1.66.0, stable, beta, nightly]
    
    if: github.event_name == 'pull_request'

    steps:
    - uses: actions/checkout@v3
    - name: Check fmt
      run: cargo fmt --all -- --check
    - name: Doc tests
      run: cargo test --doc
    - name: Clippy
      run: cargo clippy --all --all-features -- --deny warnings
    - name: Examples
      run: cargo build --examples
    - name: Build
      run: cargo build --verbose
    - name: Run tests
      run: cargo test --verbose
