chiark / gitweb /
bd7e736698ff2a5ef1a4393b22a6cbee3eb32846
[fdroidserver.git] / tests / complete-ci-tests
1 #!/bin/bash
2 #
3 # this is the script run by the Jenkins and gitlab-ci continuous integration
4 # build services.  It is a thorough set of tests that runs all the tests using
5 # the various methods of installing/running fdroidserver.  It is separate from
6 # ./tests/run-tests because its too heavy for manual use.
7
8 if [ `dirname $0` != "." ]; then
9     echo "only run this script like ./`basename $0`"
10     exit 1
11 fi
12
13 set -e
14 set -x
15
16 if [ -z $WORKSPACE ]; then
17     export WORKSPACE=`pwd`/..
18 fi
19
20 if [ -z $ANDROID_HOME ]; then
21     if [ -e ~/.android/bashrc ]; then
22         . ~/.android/bashrc
23     else
24         echo "ANDROID_HOME must be set!"
25         exit 1
26     fi
27 fi
28
29 apksource=$1
30
31 #------------------------------------------------------------------------------#
32 # cache pypi downloads
33 if [ -z $PIP_DOWNLOAD_CACHE ]; then
34     export PIP_DOWNLOAD_CACHE=$HOME/.pip_download_cache
35 fi
36
37
38 #------------------------------------------------------------------------------#
39 # required Java 7 or later keytool/jarsigner for :file support
40
41 export PATH=/usr/lib/jvm/java-8-openjdk-amd64/bin:$PATH
42
43
44 #------------------------------------------------------------------------------#
45 # run local tests, don't scan fdroidserver/ project for APKs
46
47 cd $WORKSPACE/tests
48 ./run-tests $apksource
49
50 #------------------------------------------------------------------------------#
51 # find pyvenv, to support Ubuntu/trusty's python3.4-venv
52
53 if which pyvenv; then
54     pyvenv=pyvenv
55 elif which pyvenv-3.4; then
56     pyvenv=pyvenv-3.4
57 else
58     echo "pyvenv required to run this test suite!"
59     exit 1
60 fi
61
62
63 #------------------------------------------------------------------------------#
64 # test building the source tarball, then installing it
65 cd $WORKSPACE
66 python3 setup.py sdist
67
68 rm -rf $WORKSPACE/env
69 $pyvenv $WORKSPACE/env
70 . $WORKSPACE/env/bin/activate
71 # workaround https://github.com/pypa/setuptools/issues/937
72 pip3 install --quiet setuptools==33.1.1
73 pip3 install --quiet dist/fdroidserver-*.tar.gz
74
75 # run tests in new pip+pyvenv install
76 fdroid=$WORKSPACE/env/bin/fdroid $WORKSPACE/tests/run-tests $apksource
77
78
79 #------------------------------------------------------------------------------#
80 # test install using install direct from git repo
81 cd $WORKSPACE
82 rm -rf $WORKSPACE/env
83 $pyvenv $WORKSPACE/env
84 . $WORKSPACE/env/bin/activate
85 # workaround https://github.com/pypa/setuptools/issues/937
86 pip3 install --quiet setuptools==33.1.1
87 pip3 install --quiet -e $WORKSPACE
88 python3 setup.py install
89
90 # run tests in new pip+pyvenv install
91 fdroid=$WORKSPACE/env/bin/fdroid $WORKSPACE/tests/run-tests $apksource
92
93
94 #------------------------------------------------------------------------------#
95 # run git pre-commit hook for pep8, pyflakes, etc
96 sh hooks/pre-commit
97
98
99 #------------------------------------------------------------------------------#
100 # run pylint
101
102 # only run it where it will work, for example, the pyvenvs above don't have pylint
103 if which pylint3 && python3 -c "import pylint" 2> /dev/null; then
104     cd $WORKSPACE
105     pylint3 --rcfile=.pylint-rcfile --output-format=colorized --reports=n \
106             fdroid \
107             makebuildserver \
108             setup.py \
109             fdroidserver/*.py \
110             tests/*.py \
111             tests/*.TestCase
112 fi