From charlesreid1

Revision as of 07:00, 13 November 2017 by Admin (talk | contribs) (→‎Output)

This page covers notes on running local Travis tests (replicating the Travis environment on your local machine).

Guide here: https://github.com/erdc/proteus/wiki/Replicating-the-TravisCI-Environment-on-your-Local-Machine

Setup

Docker Pull

The Travis environment can be replicated with a Docker image. The docker image is travisci/ci-garnet and there is no latest tag.

Go to this page: https://hub.docker.com/r/travisci/ci-garnet/tags/

Click the "Tags" tab

Do a docker pull like this:

docker pull travisci/ci-garnet:packer-1510529493-6aa37a4

where the packer part comes from the latest tag.

Run the Travis Container

Run the container and have it execute the bash shell:

docker run -it travisci/ci-garnet:packer-1510529493-6aa37a4 /bin/bash

Use Travis.yml

To get the container set up before you run your tests, run the commands contained in the travis.yml script in the repository you're trying to run tests for.

Let's look at a sample travis.yml: https://github.com/soft-matter/trackpy/blob/master/.travis.yml

We have to run these commands to set up the conda environment:

Before we install anything:

if [ ${TRAVIS_PYTHON_VERSION:0:1} == "2" ]; then 
    wget http://repo.continuum.io/miniconda/Miniconda-3.5.5-Linux-x86_64.sh -O miniconda.sh; 
else 
    wget http://repo.continuum.io/miniconda/Miniconda3-3.5.5-Linux-x86_64.sh -O miniconda.sh; 
fi
chmod +x miniconda.sh
./miniconda.sh -b -p /home/travis/mc
export PATH=/home/travis/mc/bin:$PATH

To install stuff:

DEPS="numpy scipy matplotlib pillow pandas!=0.18.0 scikit-image pyyaml pytables numba scikit-learn"  BUILD_DOCS=false
conda update --yes conda
conda config --append channels conda-forge
conda create -n testenv --yes $DEPS pip nose setuptools python=$TRAVIS_PYTHON_VERSION
source activate testenv

# This is not necessary, it just outputs useful info to log for Travis CI:
echo $PATH
which python
conda info
conda list

# Back to required stuff:
python setup.py install

Now for the actual tests:

nosetests --nologcapture -a '!slow'

Output

root@025e1ca5221b:/# wget http://repo.continuum.io/miniconda/Miniconda-3.5.5-Linux-x86_64.sh -O miniconda.sh
[...]

root@025e1ca5221b:/# ./miniconda.sh -b -p /home/travis/mc
PREFIX=/home/travis/mc
installing: python-2.7.7-0 ...
installing: openssl-1.0.1h-0 ...
installing: pycosat-0.6.1-py27_0 ...
installing: pyyaml-3.11-py27_0 ...
installing: readline-6.2-2 ...
installing: requests-2.3.0-py27_0 ...
installing: sqlite-3.8.4.1-0 ...
installing: system-5.8-1 ...
installing: tk-8.5.15-0 ...
installing: yaml-0.1.4-0 ...
installing: zlib-1.2.7-0 ...
installing: conda-3.5.5-py27_0 ...
Python 2.7.7 :: Continuum Analytics, Inc.
creating default environment...
installation finished.

root@025e1ca5221b:/# conda update --yes conda

root@025e1ca5221b:/# conda config --append channels conda-forge

root@025e1ca5221b:/# export PATH=/home/travis/mc/bin:$PATH

root@025e1ca5221b:/# export TRAVIS_PYTHON_VERSION="3.6"

root@025e1ca5221b:/# conda create -n testenv --yes $DEPS pip nose setuptools python=$TRAVIS_PYTHON_VERSION