# This script should be called from within Hudson

cd $WORKSPACE
VENV=$WORKSPACE/venv

echo "Starting build..."

# Update submodules
git submodule update --init

# Make sure there's no old pyc files around.
find . -name '*.pyc' | xargs rm

if [ ! -d "$VENV/bin" ]; then
  echo "No virtualenv found.  Making one..."
  virtualenv --no-site-packages $VENV
fi

source $VENV/bin/activate

pip install -q -r requirements.txt

cat > settings_local.py <<SETTINGS
from settings import *
ROOT_URLCONF = 'workspace.urls'
SETTINGS

echo "Starting tests..."
export FORCE_DB='yes sir'
coverage run manage.py test --noinput --logging-clear-handlers --with-xunit
coverage xml $(find apps lib -name '*.py')

echo "Building documentation..."
cd docs
make clean dirhtml SPHINXOPTS='-q'
cd $WORKSPACE

echo "Taking forever to make a bundle..."
PKG=$WORKSPACE/packages
export PIP_DOWNLOAD_CACHE=$PKG/pip-cache
rm -rf $PKG && mkdir $PKG && pip -q bundle -r requirements-prod.txt $PKG/amo.pybundle

echo 'shazam!'

# This script should be called from within Hudson

cd $WORKSPACE
VENV=$WORKSPACE/venv

echo "Starting build..."

# Make sure there's no old pyc files around.
find . -name '*.pyc' | xargs rm

if [ ! -d "$VENV/bin" ]; then
  echo "No virtualenv found.  Making one..."
  virtualenv --no-site-packages $VENV
fi

source $VENV/bin/activate

pip install -q -r requirements.txt

cat > settings_local.py <<SETTINGS
from settings import *
ROOT_URLCONF = 'workspace.urls'
SETTINGS

echo "Starting tests..."
export FORCE_DB='yes sir'
coverage run manage.py test --noinput --logging-clear-handlers --with-xunit
coverage xml $(find apps lib -name '*.py')

echo "Building documentation..."
cd docs
make clean dirhtml SPHINXOPTS='-q'
cd $WORKSPACE

echo "Taking forever to make a bundle..."
PKG=$WORKSPACE/packages
export PIP_DOWNLOAD_CACHE=$PKG/pip-cache
rm -rf $PKG && mkdir $PKG && pip -q bundle -r requirements-prod.txt $PKG/amo.pybundle

echo 'shazam!'

Revert "update submodules before running tests"
Revert "update submodules before running tests"

This reverts commit 4a4a3a60b0eb67440c88c75fec4a8bd8bf2b413c.
