name: CI

on:
  push:
  pull_request:

jobs:

  ci:
    name: Build and test
    runs-on: ubuntu-latest
    steps:
    - uses: actions/setup-go@v2
      with:
        go-version: '^1.19'

    - uses: actions/checkout@v2

    - name: Cache protobuf build
      id: protocache
      uses: actions/cache@v3
      with:
        path: _vendor/protobuf-21.12
        key: protobuf-21.12

    - name: Compile protobuf
      if: steps.protocache.outputs.cache-hit != 'true'
      run: |
        sudo apt-get install -y autoconf automake libtool curl make g++ unzip
        ./protobuf.sh

    - run: make install && go mod tidy && go mod verify
    - run: git --no-pager diff --exit-code

    - run: go vet ./...

    - run: make genall
    - run: git --no-pager diff --exit-code

    - run: make test
    - run: git --no-pager diff --exit-code
