name: Run tests and upload coverage

on:
  workflow_call:

permissions:
  contents: read

jobs:
  test:
    name: Run tests and collect coverage
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@85e6279cec87321a52edac9c87bce653a07cf6c2

      - name: Set up Go
        uses: actions/setup-go@29694d72cd5e7ef3b09496b39f28a942af47737e
        with:
          go-version: "1.24.3"

      - name: Install dependencies
        run: go mod download

      - name: Run tests
        run: |
          go test -v -coverprofile coverage.out -covermode atomic ./...

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