name: CI

on:
  push:
    branches:
    - main
  pull_request:

jobs:
  test:
    name: Test
    runs-on: ubuntu-latest
    strategy:
      matrix:
        go: [1.19.x, 1.18.x, 1.17.x]
    steps:
    - name: Checkout code
      uses: actions/checkout@v3
    - name: Setup Go
      uses: actions/setup-go@v3
      with:
        go-version: ${{ matrix.go }}
    - name: Test
      run: make test
    - name: Test with GOARCH=386
      run: env GOARCH=386 go test -v ./...
    - name: Test Coverage
      run: |
        go test -cover ./... | grep -F 100.0% || {
          go test -cover ./...
          echo Coverage decreased!
          exit 1
        } >&2
    - name: Lint
      run: make lint
