name: CI
on: [push, pull_request]

jobs:
  style:
    name: Check Style
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@master
    - name: Install Rustfmt
      run: rustup component add rustfmt
    - name: Check formatting
      run: cargo fmt --all -- --check

  test:
    name: Test
    needs: [style]
    runs-on: ubuntu-latest
    strategy:
      matrix:
        rust:
          - stable
          - beta
          - nightly
    steps:
      - uses: actions/checkout@master
      - name: Install Rust
        run: rustup update ${{ matrix.rust }} && rustup default ${{ matrix.rust }}
      - name: Run tests
        run: cargo test
