name: Run tests

on:
  push:
    branches:
      - main
  pull_request:
    branches:
      - main

env:
  GO_VERSION: "~1.22"

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4

      - name: Set up Go
        uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5
        with:
          go-version: ${{ env.GO_VERSION }}

      - name: Run test
        run: go test ./... -coverprofile=coverage.txt
      - name: Upload coverage to Codecov
        uses: codecov/codecov-action@0565863a31f2c772f9f0395002a31e3f06189574 # v5
        env:
          CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
