name: build
on: [push, pull_request]
jobs:
  build:
    env:
      # The special value "local" tells Go to use the bundled Go
      # version rather than trying to fetch one according to a
      # `toolchain` value in `go.mod`. This ensures that we're
      # really running the Go version in the CI matrix rather than
      # one that the Go command has upgraded to automatically.
      GOTOOLCHAIN: local
    strategy:
      matrix:
        go-version: [1.21.x, 1.22.x]
        os: [ubuntu-latest, macos-latest, windows-latest]

    runs-on: ${{ matrix.os }}

    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-go@v5
        with:
          go-version: ${{ matrix.go-version }}
        id: go

      - name: Build
        run: go build -v

      - name: Test
        run: go test -v ./...
