---
name: test

on:
  push:
    branches: [main]
    paths-ignore:
      - 'docs/**'
  pull_request:
    branches: [main]
    paths-ignore:
      - 'docs/**'

jobs:

  build:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        go: [ '1.16', '1.17', '1.18' ]
    steps:
    - uses: actions/checkout@v2

    - name: Install gpgme
      run: sudo apt-get install libgpgme-dev

    - name: Setup go ${{ matrix.go }}
      uses: actions/setup-go@v2
      with:
        go-version: ${{ matrix.go }}

    - uses: actions/cache@v2
      with:
        path: ~/go/pkg/mod
        key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
        restore-keys: |
          ${{ runner.os }}-go-

    - name: Build with go ${{ matrix.go }}
      run: make all

    - name: vet
      run: make vet

    - name: test
      run: make test-it
