2014-04-03 00:32:41 +02:00
|
|
|
#!/bin/bash
|
2014-04-01 22:17:03 +02:00
|
|
|
#
|
|
|
|
# this is the script run by the Jenkins server to run the build and tests. Be
|
|
|
|
# sure to always run it in its dir, i.e. ./jenkins-build.sh, otherwise it might
|
|
|
|
# remove things that you don't want it to.
|
|
|
|
|
|
|
|
if [ `dirname $0` != "." ]; then
|
|
|
|
echo "only run this script like ./`basename $0`"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
set -e
|
|
|
|
set -x
|
|
|
|
|
|
|
|
if [ -z $WORKSPACE ]; then
|
|
|
|
export WORKSPACE=`pwd`
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z $ANDROID_HOME ]; then
|
|
|
|
if [ -e ~/.android/bashrc ]; then
|
|
|
|
. ~/.android/bashrc
|
|
|
|
else
|
|
|
|
echo "ANDROID_HOME must be set!"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2014-04-14 22:12:17 +02:00
|
|
|
|
|
|
|
#------------------------------------------------------------------------------#
|
|
|
|
# cache pypi downloads
|
|
|
|
if [ -z $PIP_DOWNLOAD_CACHE ]; then
|
|
|
|
export PIP_DOWNLOAD_CACHE=$HOME/.pip_download_cache
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2014-04-01 22:17:03 +02:00
|
|
|
#------------------------------------------------------------------------------#
|
|
|
|
# required Java 7 keytool/jarsigner for :file support
|
|
|
|
|
|
|
|
export PATH=/usr/lib/jvm/java-7-openjdk-amd64/bin:$PATH
|
|
|
|
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------#
|
2014-08-30 19:47:12 +02:00
|
|
|
# run local tests, don't scan fdroidserver/ project for APKs
|
2015-03-11 22:40:26 +01:00
|
|
|
|
|
|
|
# this is a local repo on the Guardian Project Jenkins server
|
|
|
|
apksource=/var/www/fdroid
|
|
|
|
|
2014-04-01 22:17:03 +02:00
|
|
|
cd $WORKSPACE/tests
|
2015-03-11 22:40:26 +01:00
|
|
|
./run-tests $apksource
|
2014-04-01 22:17:03 +02:00
|
|
|
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------#
|
|
|
|
# test building the source tarball
|
|
|
|
cd $WORKSPACE
|
2014-06-30 17:31:38 +02:00
|
|
|
python2 setup.py sdist
|
2014-04-01 22:17:03 +02:00
|
|
|
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------#
|
|
|
|
# test install using site packages
|
|
|
|
cd $WORKSPACE
|
|
|
|
rm -rf $WORKSPACE/env
|
2014-06-30 17:31:38 +02:00
|
|
|
virtualenv --python=python2 --system-site-packages $WORKSPACE/env
|
2014-04-01 22:17:03 +02:00
|
|
|
. $WORKSPACE/env/bin/activate
|
|
|
|
pip install -e $WORKSPACE
|
2014-06-30 17:31:38 +02:00
|
|
|
python2 setup.py install
|
2014-04-01 22:17:03 +02:00
|
|
|
|
|
|
|
# run tests in new pip+virtualenv install
|
|
|
|
. $WORKSPACE/env/bin/activate
|
2015-03-11 22:40:26 +01:00
|
|
|
fdroid=$WORKSPACE/env/bin/fdroid $WORKSPACE/tests/run-tests $apksource
|
2014-04-01 22:17:03 +02:00
|
|
|
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------#
|
2014-06-02 19:24:24 +02:00
|
|
|
# run git pre-commit hook for pep8, pyflakes, etc
|
|
|
|
sh hooks/pre-commit
|
2014-04-01 22:17:03 +02:00
|
|
|
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------#
|
|
|
|
# run pylint
|
|
|
|
|
|
|
|
cd $WORKSPACE
|
|
|
|
set +e
|
2014-04-03 01:52:47 +02:00
|
|
|
# use the virtualenv python so pylint checks against its installed libs
|
2014-06-30 17:31:38 +02:00
|
|
|
PYTHONPATH=$WORKSPACE/.pylint-plugins python2 /usr/bin/pylint \
|
2014-04-03 01:53:53 +02:00
|
|
|
--output-format=parseable --reports=n \
|
|
|
|
--load-plugins astng_hashlib \
|
|
|
|
fdroidserver/*.py fdroid makebuildserver setup.py > $WORKSPACE/pylint.parseable
|
2014-04-01 22:17:03 +02:00
|
|
|
|
|
|
|
# to only tell jenkins there was an error if we got ERROR or FATAL, uncomment these:
|
2014-04-03 17:54:08 +02:00
|
|
|
# running pylint in the virtualenv is causing this FATAL error, which is a bug:
|
|
|
|
# https://bitbucket.org/logilab/pylint/issue/73/pylint-is-unable-to-import
|
2014-04-03 01:52:47 +02:00
|
|
|
[ $(($? & 1)) = "1" ] && echo "FATALs found"
|
2014-04-03 17:54:08 +02:00
|
|
|
[ $(($? & 2)) = "2" ] && exit 2
|
|
|
|
[ $(($? & 4)) = "4" ] && exit 4
|
2014-04-01 22:17:03 +02:00
|
|
|
set -e
|
|
|
|
|