name: CI
on: [push, pull_request]

jobs:
  check_fmt:
    name: fmt ${{ github.sha }}
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2

      - uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
          override: true

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

  ci:
    strategy:
      matrix:
        os: [macos-latest, ubuntu-latest, windows-latest]
        task: [['test', ''], ['clippy', '-- --deny warnings']]

    name: ${{ matrix.task[0] }} on ${{ matrix.os }}
    runs-on: ${{ matrix.os }}

    steps:
      - uses: actions/checkout@v2

      - uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
          override: true
          components: clippy

      - uses: actions-rs/cargo@v1
        with:
          command: ${{ matrix.task[0] }}
          args: ${{ matrix.task[1] }}
