name: Collect Coverage

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main, develop ]

jobs:

  build:
    name: Build
    runs-on: ubuntu-latest
    steps:

    - name: Set up Go
      uses: actions/setup-go@v4
      with:
        go-version: '1.18'
      id: go

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

    - name: Get dependencies
      run: go get -v -t -d ./...

    - name: Coverage
      run: go test -v -cover -race -coverprofile=coverage -covermode=atomic

    - name: Upload coverage
      if: github.event_name == 'push'
      uses: codecov/codecov-action@v3
      with:
        file: ./coverage
        verbose: true
