name: test
on:
  pull_request:
  push:
    branches:
      - main

jobs:
  test:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2

      - name: Cache .cargo and target
        uses: actions/cache@v2
        with:
          path: |
            ~/.cargo
            ./target
          key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: |
            ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.lock') }}
            ${{ runner.os }}-cargo-test

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