Skip to content

Commit

Permalink
moving tests/ somewhere standard. adding TravisCI'
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathon Belotti committed Apr 22, 2017
1 parent 97e6c0f commit 7d6dbca
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
*.pydevproject
*.kpf
venv
build/
dist/

# Ignore data files
data/
Expand All @@ -18,6 +20,10 @@ snoopsnoo/

# Ignore my virtualenv environment
env2.7/
virtual_env/

# Ignore egg-info
*egg-info/

# Ignore the Stanford CoreNLP Folder (+500 mb)
stanford-corenlp-full*/
Expand Down
10 changes: 10 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
language: python
python:
- "3.5"
install:
- pip install -r requirements.txt
branches:
only: [master]
# command to run tests
script:
- nosetests
31 changes: 31 additions & 0 deletions install_package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash -e
# Create or replace the app's python virtual environment and installs all the packages required for the app.
#
# Usage:
#
# ./install_package.sh


script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
VIRTUAL_ENV_PATH="${VIRTUAL_ENV_PATH:=${script_dir}/virtual_env}"

requirements_pip_file="${REQUIREMENTS_PIP_FILE:-requirements.txt}"

# Create or replace python virtual environment
echo "Creating/Replacing VirtualEnv"
rm -rf $VIRTUAL_ENV_PATH
mkdir -p "${VIRTUAL_ENV_PATH}" 2>/dev/null

if PYTHON3_PATH=$(which python3); then
virtualenv --python=$PYTHON3_PATH $VIRTUAL_ENV_PATH
else
echo "Could not find Python 3 on system. Please install it."
exit 1
fi

# Install the package and its dependencies
echo "Installing pip requirement file: ${requirements_pip_file}"
./run_in_venv.sh pip install -r "${requirements_pip_file}"

echo "Setup.py Installing"
./run_in_venv.sh python setup.py install
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
nose
pytest
29 changes: 29 additions & 0 deletions run_in_venv.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

# Runs any command in the application's python virtual environment. This script assumes
# the environment has been installed using install_miniconda.sh and
# install_app.sh.
#
# Usage:
# ./run_in_environment.sh python setup.py test
#
# You can also use it to activate the virtual environment, e.g.:
# source run_in_environment.sh
script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

VIRTUAL_ENV_PATH="${VIRTUAL_ENV_PATH:=${script_dir}/virtual_env}"
ACTIVATE_FILE="${VIRTUAL_ENV_PATH}/bin/activate"

# Get out of currently activate venvs, if any
if [[ $VIRTUAL_ENV ]]; then
deactivate 2> /dev/null
fi

if [ -f $ACTIVATE_FILE ]; then
source $ACTIVATE_FILE
exec "$@"
else
echo "Error: the file $ACTIVATE_FILE does not exist. Please install the environment correctly."
# Only exit if you're not in an interactive session
if [[ $- != *"i"* ]] ; then exit 1 ; fi
fi
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 7d6dbca

Please sign in to comment.