image: ubuntu:latest

stages:
  - test
  - deploy

.test_students:
  stage: test
  script:
    - echo "Testing student files"
    - pwd
    - apt-get update -y
    - apt install -y python3-pip
    - apt install -y python3.10 python-is-python3
#    - apt install -y python-is-python3
#    - python --version
#    - locate python
    - apt install -y git
    - apt install -y xvfb # Virtual framebuffer for GL stuff.
    - apt install -y inkscape pdftk
    - apt install -y latexmk  poppler-utils # latexmk and pdftocairo
    - DEBIAN_FRONTEND='noninteractive' apt install -y texlive-latex-recommended texlive-latex-extra texlive-science pdf2svg texlive-fonts-extra texlive-fonts-recommended
    - pip install -U Pillow
    - pip install -e ./
    - cd tests
    - xvfb-run -s "-screen 0 1400x900x24" python -m unittest test_slider.py
    - latexmk --version
    - ls tests_images/*


test_39:
  extends: .test_students
  image: ubuntu:latest

pages:
  stage: deploy
  script:
    - echo "Building the documentation."
    - pwd
    - apt-get -y update
    - apt install -y git
    - apt install -y python3-pip
    - apt install -y python3.10 python-is-python3
    - apt install -y inkscape pdftk # pdftk to grap pdf pages (only for converter; can probably be omitted).
    - apt install -y latexmk  poppler-utils # latexmk and pdftocairo
    - DEBIAN_FRONTEND='noninteractive' apt install -y texlive-latex-recommended texlive-latex-extra texlive-science pdf2svg
    - pip install -U Pillow
    - pip install -e ./
    - apt install -y xvfb # python-opengl  # Virtual framebuffer for GL stuff.
    - rm -rf tests/tests_images # blow tests_images folder if exists.
    - cd tests
    - xvfb-run -s "-screen 0 1400x900x24" python -m unittest test_slider.py
    - cd ..
    - ls tests
    - cp tests/tests_images public -rf
    - cp tests/expected public -rf
    - cat public/index.html
    - echo "in tests/expected"
    - ls tests/expected/*
    - echo "in public/expected"
    - ls public/expected/*
    - echo "in public/tests_images"
    - ls public/tests_images/*
    - latexmk --version
  artifacts:
    paths:
    - public
  rules:
    - if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH
