on: [push, pull_request]

name: CI
jobs:
  ci:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        rust:
          - stable
          - beta
          - nightly
          - 1.55.0 # MSRV

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

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

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

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

      - name: Build
        uses: actions-rs/cargo@v1
        with:
          command: build
          args: --all-targets

      - name: Test
        uses: actions-rs/cargo@v1
        with:
          command: test
          args: --all-targets
