name: Rust

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

jobs:
  check-stable:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
    - name: Install the stable
      uses: actions-rs/toolchain@v1
      with:
          toolchain: stable
          override: true
          components: rustfmt
    - name: Cargo fmt
      run: cargo fmt --all -- --check
    - name: Run tests
      run: cargo test --verbose
    - name: Build benchmarks
      run: cargo bench --verbose DONTRUNBENCHMARKS

  check-nightly:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
    - name: Install the nightly
      uses: actions-rs/toolchain@v1
      with:
          toolchain: nightly
          override: true
    - name: Run tests
      run: cargo test --features="std,nightly" --verbose
    - name: Build benchmarks
      run: cargo bench --features="std,nightly" --verbose DONTRUNBENCHMARKS
