name: '[freebsd] architecture builds'
on:
  workflow_dispatch:
    branches: [ master, stable* ]
  schedule:
    - cron: '30 5 * * SAT'

jobs:
  freebsd_job:
    runs-on: ubuntu-latest
    name: Build on FreeBSD
    steps:
    - uses: actions/checkout@v4
    - name: Test in FreeBSD
      id: test
      uses: vmactions/freebsd-vm@v1
      with:
        usesh: true
        copyback: false
        prepare: |
          pkg install -y \
            cmake \
            ninja \
            krb5-devel \
            json-c \
            libcjson \
            fdk-aac \
            libsoxr \
            sdl2 \
            sdl3 \
            sdl2_ttf \
            sdl2_image \
            opus \
            png \
            webp \
            openjpeg \
            libjpeg-turbo \
            opensc \
            v4l_compat \
            libv4l \
            uriparser \
            pkcs11-helper \
            ffmpeg \
            pulseaudio \
            pcsc-lite \
            cups \
            opencl \
            openssl34 \
            gsm \
            influxpkg-config \
            icu \
            fusefs-libs3 \
            ccache \
            opencl-clang-llvm15 \
            faac \
            faad2 \
            opus-tools \
            openh264 \
            alsa-lib \
            cairo \
            ocl-icd

        run: |
          export LD_LIBRARY_PATH=/usr/lib/clang/18/lib/freebsd
          export CTEST_OUTPUT_ON_FAILURE=1
          cmake -GNinja \
            -C ci/cmake-preloads/config-freebsd.txt \
            -B ci-build \
            -S . \
            -DCMAKE_INSTALL_PREFIX=/tmp/ci-test
          cmake --build ci-build --parallel $(nproc) --target install
          cmake --build ci-build --parallel $(nproc) --target test
