name: Test

on:
  pull_request:
  push:
    branches:
      - master

jobs:
  build:

    strategy:
      matrix:
        os: [ ubuntu-latest, macos-latest ]
        go-version: [ '1.20', '1.21' ]

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

    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Set up Go ${{ matrix.go-version }}
        uses: actions/setup-go@v4
        with:
          go-version: ${{ matrix.go-version }}

      - name: Build Go package
        run: go build

      - name: Test Go package
        run: go test -exec sudo
