name: Test

on:
  push:
    branches:
      - "*"
  pull_request:
    branches:
      - "*"

jobs:
  build:
    strategy:
      matrix:
        go-version: ["1.18", "1.19", "1.20"]
        # TODO(mdlayher): tests are failing on macOS but almost all consumers of
        # this package are Linux. Investigate.
        os: [ubuntu-latest]
    runs-on: ${{ matrix.os }}

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

      - name: Check out code into the Go module directory
        uses: actions/checkout@v3

      - name: Run tests
        run: go test -race -tags gofuzz ./...

      - name: Build test binary
        run: go test -c -race

      - name: Run integration tests
        run: sudo ./ndp.test -test.v -test.run TestConn
