name: Rust

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

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - name: Run cargo fmt
      run: cargo fmt -- --check
    - name: Build
      run: cargo build --verbose
    - name: Run tests
      run: cargo test --verbose

  clippy:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - uses: actions-rs/toolchain@v1
      with:
        profile: minimal
        toolchain: stable
        override: true
        components: clippy
    - uses: actions-rs/cargo@v1
      with:
        command: clippy
        args: --workspace --tests -- --deny warnings
