name: rust

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

env:
  CARGO_TERM_COLOR: always

jobs:
  lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions-rs/toolchain@v1
        with:
          profile: minimal
          toolchain: stable
          components: rustfmt, clippy
          override: true
      - uses: actions-rs/cargo@v1
        with:
          command: clippy
          args: -- -D warnings
      - uses: actions-rs/cargo@v1
        with:
          command: fmt
          args: --all -- --check
  test:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        rust:
          - 1.46.0
          - stable
          - beta
    steps:
      - uses: actions/checkout@v2
      - uses: actions-rs/toolchain@v1
        with:
          profile: minimal
          toolchain: ${{ matrix.rust }}
          override: true
      - uses: actions-rs/cargo@v1
        with:
          command: check
      - uses: actions-rs/cargo@v1
        with:
          command: test
