name: build

on:
  push:
    # Branches that sound like default
    branches:
      - trunk
      - crates-io
    # Don't run tests, when only textfiles were modified
    paths-ignore:
      - "COPYRIGHT"
      - "LICENSE-*"
      - "**.md"
      - "**.txt"
      - "**readme.yml"
      - "**tpl"
  pull_request:
    branches:
      - trunk
      - crates-io
    paths-ignore:
      - "COPYRIGHT"
      - "LICENSE-*"
      - "**.md"
      - "**.txt"
      - "**readme.yml"
      - "**tpl"

jobs:
  rustfmt:
    name: Rustfmt
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions-rs/toolchain@v1
        with:
          profile: minimal
          toolchain: stable
          override: true
          components: rustfmt, clippy
      - uses: actions-rs/cargo@v1
        with:
          command: fmt
          args: --all -- --check
      - uses: actions-rs/cargo@v1
        with:
          command: clippy
          args: -- -D warnings
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Install Rust
        uses: hecrj/setup-rust-action@v1
      - name: Build
        run: cargo  build
      - name: Run tests
        run: cargo test
