on:
  push:
    branches:
      - main
    paths:
      - '**.rs'
      - '**/Cargo.toml'
  workflow_dispatch:
  pull_request:
    paths:
      - '**.rs'
      - '**/Cargo.toml'

name: Tests
jobs:

  tests:
    name: Integration tests
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Install stable toolchain
        uses: actions-rs/toolchain@v1
        with:
          profile: minimal
          toolchain: stable
          override: true
          components: rustfmt
      - name: Run cargo test
        uses: actions-rs/cargo@v1
        with:
          command: test

  benches:
    name: Compile benchmarks
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Install stable toolchain
        uses: actions-rs/toolchain@v1
        with:
          profile: minimal
          toolchain: stable
          override: true
          components: rustfmt
      - name: Run cargo check
        uses: actions-rs/cargo@v1
        with:
          command: check
          args: -p bench --benches