name: Test sysinstall

on:
  schedule:
    - cron: '13 4 * * *'
  workflow_dispatch:

jobs:

  sysinstall:
    name: Test sysinstall
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest]

    steps:

      - uses: actions/checkout@v4
      
      # It seems to be important not to install a custom python here,
      # because `sudo` (which we need to use when installing to /usr/local
      # etc) always ends up running the default python, even if we set
      # $PATH etc. So for example we can end up with mupdf files and
      # pymupdf files being installed into .../python3.11/site-packages and
      # .../python3.10/site-packages, and tests all fail to import pymupdf.
      #
      #- uses: actions/setup-python@v5
        #with:
        #  # 3.12 doesn't have setuptools. As of 2024-01-03, MuPDF build requires setuptools before it
        #  # sees `--venv` and defers to a venv, so we currently have to force use of python 3.11.
        #  python-version: '3.11'

      - name: sysinstall_venv
        run:
          # Use venv.
          python3 scripts/sysinstall.py --root / --mupdf-git '--branch master https://github.com/ArtifexSoftware/mupdf.git'
          
      - name: sysinstall_sudo
        run:
          # Do not use a venv, instead install required packages with sudo.
          python3 scripts/sysinstall.py --pip sudo --root / --mupdf-git '--branch master https://github.com/ArtifexSoftware/mupdf-julian.git'
