name: Test Go
on:
  push:
    tags:
      - v*
    branches:
      - main
  pull_request:
jobs:
  test:
    name: Test
    runs-on: ubuntu-latest

    steps:
      - name: Check out code
        uses: actions/checkout@v3

      - name: Set up Go
        uses: actions/setup-go@v4
        with:
          go-version-file: "go.mod"

      - name: Install Dependencies
        env:
          GOPROXY: https://proxy.golang.org,direct
        run: go mod download

      - name: Test
        run: go test -race -coverprofile=coverage.out -covermode=atomic ./...

      - name: Upload coverage reports to Codecov
        uses: codecov/codecov-action@v5
        with:
          token: ${{ secrets.CODECOV_TOKEN }}
