# This config file is generated by ./scripts/gen_gh_actions.py.
# Do not edit by hand.

name: FreeBSD CI

on:
  push:
    branches: [ dev, ci_travis ]
  pull_request:
    branches: [ dev ]

jobs:
  test-freebsd:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        debug: ['--enable-debug', '--disable-debug']
        prof: ['--enable-prof', '--disable-prof']
        arch: ['64-bit', '32-bit']
        uncommon:
          - ''
          - '--with-lg-page=16 --with-malloc-conf=tcache:false'

    name: FreeBSD (${{ matrix.arch }}, debug=${{ matrix.debug }}, prof=${{ matrix.prof }}${{ matrix.uncommon && ', uncommon' || '' }})

    steps:
    - uses: actions/checkout@v6
      with:
        fetch-depth: 1

    - name: Test on FreeBSD
      uses: vmactions/freebsd-vm@v1
      with:
        release: '15.0'
        usesh: true
        prepare: |
          pkg install -y autoconf gmake
        run: |
          # Verify we're running in FreeBSD
          echo "==== System Information ===="
          uname -a
          freebsd-version
          echo "============================"

          # Set compiler flags for 32-bit if needed
          if [ "${{ matrix.arch }}" = "32-bit" ]; then
            export CC="cc -m32"
            export CXX="c++ -m32"
          fi

          # Generate configure script
          autoconf

          # Configure with matrix options
          ./configure --with-jemalloc-prefix=ci_ ${{ matrix.debug }} ${{ matrix.prof }} ${{ matrix.uncommon }}

          # Get CPU count for parallel builds
          export JFLAG=$(sysctl -n kern.smp.cpus)

          gmake -j${JFLAG}
          gmake -j${JFLAG} tests
          gmake check



