name: "Run Tests"

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

jobs:
  test:
    name: Test

    strategy:
      matrix:
        os: [macos-latest, windows-latest, ubuntu-latest]

    runs-on: ${{ matrix.os }}

    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: Install Rust toolchain
        uses: actions-rs/toolchain@v1
        with:
          profile: minimal
          toolchain: stable

      - name: Cache cargo resources
        uses: Swatinem/rust-cache@v1

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

      - name: Cargo fmt
        uses: actions-rs/cargo@v1
        with:
          command: fmt
          args: --all -- --check

      - name: Debug build
        uses: actions-rs/cargo@v1
        with:
          command: build
          args: --all-targets

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