# This file is a template, and might need editing before it works on your project.
# Official language image. Look for the different tagged releases at:
image: python:3.8

# Pick zero or more services to be used on all builds.
# Only needed when using a docker container to run your tests in.
# Check out: http://docs.gitlab.com/ce/ci/docker/using_docker_images.html#what-is-service
#services:
#  - mysql:latest
#  - redis:latest
#  - postgres:latest

variables:
  ES_HOST: "$ES_HOST"
#  POSTGRES_DB: database_name

# Cache packages in between builds
# cache:
#   paths:
#     - vendor/python

# This is a basic example for a package or script which doesn't use services such as redis or postgres
before_script:
  - python -v                                   # Print out Python version for debugging
  # Setup git
  - apt-get install git
  - apt-get install -y curl
  - git config --global user.email "gitlabci@totalgood.com"
  - git config --global user.name "GitLab CI"
  # Install dependencies of your package and the testing environment
  # - apt-get install miniconda
  # - conda env create -n qary f scripts/environment.yml
  # - pip install .

# Run in different environments
# py27:
#   image: "python:2.7"
#   script:
#   - python setup.py test

py36:
  image: continuumio/miniconda3:latest

  before_script:
    - conda install -c anaconda curl
    - conda update -n base -c defaults conda
    - conda create -n qary36 'python>=3.6.0,<3.7'
    - conda env update -n qary36 -f environment.yml
    - source activate qary36
    - pip install -e .

  script:
    - ./scripts/test_command_line_qa.sh
    - pytest --cov-report=xml --cov=./

  after_script:
    - bash <(curl -s https://codecov.io/bash) -t $CODECOV_TOKEN

py37_pypi_latest_version_test:
  image: continuumio/miniconda3:latest

  before_script:
    - conda install -c anaconda curl
    - conda update -n base -c defaults conda
    - conda create -n qary37 'python>=3.7.6,<3.8'
    - source activate qary37
    - pip install qary

  script:
    - ./scripts/test_command_line_qa.sh

py37:
  image: continuumio/miniconda3:latest

  before_script:
    - conda install -c anaconda curl
    - conda update -n base -c defaults conda
    - conda create -n qary37 'python>=3.7.0,<3.8'
    - conda env update -n qary37 -f environment.yml
    - source activate qary37
    - pip install -e .

  script:
    - ./scripts/test_command_line_qa.sh
    - pytest --cov-report=xml --cov=./qary

  after_script:
    - bash <(curl -s https://codecov.io/bash) -t $CODECOV_TOKEN



py38:
  image: continuumio/miniconda3:latest

  before_script:
    - conda install -c anaconda curl
    - conda update -n base -c defaults conda
    - conda create -n qary38 'python>=3.8.0,<3.9'
    - conda env update -n qary38 -f environment.yml
    - source activate qary38
    - pip install -e .

  script:
    - ./scripts/test_command_line_qa.sh
    - pytest --cov-report=xml --cov=./

  after_script:
    - bash <(curl -s https://codecov.io/bash) -t $CODECOV_TOKEN


# This deploy job uses a simple deploy flow to Heroku, other providers, e.g. AWS Elastic Beanstalk
# are supported too: https://github.com/travis-ci/dpl
#deploy:
#  type: deploy
#  environment: production
#  script:
#  - python setup.py
#  - dpl --provider=heroku --app=$HEROKU_APP_NAME --api-key=$HEROKU_PRODUCTION_KEY

pages:
  before_script:
    # - conda update -n base -c defaults conda
    # - conda create -n qarydocs37 python=3.7.6
    # - conda env update -n qary37 -f environment.yml
    # - source activate qarydocs37
    - pip install -e .
    - pip install Sphinx
  script:
    - python setup.py install docs -b html
    - cp -r build/sphinx/html public
  artifacts:
    paths:
      - public
  only:
    - master
