name: rust

on:
  pull_request:
  push:
    branches:
    - master
  schedule:
  - cron: '00 01 * * *'

jobs:
  build:
    name: test
    runs-on: ubuntu-18.04
    strategy:
      matrix:
        build: [stable, beta, nightly]
        include:
        - build: stable
          rust: stable
        - build: beta
          rust: beta
        - build: nightly
          rust: nightly
    steps:
    - name: Checkout repository
      uses: actions/checkout@v1
      with:
        fetch-depth: 1
    - name: Build
      run: cargo build --all-targets
    - name: Test
      run: cargo test
    - name: Doc
      run: cargo doc

  rustfmt:
    name: rustfmt
    runs-on: ubuntu-18.04
    steps:
    - name: Checkout repository
      uses: actions/checkout@v1
      with:
        fetch-depth: 1
    - name: Check formatting
      run: cargo fmt -- --check
