name: ci-fedora

on:
  workflow_call:

jobs:
  build-fedora:
    runs-on: ubuntu-latest
    container:
      image: fedora:latest
    timeout-minutes: 5

    steps:
      - uses: actions/checkout@v4

      - name: Install dependencies
        run: |
          dnf install -y autoconf automake gcc gettext-devel groff libtool make pkgconfig
          dnf install -y aspell-devel check-devel gpm-devel libX11-devel "pkgconfig(ext2fs)" "pkgconfig(glib-2.0)" "pkgconfig(gmodule-2.0)" "pkgconfig(libssh2)" "pkgconfig(slang)"

          # For tests
          dnf install -y glibc-gconv-extra util-linux

      - name: Lint documentation
        working-directory: maint
        run: ./doctest

      - name: Bootstrap build system
        run: ./autogen.sh

      - name: Build default configuration
        run: |
          useradd --home "$(pwd)" test
          chown -R test "$(pwd)"

          su - test -c ' \
            ./configure \
              --prefix="$(pwd)/install-prefix" \
              --enable-mclib \
              --enable-aspell \
              --enable-werror \
              && \
            \
            make -j$(nproc) && \
            make check && \
            make install \
          '

      - uses: actions/upload-artifact@v4
        if: failure()
        with:
          name: test-suite-logs-fedora
          path: ./**/test-suite.log
