name: Go

on:
  push:
    branches: [master]
  pull_request:
    branches: [master]

jobs:
  build:
    name: Build
    runs-on: ubuntu-latest
    steps:
      - name: Set up Go 1.x
        uses: actions/setup-go@v2
        with:
          go-version: 1.17

      - name: Check out code into the Go module directory
        uses: actions/checkout@v2

      - name: Get dependencies
        run: |
          go mod download
          go get

      - name: Test
        run: go test -v -coverprofile=covprofile.cov ./...

      - name: Send coverage
        env:
          COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          go get github.com/mattn/goveralls
          go install github.com/mattn/goveralls
          goveralls -coverprofile=covprofile.cov -service=github
