name: Rust

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

env:
  CARGO_TERM_COLOR: always

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
    - uses: actions/cache@v2
      with:
        path: |
          ~/.rustup/toolchains/stable-*
          ~/.cargo/registry
          ~/.cargo/git
          target
        key: ${{ runner.os }}-stable-cargo-${{ hashFiles('**/Cargo.lock') }}
    - name : Install clippy
      run: rustup component add clippy
    - name: Run clippy
      run: cargo clippy --all-features --verbose
    - name: Build
      run: cargo build --all-features --verbose
    - name: Run tests
      run: cargo test --all-features --verbose
