<commit_before>language: generic

sudo: false

matrix:
  fast_finish: true
  include:
    - os: linux
      env: TEST_TARGET=coding_standards ENV_NAME="IOOS3" ENV="environment.yml"
    - os: linux
      env: TEST_TARGET=notebooks_python3 ENV_NAME="IOOS3" ENV="environment.yml"
    - os: linux
      env: TEST_TARGET=notebooks_python2 ENV_NAME="IOOS2" ENV="environment-python-2.yml"
    - os: linux
      env: TEST_TARGET=staged_notebooks ENV_NAME="IOOS3" ENV="environment.yml"
    - os: linux
      env: TEST_TARGET=publish ENV_NAME="IOOS3" ENV="environment.yml"
    - os: osx
      env: TEST_TARGET=notebooks_python3 ENV_NAME="IOOS3" ENV="environment.yml"
  allow_failures:
    - os: linux
      env: TEST_TARGET=staged_notebooks ENV_NAME="IOOS3" ENV="environment.yml"
    - os: osx
      env: TEST_TARGET=notebooks_python3 ENV_NAME="IOOS3" ENV="environment.yml"

before_install:
  - if [ $TRAVIS_PULL_REQUEST == 'false' ]; then
      openssl aes-256-cbc -K $encrypted_2ed57bb9ae7e_key -iv $encrypted_2ed57bb9ae7e_iv -in deploy_key.enc -out deploy_key -d ;
    fi
  - if [ "$TRAVIS_OS_NAME" == "osx" ]; then URL="https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh" ; fi
  - if [ "$TRAVIS_OS_NAME" == "linux" ]; then URL="https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh" ; fi
  # GUI (R png figures).
  - if [ "$TRAVIS_OS_NAME" == "linux" ]; then export DISPLAY=:99.0 ; sh -e /etc/init.d/xvfb start ; fi
  - wget $URL -O miniconda.sh
  - bash miniconda.sh -b -p $HOME/miniconda
  - export PATH="$HOME/miniconda/bin:$PATH"
  - hash -r
  - conda config --set always_yes yes --set changeps1 no
  - conda update --quiet conda

install:
  - conda env create --quiet --file "$ENV"
  - source activate "$ENV_NAME"

  # Debug.
  - conda info -a
  - conda list

script:
  # Default test is mostly codding standards.
  # The notebook PEP 8 test ignore:
  # W391: blank line at end of file (always present when using nbconvert)
  # E226: missing whitespace around arithmetic operator (not enforced by PEP 8)
  # E402: module level import not at top of file (in notebooks it is clearer to import in the first cell the module is used.)
  # In addition the magic cells are skipped with `grep -v '^get_ipython'` b/c they are not compliant when converted to script.
  - if [ $TEST_TARGET == 'coding_standards' ]; then
      find . -type f -name "*.py" ! -name "conf.py" | xargs flake8 --max-line-length=100 ;
      for file in $(find . -type f -name "*.ipynb" ! -name "2017-01-23-R-notebook.ipynb" ); do jupyter nbconvert --template=tests/strip_markdown.tpl --stdout --to python $file | grep -v '^get_ipython' | flake8 - --ignore=W391,E226,E402 --max-line-length=100 --show-source ; done ;
    fi
  # Test the blog notebook.
  - if [ $TEST_TARGET == 'notebooks_python3' ]; then
      cd tests && python test_notebooks.py ;
    fi
  - if [ $TEST_TARGET == 'notebooks_python2' ]; then
      cd tests && python test_notebooks.py ;
    fi
  # Test the staged notebooks.
  - if [ $TEST_TARGET == 'staged_notebooks' ]; then
      cd tests && python test_staged_notebooks.py ;
    fi
  # Publish the notebooks.
  - if [ $TEST_TARGET == 'publish' ]; then
      cd webpage && python make_index.py && cd ..;
      find notebooks/ -maxdepth 1 -name \*.ipynb -print0 | xargs -0 -n1 jupyter nbconvert --to=markdown --template="jupyter-jekyll.tpl" --output-dir=webpage/_notebooks ;
      bash webpage/deploy.sh ;
    fi<commit_msg>cache Travis-CI<commit_after>language: generic

sudo: false

cache:
  directories:
    - $HOME/miniconda

# Removing the directory will remove the env but leave the cached packages
# at $HOME/miniconda/pkgs. That is a win-win because when re-creating the
# env we will download only the new packages.
before_cache:
  - rm -rf $HOME/miniconda/envs/IOOS

# All but one of the tests are executed with the Python 3 env.
env:
  global:
    - ENV: environment.yml

matrix:
  fast_finish: true
  include:
    - os: linux
      env: TEST_TARGET=notebooks_python2 ENV="environment-python-2.yml"
    - os: linux
      env: TEST_TARGET=notebooks_python3
    - os: linux
      env: TEST_TARGET=coding_standards
    - os: linux
      env: TEST_TARGET=staged_notebooks
    - os: linux
      env: TEST_TARGET=publish
    - os: osx
      env: TEST_TARGET=notebooks_python3
  allow_failures:
    - os: linux
      env: TEST_TARGET=staged_notebooks
    - os: osx
      env: TEST_TARGET=notebooks_python3

before_install:
  - |
    if [ "$TRAVIS_OS_NAME" == "osx" ]; then
      URL="https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh"
    elif [ "$TRAVIS_OS_NAME" == "linux" ] ; then
      URL="https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh"
    fi
    echo ""
    if [ ! -f $HOME/miniconda/bin/conda ] ; then
      echo "Fresh miniconda installation."
      wget $URL -O miniconda.sh
      rm -rf $HOME/miniconda
      bash miniconda.sh -b -p $HOME/miniconda
    fi
    export PATH="$HOME/miniconda/bin:$PATH"
    conda config --set always_yes yes --set changeps1 no --set show_channel_urls true
    conda update conda

  # GUI (R png figures).
  - if [ "$TRAVIS_OS_NAME" == "linux" ]; then export DISPLAY=:99.0 ; sh -e /etc/init.d/xvfb start ; fi

  ## Pages deploy_key.
  #- if [ $TRAVIS_PULL_REQUEST == "false" ]; then
      #openssl aes-256-cbc -K $encrypted_2ed57bb9ae7e_key -iv $encrypted_2ed57bb9ae7e_iv -in deploy_key.enc -out deploy_key -d ;
    #fi

install:
  - conda env create --file "$ENV" --name IOOS
  - source activate IOOS

  # Debug.
  - conda info --all
  - conda list

script:
  # Default test is mostly coding standards.
  # The notebook PEP 8 test ignore:
  # W391: blank line at end of file (always present when using nbconvert)
  # E226: missing whitespace around arithmetic operator (not enforced by PEP 8)
  # E402: module level import not at top of file (in notebooks it is clearer to import in the first cell the module is used.)
  # In addition the magic cells are skipped with `grep -v "^get_ipython"` b/c they are not compliant when converted to script.
  - if [ $TEST_TARGET == "coding_standards" ]; then
      find . -type f -name "*.py" ! -name "conf.py" | xargs flake8 --max-line-length=100 ;
      for file in $(find . -type f -name "*.ipynb" ! -name "2017-01-23-R-notebook.ipynb" ); do jupyter nbconvert --template=tests/strip_markdown.tpl --stdout --to python $file | grep -v "^get_ipython" | flake8 - --ignore=W391,E226,E402 --max-line-length=100 --show-source ; done ;
    fi

  # Test notebooks on Python 3.
  - if [ $TEST_TARGET == "notebooks_python3" ]; then
      cd tests && python test_notebooks.py ;
    fi

  # Test notebooks on Python 2.
  - if [ $TEST_TARGET == "notebooks_python2" ]; then
      cd tests && python test_notebooks.py ;
    fi

  # Test staged notebooks.
  - if [ $TEST_TARGET == "staged_notebooks" ]; then
      cd tests && python test_staged_notebooks.py ;
    fi

  # Publish the notebooks.
  - if [ $TEST_TARGET == "publish" ]; then
      cd webpage && python make_index.py && cd ..;
      find notebooks/ -maxdepth 1 -name \*.ipynb -print0 | xargs -0 -n1 jupyter nbconvert --to=markdown --template="jupyter-jekyll.tpl" --output-dir=webpage/_notebooks ;
      bash webpage/deploy.sh ;
    fi
{'fraction_non_alphanumeric': 0.12116182572614108, 'fraction_numerical': 0.02199170124481328, 'mean_word_length': 3.019455252918288, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '165405', 'n_tokens_mistral': 2729, 'n_tokens_neox': 2581, 'n_words': 715}