stages:
  - build
  - docs
  - deploy


image: debian:latest
before_script:
  - apt update && apt -y install git gcc cmake mpich

build_makefile:
  stage: build
  script:
    - make

build_cmake:
  stage: build
  script:
    - mkdir build && cd build
    - cmake ..
    - make

build_python:
  stage: build
  before_script:
    - apt update && apt -y install git gcc cmake mpich python3 python3-pip python3-venv
    - python3 -m venv ./venv
    - ./venv/bin/python -m pip install numpy wheel
  script:
    - ./venv/bin/python setup.py bdist_wheel
    - ./venv/bin/python -m pip install dist/*
  artifacts:
    paths:
      - dist/*.whl
  variables:
    PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
  cache:
    paths:
      - .cache/pip
      - venv/

build_docs:
  stage: docs
  dependencies:
    - build_python
  before_script:
    - apt update && apt -y install mpich python3 python3-pip python3-venv
    - python3 -m venv ./venv
    - ./venv/bin/python -m pip install numpy wheel
    - ./venv/bin/python -m pip install dist/*
    - ./venv/bin/python -m pip install Sphinx sphinx-rtd-theme sphinxcontrib-napoleon numpydoc myst-parser
  script:
    - source ./venv/bin/activate
    - cd docs
    - make dirhtml
  artifacts:
    paths:
      - docs/_build/dirhtml/
      
deploy_docs:
  stage: deploy
  dependencies:
    - build_docs
  script:
   - rsync -avp docs/_build/dirhtml/ /tmp/genericio
  tags:
   - docs

