name: CI

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

env:
  CARGO_TERM_COLOR: always

jobs:
  tests:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
    - uses: actions-rs/toolchain@v1
      with:
        profile: minimal
        toolchain: 1.46.0
        override: true
        components: rustfmt, clippy

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

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

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

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