sudo: false
language: python
cache: pip
env:
    matrix:
        # Minimal required package versions
        - ODDT_TOOLKIT=ob CONDA_PY=3.6 MINIMAL_REQ=1
        - ODDT_TOOLKIT=rdk CONDA_PY=3.6  MINIMAL_REQ=1
        # Recent versions
        - ODDT_TOOLKIT=ob CONDA_PY=3.6
        - ODDT_TOOLKIT=ob CONDA_PY=3.7
        - ODDT_TOOLKIT=ob CONDA_PY=3.8
        - ODDT_TOOLKIT=rdk CONDA_PY=3.6
        - ODDT_TOOLKIT=rdk CONDA_PY=3.7
        - ODDT_TOOLKIT=rdk CONDA_PY=3.8

    global:
        secure: "XOHub9EE1aj4xDWvws5Ej1oGvb5Dw2vVnDRKpU9ZP5Ko9yJ6AYvy3zDeHBb83htp2JSxdciIB5voBb3LF+o0YliBpHdgrub8CgV8VH3Lpl+f0X14yBsnP/swwY0Lde/Xyq2lq6FcP3siNx8OpaSFFTDIZnAqt/kKzUzBknd9wgA="
deploy:
    # pypi
    - provider: pypi
      user: __token__
      password:
          secure: "PVENDt0UDwftDGLKwd6iFSxra9x95txpE//gfqThhYV36EZyw1KxKmIKfWjZzjok7jI60s3pIwhFFjToErHj4zaE7F+OdS/qflZGMCisV4jl7lNZhIV2LW/9VZ5V2x1Ow+NG28DqWNPpWyd2C4FIqUk9FeO+sslgLkqaAZZW4rU="
      distributions: sdist
      on:
          tags: true
          repo: oddt/oddt
          branch: master
          # deploy once to prevent conflicting names on PyPi
          python: '3.6'
          condition: $ODDT_TOOLKIT = ob
    # conda
    - provider: script
      script: conda/deploy.sh
      on:
          tags: true
          repo: oddt/oddt
          branch: master
          # deploy once to prevent conflicting names on Anaconda.org
          python: '3.6'
          condition: $ODDT_TOOLKIT = ob
      skip_cleanup: true
install:
    # Install Miniconda.
    - wget -q https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh; bash miniconda.sh -b -f -p $HOME/miniconda;
    - export PATH="$HOME/miniconda/bin:$PATH"
    - conda config --set always_yes yes --set changeps1 no
    - conda update -q conda
    - conda install -q conda-build anaconda-client
    - conda info -a
    - if [ -d $HOME/miniconda/envs/test-environment ]; then rm -rf $HOME/miniconda/envs/test-environment; fi
    - conda create -q -n test-environment python=$CONDA_PY numpydoc six pillow
    - source activate test-environment
    - |
        if [[ "$MINIMAL_REQ" == "1" ]]; then
            conda install -q -c conda-forge numpy=1.12 scipy=0.19 joblib=0.10.3 scikit-image=0.12.3 xlsxwriter \
                scikit-learn=0.18 pandas=0.19.2;
            if [[ "$ODDT_TOOLKIT" == "ob" ]]; then
                conda install -q -c conda-forge openbabel=3.0.0;
            elif [[ "$ODDT_TOOLKIT" == "rdk" ]]; then
                conda install -q -c conda-forge rdkit=2018.03 boost=1.68;
            fi
        else
            conda install -q -c anaconda numpy scikit-learn joblib pandas scikit-image xlsxwriter;
            if [[ "$ODDT_TOOLKIT" == "ob" ]]; then
                conda install -q -c conda-forge openbabel;
            elif [[ "$ODDT_TOOLKIT" == "rdk" ]]; then
                conda install -q -c conda-forge rdkit=2019.09;
            fi
        fi
        conda install -q -c bioconda autodock-vina
        conda install -q pytest pytest-cov pytest-xdist
        pip install coveralls
    - python setup.py install
script:
    - pytest --cov=oddt -n 2 -v -s --durations=0 tests/
    - oddt_cli --help
    - oddt_cli tests/data/dude/xiap/crystal_ligand.sdf -osmi
    - oddt_cli tests/data/dude/xiap/actives_docked.sdf --similarity ifp --query tests/data/dude/xiap/crystal_ligand.sdf --cutoff 0.9 --receptor tests/data/dude/xiap/receptor_rdkit.pdb -ocsv
    - oddt_cli tests/data/dude/xiap/actives_docked.sdf --similarity sifp --query tests/data/dude/xiap/crystal_ligand.sdf --cutoff 0.9 --receptor tests/data/dude/xiap/receptor_rdkit.pdb -ocsv
    - oddt_cli tests/data/dude/xiap/actives_docked.sdf --similarity usr --query tests/data/dude/xiap/crystal_ligand.sdf --cutoff 0.3 -ocsv
    - oddt_cli tests/data/dude/xiap/actives_docked.sdf --similarity usr_cat --query tests/data/dude/xiap/crystal_ligand.sdf --cutoff 0.3 -ocsv
    - oddt_cli tests/data/dude/xiap/actives_docked.sdf --similarity electroshape --query tests/data/dude/xiap/crystal_ligand.sdf --cutoff 0.3 -ocsv
    - oddt_cli tests/data/dude/xiap/actives_docked.sdf --score pleclinear --receptor tests/data/dude/xiap/receptor_rdkit.pdb -ocsv

after_success:
    - coveralls
