name: CI

on:
  push:
    branches:
      - main
  pull_request:

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

  build:
    name: Build
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        build: [1.34.2, stable, beta, nightly, windows, macos]
        include:
          - build: 1.34.2
            os: ubuntu-latest
            rust: 1.34.2
          - build: stable
            os: ubuntu-latest
            rust: stable
          - build: beta
            os: ubuntu-latest
            rust: beta
          - build: nightly
            os: ubuntu-latest
            rust: nightly
          - build: macos
            os: macos-latest
            rust: stable
          - build: windows
            os: windows-latest
            rust: stable
          - build: windows
            os: windows-latest
            rust: nightly

    steps:
    - uses: actions/checkout@v1
      with:
        submodules: true
    - uses: ./.github/actions/install-rust
      with:
        toolchain: ${{ matrix.rust }}
    - run: cargo build --all --all-features --release -vv

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

    steps:
    - uses: actions/checkout@v1
      with:
        submodules: true
    - uses: ./.github/actions/install-rust
      with:
        toolchain: ${{ matrix.rust }}
    - run: cargo test --all-features --all

