# After changing this file, check it on:
# http://lint.travis-ci.org/
sudo: false
cache:
  directories:
    - $HOME/.cache/pip
    - $HOME/.theano
    - $HOME/download # Sufficient to add miniconda.sh to TRAVIS cache.
    - $HOME/miniconda2 # Add the installation to TRAVIS cache.


language: python
# For now, Python versions have to be listed in the "jobs" matrix

# NB:
# In before_install and install sections below,
# some codes have been moved to separate files
# to better handle if-else shell syntax
# for multiple lines. New files are in
# new folder ".travis".

# command to install dependencies
before_install:
  - ./.travis/travis_before_install.sh
  - export PATH=/home/travis/miniconda2/bin:$PATH

addons:
  apt_packages:
   - texlive-latex-recommended
   - texlive-latex-extra
   - texlive-fonts-recommended
   - dvipng

install:
  - ./.travis/travis_install.sh
  - source activate pyenv
  - if [[ $TRAVIS_PYTHON_VERSION == '2.7' ]]; then pip install pydot; else pip install pydot-ng; fi
  - pip install . --no-deps --upgrade
  - pip install flake8-future-import parameterized sphinx_rtd_theme
  # nose-exclude plugin allow us to tell nosetests to exclude folder with --exclude-dir=path/to/directory.
  - pip install nose-exclude nose-timer
  - conda install --yes -q scipy=0.14.0  # Try to reinstall it to fix the problem

jobs:
  include:
    # define prototype for doctest
    - &doctest
      stage: doc
      python: "2.7"
      env: DOC=1 PART="theano/tests/test_flake8.py"
    # re-use prototype, changing the Python version
    - <<: *doctest
      python: "3.4"
    - &normaltest
      stage: test
      python: "2.7"
      env: PART="theano/compat theano/compile theano/d3viz theano/gof theano/misc theano/sandbox theano/scalar theano/scan_module theano/tests -e test_flake8.py theano/typed_list"
    - <<: *normaltest
      python: "3.4"
      env: PART="theano/compat theano/compile theano/d3viz theano/gof theano/misc theano/sandbox theano/scalar theano/scan_module theano/tests -e test_flake8.py theano/typed_list"
    - <<: *normaltest
      env: PART="theano/sparse theano/tensor --exclude-test=theano.tensor.tests.test_basic --exclude-test=theano.tensor.tests.test_elemwise --exclude-test=theano.tensor.tests.test_opt --exclude-dir=theano/tensor/nnet"
    - <<: *normaltest
      python: "3.4"
      env: PART="theano/sparse theano/tensor --exclude-test=theano.tensor.tests.test_basic --exclude-test=theano.tensor.tests.test_elemwise --exclude-test=theano.tensor.tests.test_opt --exclude-dir=theano/tensor/nnet"
    - <<: *normaltest
      env: PART="theano/tensor/tests/test_basic.py"
    - <<: *normaltest
      python: "3.4"
      env: PART="theano/tensor/tests/test_basic.py"
    - <<: *normaltest
      env: PART="theano/tensor/tests/test_elemwise.py theano/tensor/tests/test_opt.py"
    - <<: *normaltest
      python: "3.4"
      env: PART="theano/tensor/tests/test_elemwise.py theano/tensor/tests/test_opt.py"
    - <<: *normaltest
      env: PART="theano/tensor/nnet -e test_abstract_conv.py"
    - <<: *normaltest
      python: "3.4"
      env: PART="theano/tensor/nnet -e test_abstract_conv.py"
    - <<: *normaltest
      env: PART="theano/tensor/nnet/tests/test_abstract_conv.py"
    - <<: *normaltest
      python: "3.4"
      env: PART="theano/tensor/nnet/tests/test_abstract_conv.py"
    - <<: *normaltest
      env: FAST_COMPILE=1 FLOAT32=1 PART="theano -e test_flake8.py --exclude-dir=theano/tensor/nnet --exclude-dir=theano/tensor/signal"
    - <<: *normaltest
      python: "3.4"
      env: FAST_COMPILE=1 PART="theano -e test_flake8.py --exclude-dir=theano/tensor/nnet --exclude-dir=theano/tensor/signal"
    - <<: *normaltest
      env: FAST_COMPILE=1 FLOAT32=1 PART="theano/tensor/nnet"
    - <<: *normaltest
      python: "3.4"
      env: FAST_COMPILE=1 PART="theano/tensor/nnet"
    - <<: *normaltest
      env: FAST_COMPILE=1 FLOAT32=1 PART="theano/tensor/signal"
    - <<: *normaltest
      python: "3.4"
      env: FAST_COMPILE=1 PART="theano/tensor/signal"

script:
  - if [[ $FAST_COMPILE == "1" ]]; then export THEANO_FLAGS=$THEANO_FLAGS,mode=FAST_COMPILE; fi
  - if [[ $FLOAT32 == "1" ]]; then export THEANO_FLAGS=$THEANO_FLAGS,floatX=float32; fi
  - export THEANO_FLAGS=$THEANO_FLAGS,warn.ignore_bug_before=all,on_opt_error=raise,on_shape_error=raise,gcc.cxxflags=-pipe
  - export MKL_NUM_THREADS=1
  - export OMP_NUM_THREADS=1
  - python --version
  - uname -a
  - free -m
  - df -h
  - ulimit -a
  - echo "$PART"
# Print information to help debug problems
  - python -c 'import theano; print(theano.__version__)'
  - python -c 'import theano; print(theano.config.__str__(print_doc=False))'
  - python -c 'import theano; assert(theano.config.blas.ldflags != "")'
# Run tests for the given part
  - theano-nose -v --with-timer --timer-top-n 10 $PART
  - if [[ $DOC == "1" ]]; then python doc/scripts/docgen.py --nopdf --check; fi
  - if [[ $DOC == "1" ]]; then python doc/scripts/docgen.py --test --check; fi

after_failure:
  - cat /home/travis/.pip/pip.log
