name: ci-fedora

on:
  workflow_call:

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

    steps:
      - name: Install git inside container
        run: dnf install -y git

      - uses: actions/checkout@v4

      - name: Install dependencies
        run: |
          dnf install -y autoconf automake clang-tools-extra 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 \
              && \
            \
            echo "Checking formatting..." && \
            clang-format --version && \
            make indent && \
            git diff --exit-code && \
            \
            make -j$(nproc) && \
            make check && \
            make install \
          '

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