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: Run "./scripts/test.sh"
        run: ./scripts/test.sh
