2015-09-01 12:28:58 +02:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# this is the script run by the Jenkins and gitlab-ci continuous integration
|
|
|
|
# build services. It is a thorough set of tests that runs all the tests using
|
|
|
|
# the various methods of installing/running fdroidserver. It is separate from
|
|
|
|
# ./tests/run-tests because its too heavy for manual use.
|
|
|
|
|
|
|
|
if [ `dirname $0` != "." ]; then
|
|
|
|
echo "only run this script like ./`basename $0`"
|
2016-02-15 11:40:35 +01:00
|
|
|
exit 1
|
2015-09-01 12:28:58 +02:00
|
|
|
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!"
|
2016-02-15 11:40:35 +01:00
|
|
|
exit 1
|
2015-09-01 12:28:58 +02:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
apksource=$1
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------#
|
|
|
|
# cache pypi downloads
|
|
|
|
if [ -z $PIP_DOWNLOAD_CACHE ]; then
|
|
|
|
export PIP_DOWNLOAD_CACHE=$HOME/.pip_download_cache
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------#
|
|
|
|
# required Java 7 keytool/jarsigner for :file support
|
|
|
|
|
|
|
|
export PATH=/usr/lib/jvm/java-7-openjdk-amd64/bin:$PATH
|
|
|
|
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------#
|
|
|
|
# run local tests, don't scan fdroidserver/ project for APKs
|
|
|
|
|
|
|
|
cd $WORKSPACE/tests
|
|
|
|
./run-tests $apksource
|
|
|
|
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------#
|
|
|
|
# test building the source tarball, then installing it
|
|
|
|
cd $WORKSPACE
|
2016-01-04 21:17:58 +01:00
|
|
|
python3 setup.py sdist
|
2015-09-01 12:28:58 +02:00
|
|
|
|
|
|
|
rm -rf $WORKSPACE/env
|
2016-04-06 19:46:21 +02:00
|
|
|
pyvenv $WORKSPACE/env
|
2015-09-01 12:28:58 +02:00
|
|
|
. $WORKSPACE/env/bin/activate
|
2016-04-06 19:46:21 +02:00
|
|
|
pip3 install dist/fdroidserver-*.tar.gz
|
2015-09-01 12:28:58 +02:00
|
|
|
|
2016-04-06 19:46:21 +02:00
|
|
|
# run tests in new pip+pyvenv install
|
2015-09-01 12:28:58 +02:00
|
|
|
fdroid=$WORKSPACE/env/bin/fdroid $WORKSPACE/tests/run-tests $apksource
|
|
|
|
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------#
|
|
|
|
# test install using install direct from git repo
|
|
|
|
cd $WORKSPACE
|
|
|
|
rm -rf $WORKSPACE/env
|
tests: `pyvenv --system-site-packages` is too buggy on python 3.4
It always wants to install packages into /usr/lib/python3.4/site-packages
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/pip/basecommand.py", line 122, in main
status = self.run(options, args)
File "/usr/lib/python3/dist-packages/pip/commands/install.py", line 295, in run
requirement_set.install(install_options, global_options, root=options.root_path)
File "/usr/lib/python3/dist-packages/pip/req.py", line 1436, in install
requirement.install(install_options, global_options, *args, **kwargs)
File "/usr/lib/python3/dist-packages/pip/req.py", line 672, in install
self.move_wheel_files(self.source_dir, root=root)
File "/usr/lib/python3/dist-packages/pip/req.py", line 902, in move_wheel_files
pycompile=self.pycompile,
File "/usr/lib/python3/dist-packages/pip/wheel.py", line 214, in move_wheel_files
clobber(source, lib_dir, True)
File "/usr/lib/python3/dist-packages/pip/wheel.py", line 176, in clobber
os.makedirs(dest)
File "/usr/lib/python3.4/os.py", line 237, in makedirs
mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/usr/lib/python3.4/site-packages'
2016-06-14 22:40:50 +02:00
|
|
|
pyvenv $WORKSPACE/env
|
2015-09-01 12:28:58 +02:00
|
|
|
. $WORKSPACE/env/bin/activate
|
2016-04-06 19:46:21 +02:00
|
|
|
pip3 install -e $WORKSPACE
|
2016-01-04 21:17:58 +01:00
|
|
|
python3 setup.py install
|
2015-09-01 12:28:58 +02:00
|
|
|
|
2016-04-06 19:46:21 +02:00
|
|
|
# run tests in new pip+pyvenv install
|
2015-09-01 12:28:58 +02:00
|
|
|
fdroid=$WORKSPACE/env/bin/fdroid $WORKSPACE/tests/run-tests $apksource
|
|
|
|
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------#
|
|
|
|
# run git pre-commit hook for pep8, pyflakes, etc
|
|
|
|
sh hooks/pre-commit
|
|
|
|
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------#
|
|
|
|
# run pylint
|
|
|
|
|
|
|
|
cd $WORKSPACE
|
|
|
|
set +e
|
2016-04-06 19:46:21 +02:00
|
|
|
# use the pyvenv so pylint checks against its installed libs
|
2016-01-04 21:17:58 +01:00
|
|
|
PYTHONPATH=$WORKSPACE/.pylint-plugins python3 /usr/bin/pylint \
|
2015-09-01 12:28:58 +02:00
|
|
|
--output-format=parseable --reports=n \
|
|
|
|
--load-plugins astng_hashlib \
|
|
|
|
fdroidserver/*.py fdroid makebuildserver setup.py > $WORKSPACE/pylint.parseable
|
|
|
|
|
|
|
|
# to only tell jenkins there was an error if we got ERROR or FATAL, uncomment these:
|
2016-04-06 19:46:21 +02:00
|
|
|
# running pylint in the pyvenv/virtualenv is causing this FATAL error, which is a bug:
|
2015-09-01 12:28:58 +02:00
|
|
|
# https://bitbucket.org/logilab/pylint/issue/73/pylint-is-unable-to-import
|
|
|
|
[ $(($? & 1)) = "1" ] && echo "FATALs found"
|
|
|
|
[ $(($? & 2)) = "2" ] && exit 2
|
|
|
|
[ $(($? & 4)) = "4" ] && exit 4
|
|
|
|
set -e
|
|
|
|
|