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 -m pip install numpy
  script:
    - python3 setup.py bdist_wheel
    - python3 -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 -m pip install --upgrade pip
    - python3 -m pip install numpy
    - python3 -m pip install dist/*
    - python3 -m pip install Sphinx sphinx-rtd-theme sphinxcontrib-napoleon numpydoc myst-parser
  script:
    - 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