name: test

on:
  pull_request:

jobs:
  test:
    runs-on: ubuntu-latest
    env:
      GOTOOLCHAIN: local
    strategy:
      fail-fast: false
      matrix:
        go: ['1.24', '1.25']
    steps:
    - uses: actions/setup-go@v4
      with:
        go-version: ${{ matrix.go }}
    - uses: actions/checkout@v4

    - name: Get dependencies
      run: |
        go get golang.org/x/tools/cmd/cover
        go get github.com/mattn/goveralls

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

    - name: Send coverage
      uses: shogo82148/actions-goveralls@v1
      with:
        github-token: ${{ secrets.GITHUB_TOKEN }}
        path-to-profile: coverage.out
        flag-name: Go-${{ matrix.go }}
        parallel: true

  # notifies that all test jobs are finished.
  finish:
    needs: test
    runs-on: ubuntu-latest
    steps:
      - uses: shogo82148/actions-goveralls@v1
        with:
          parallel-finished: true
