name: clippy/fmt

on:
  pull_request:
  push:
    branches:
      - main

jobs:
  clippy_fmt:
    name: Runs Clippy and Fmt
    runs-on: ubuntu-latest
    strategy:
      matrix:
        rust:
          - stable
          - beta
          - nightly

    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - uses: actions-rs/toolchain@v1
        with:
          profile: minimal
          toolchain: ${{ matrix.rust }}
          override: true
          components: rustfmt, clippy

      - name: Run fmt
        uses: actions-rs/cargo@v1
        with:
          command: fmt
          args: --all -- --check

      - name: Run clippy
        uses: actions-rs/cargo@v1
        with:
          command: clippy
          args: -- -D warnings
