---
name: Test
on:
  pull_request:
    paths:
      - "**.go"
  push:
    branches:
      - master
      - v[0-9].[0-9]+-dev
jobs:
  tests:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        part: ["00", "01", "02", "03", "04", "05"]
    steps:
      - uses: actions/setup-go@v5.0.0
        with:
          go-version: "1.21"
      - uses: actions/checkout@v4
      - uses: technote-space/get-diff-action@v6
        with:
          PATTERNS: |
            **/**.go
            "!test/"
            go.mod
            go.sum
            Makefile
      - name: Install libpcap
        run: sudo apt-get install --yes libpcap-dev
      - uses: ./.github/actions/bls
        name: Install BLS library
        if: "env.GIT_DIFF != ''"
      - name: Install dependencies
        run: sudo apt-get update && sudo apt-get install -y libpcap-dev
      - name: Run Go Tests
        env:
          CGO_LDFLAGS: "-L/usr/local/lib -ldashbls -lrelic_s -lmimalloc-secure -lgmp"
          CGO_CXXFLAGS: "-I/usr/local/include"
        run: |
          make test-group-${{ matrix.part }} NUM_SPLIT=6
        if: env.GIT_DIFF