stages:
#  - test
  - deploy
  - pages

cache:
  key: old-pages
  paths:
    - public/docs/

#### Test ####
#now done with pre-commit hook
#CI is difficult (PostgreSQL server has to be setup
#(including PostGIS and toar_controlled_vocabulary),
#database users and passwords have to be created)
#activated via "git commit" (without arguments!)
#trying to set my default vi editor for the commit
#message (formerly done as command line option):
#git config --global core.editor "vi"
#test:
#  stage: test
#  tags:
#    - leap
#    - zam347
#    - base
#  script:
#    - zypper --non-interactive install python3-pip
#    - pip install --upgrade pip
#    - pip install --no-cache-dir -r requirements.txt
#    - chmod +x ./CI/do_pytest.sh
#    - ./CI/do_pytest.sh

#### Documentation ####
docs:
  stage: deploy
  tags:
    - leap
    - zam347
    - base
  when: always
  script:
    - zypper --non-interactive install python3-pip
    - pip install --upgrade pip
    - pip install --no-cache-dir -r requirements.txt
    - pip install sphinx
    - pip install sphinxcontrib.napoleon
    - pip install sphinxcontrib.restbuilder
    - pip install sphinxcontrib.websupport
    - chmod +x ./CI/create_documentation.sh
    - ./CI/create_documentation.sh
  artifacts:
    name: pages
    when: always
    paths:
      - docs/_build/html/

#### Pages ####
pages:
  stage: pages
  tags:
    - leap
    - zam347
    - base
  when: always
  script:
    - mkdir -p public/docs
    - cp -af docs/_build/html/* public/docs
    - ls public/docs/
  artifacts:
    name: pages
    when: always
    paths:
      - public/
