#image: registry.esss.lu.se/ics-docker/miniconda
image: python:3.8-slim
.pip_install_default: &pip_install_default
    - pip install scipy matplotlib h5py webdavclient3
.pip_install_sphinx: &pip_install_sphinx
    - pip install sphinx sphinxcontrib-confluencebuilder sphinxcontrib-blockdiag blockdiag sphinxcontrib-restbuilder sphinx_rtd_theme numpy m2r2
variables:
  TWINE_REPOSITORY_URL: https://artifactory.esss.lu.se/artifactory/api/pypi/ics-pypi

stages:
    - test
    - deploy

style_check:
  stage: test
  image: registry.esss.lu.se/ics-docker/pre-commit
  script:
    - pre-commit run --all-files

examples:
  stage: test
  before_script:
    - *pip_install_default
  script:
    - python tests.py -v

pages:
  stage: deploy
  script:
    - apt update
    - apt install git -y
    - *pip_install_sphinx
    - python setup.py install
    - sphinx-build -b html -d public/doctrees   doc public
  artifacts:
    paths:
      - public
  only:
    - tags

confluence-doc:
  stage: deploy
  script:
    - apt update
    - apt install git -y
    - *pip_install_sphinx
    - python setup.py install
    - sphinx-build -M confluence "doc" "doc"
  only:
    - tags

release-pypi:
  tags:
    - docker
  stage: deploy
  image: python:3.7
  before_script:
    - pip install twine
  script:
    - python setup.py check sdist bdist_wheel
    - twine upload dist/*
  only:
    - tags

auto-release:
    image: inetprocess/gitlab-release
    stage: deploy
    only:
        - tags
    script:
        - gitlab-release --message "Automatic release of ${CI_COMMIT_TAG} from ${CI_COMMIT_SHORT_SHA}<br>${CI_COMMIT_DESCRIPTION}"
