name: Run Rust tests

on:
  pull_request:
    branches:
      - main
  workflow_dispatch:

env:
  CARGO_TERM_COLOR: always

jobs:
  test:
    name: test-${{ matrix.os }}
    runs-on: ${{ matrix.os }}-latest

    strategy:
      fail-fast: false
      matrix:
        include:
          - os: ubuntu
            target: x86_64-unknown-linux-gnu
          - os: windows
            target: x86_64-pc-windows-msvc
          - os: macos
            target: x86_64-apple-darwin

    steps:
    - uses: actions/checkout@v2
    - uses: actions-rs/toolchain@v1
      with:
        toolchain: stable
        target: ${{ matrix.target }}
        default: true
        override: true
    - uses: Swatinem/rust-cache@v1
    - uses: actions-rs/cargo@v1
      with:
        command: test
        args: --verbose --workspace
