name: CI

on:
  push:
    branches: [master]
    paths-ignore: ['**.md']
  pull_request:
    types: [opened, synchronize]
    paths-ignore: ['**.md']

jobs:
  run:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - uses: actions/setup-go@v2
      with:
        go-version: 1.16.x
    - name: Ensure go.mod is already tidied
      run: go mod tidy && git diff -s --exit-code go.sum
    - uses: actions/cache@v2
      with:
        path: ~/go/pkg/mod
        key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
        restore-keys: |
          ${{ runner.os }}-go-
    - name: Run verify-readme
      run: make verify-readme
    - name: Run tests
      run: make test
    - name: Build binary
      run: make build
