# After changing this file, check it on:
# http://lint.travis-ci.org/
os: linux
dist: xenial
cache:
  directories:
    - $HOME/.cache/pip
    - $HOME/.theano
    - $HOME/download
    - $HOME/miniconda

language: python

python:
  - "3.7"
  - "3.6"

stages:
  - lint
  # - doc
  - test

env:
  global:
    - NUMPY_VERSION=1.18.1
  jobs:
    - PART="theano/compat theano/compile theano/d3viz theano/gof theano/misc theano/sandbox theano/scalar theano/scan_module theano/tests theano/typed_list"
    - PART="theano/sparse theano/tensor --ignore=theano/tensor/tests/test_basic.py --ignore=theano/tensor/tests/test_elemwise.py --ignore=theano/tensor/tests/test_opt.py --ignore=theano/tensor/nnet"
    - PART="theano/tensor/tests/test_basic.py"
    - PART="theano/tensor/tests/test_elemwise.py theano/tensor/tests/test_opt.py"
    - PART="theano/tensor/nnet --ignore-glob='*/test_abstract_conv.py'"
    - PART="theano/tensor/nnet/tests/test_abstract_conv.py"

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

before_install:
  - source .travis/travis_before_install.sh

install:
  - source .travis/travis_install.sh

jobs:
  include:
    - stage: lint
      script:
        - pip install black
        - black --check theano/ setup.py
        - flake8 theano/ setup.py
    # - &doctest
    #   stage: doc
    #   env: DOC=1
    - &normaltest
      stage: test
      env: FAST_COMPILE=1 FLOAT32=1 PART="theano --ignore=theano/tensor/nnet --ignore=theano/tensor/signal"
    - <<: *normaltest
      env: FAST_COMPILE=1 PART="theano --ignore=theano/tensor/nnet --ignore=theano/tensor/signal"
    - <<: *normaltest
      env: FAST_COMPILE=1 FLOAT32=1 PART="theano/tensor/nnet"
    - <<: *normaltest
      env: FAST_COMPILE=1 PART="theano/tensor/nnet"
    - <<: *normaltest
      env: FAST_COMPILE=1 FLOAT32=1 PART="theano/tensor/signal"
    - <<: *normaltest
      env: FAST_COMPILE=1 PART="theano/tensor/signal"

script:
  - conda activate pyenv
  - 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_THREADING_LAYER=GNU
  - export MKL_NUM_THREADS=1
  - export OMP_NUM_THREADS=1
  - which python
  - python --version
  - uname -a
  - free -m
  - df -h
  - ulimit -a
  - echo "$PART"
  # Print information to help debug problems
  - python -c 'import numpy; print(numpy.__version__)'
  - 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 != "")'
  - pytest -r A --verbose --runslow $PART

after_failure:
  - cat $HOME/.pip/pip.log
