name: Test

on:
  push:
    branches:
      - master
  pull_request:

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

permissions:
  contents: read

jobs:
  go-versions:
    runs-on: ubuntu-latest
    outputs:
      versions: ${{ steps.versions.outputs.value }}
    steps:
      - id: versions
        run: |
          versions=$(curl -s 'https://go.dev/dl/?mode=json' | jq -c 'map(.version[2:])')
          echo "value=${versions}"  >> $GITHUB_OUTPUT
  test:
    needs: go-versions
    strategy:
      fail-fast: false
      matrix:
        go-version: ${{fromJson(needs.go-versions.outputs.versions)}}
        os:
          - ubuntu-24.04
          - ubuntu-22.04
          - macos-26
          - macos-15
          - macos-15-intel
          - macos-14
          - windows-2025
          - windows-2022
    runs-on: ${{ matrix.os }}
    steps:
      - name: Checkout code
        uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
      - name: Install Go
        uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
        with:
          go-version: ${{ matrix.go-version }}
      - name: Test
        run: |
          go test -coverprofile='coverage.out' -covermode=atomic ./...
