name: CI

on:
  push:
    branches:
      - main
  pull_request:

jobs:
  rustfmt:
    name: Rustfmt
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
      with:
        submodules: true
    - uses: ./.github/actions/install-rust
      with:
        toolchain: stable
    - run: cargo fmt --all -- --check

  test:
    name: Test
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        build: [stable, windows]
        include:
          - build: stable
            os: ubuntu-latest
            rust: stable
          - build: windows
            os: windows-latest
            rust: stable

    steps:
    - run: |
        sudo apt-get update
        sudo apt-get install libudev-dev
      if: matrix.os == 'ubuntu-latest'
    - uses: actions/checkout@v2
      with:
        submodules: true
    - uses: ./.github/actions/install-rust
      with:
        toolchain: ${{ matrix.rust }}
    - run: cargo test --workspace --all-features
