image: python:latest

stages:
  - build
  - test
  - coverage
  - doc_build

navipy_install:
  stage: build
  before_script:
  - python3 -V # Print out python version for debugging

  script:
  - pip3 install virtualenv
  - virtualenv -p python3 venv
  - source venv/bin/activate
  - pip3 install .
  - python navipy/scripts/config_matplotlib_server.py # because no interactive backend

  artifacts:
    paths:
      - venv
    expire_in: 2 hours

  artifacts:
    paths:
      - venv

flake8:
  stage: test
  dependencies:
  - navipy_install

  script:
  - source $CI_PROJECT_DIR/venv/bin/activate
  - python3 -m flake8 navipy/*.py
  
navipy_unittest:
  stage: test
  dependencies: 
  - navipy_install

  script:
  - source $CI_PROJECT_DIR/venv/bin/activate
  - python3 -m coverage run -m unittest discover navipy

  artifacts:
    paths:
      - .coverage
    expire_in: 1 hours

coverage:
  stage: coverage
  dependencies: 
  - navipy_install
  - navipy_unittest
  
  script:
  - source $CI_PROJECT_DIR/venv/bin/activate
  - python3 -m coverage html

  artifacts:
    paths:
      - coverage_html_report
    expire_in: 1 day

doc_build:
  stage: doc_build
  dependencies:
  - navipy_install
  - coverage

  before_script:
  - apt-get update -y; apt-get install -y -qq pandoc

  script:
  - source $CI_PROJECT_DIR/venv/bin/activate
  - cd doc ; make html

  artifacts:
    paths:
    - doc/build
    
    expire_in: 1 week
