name: Rust

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

env:
  CARGO_TERM_COLOR: always

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
    - name: Format
      run: cargo fmt --all -- --check
    - name: Build
      run: RUSTFLAGS="-D warnings" cargo build --verbose --all-targets
    - name: Clippy
      run: cargo clippy --all-targets --all-features --locked -- -D warnings -D clippy::wildcard_imports -D clippy::cognitive_complexity
    - name: Run tests
      run: cargo test --verbose
