chiark / gitweb /
Merge branch 'master' into 'master'
[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     WORKSPACE=`cd $(dirname $0)/.. && pwd`
18     echo "Setting Workspace to $WORKSPACE"
19 fi
20
21 if [ -z $ANDROID_HOME ]; then
22     if [ -e ~/.android/bashrc ]; then
23         . ~/.android/bashrc
24     else
25         echo "ANDROID_HOME must be set!"
26         exit 1
27     fi
28 fi
29
30 apksource=$1
31
32 #------------------------------------------------------------------------------#
33 # cache pypi downloads
34 if [ -z $PIP_DOWNLOAD_CACHE ]; then
35     export PIP_DOWNLOAD_CACHE=$HOME/.pip_download_cache
36 fi
37
38
39 #------------------------------------------------------------------------------#
40 # required Java 7 or later keytool/jarsigner for :file support
41
42 export PATH=/usr/lib/jvm/java-8-openjdk-amd64/bin:$PATH
43
44
45 #------------------------------------------------------------------------------#
46 # run local tests, don't scan fdroidserver/ project for APKs
47
48 cd $WORKSPACE/tests
49 ./run-tests $apksource
50
51 #------------------------------------------------------------------------------#
52 # find pyvenv, to support Ubuntu/trusty's python3.4-venv
53
54 if which pyvenv; then
55     pyvenv=pyvenv
56 elif which pyvenv-3.4; then
57     pyvenv=pyvenv-3.4
58 else
59     echo "pyvenv required to run this test suite!"
60     exit 1
61 fi
62
63
64 #------------------------------------------------------------------------------#
65 # make sure that translations do not cause stacktraces
66 cd $WORKSPACE/locale
67 for locale in *; do
68     if [ ! -d $locale ]; then
69         continue
70     fi
71     for cmd in `sed -n 's/.*("\(.*\)", *_.*/\1/p' $WORKSPACE/fdroid`; do
72         LANGUAGE=$locale $WORKSPACE/fdroid $cmd --help > /dev/null
73     done
74 done
75
76
77 #------------------------------------------------------------------------------#
78 # test install using install direct from git repo
79 cd $WORKSPACE
80 rm -rf $WORKSPACE/env
81 $pyvenv $WORKSPACE/env
82 . $WORKSPACE/env/bin/activate
83 # workaround https://github.com/pypa/setuptools/issues/937
84 pip3 install --quiet setuptools==33.1.1 Babel
85 pip3 install --quiet -e $WORKSPACE
86 python3 setup.py compile_catalog install
87
88 # make sure translation files were installed
89 test -e $WORKSPACE/env/share/locale/de/LC_MESSAGES/fdroidserver.mo
90
91 # run tests in new pip+pyvenv install
92 fdroid=$WORKSPACE/env/bin/fdroid $WORKSPACE/tests/run-tests $apksource
93
94
95 #------------------------------------------------------------------------------#
96 # run pylint
97
98 # only run it where it will work, for example, the pyvenvs above don't have pylint
99 if which pylint3 && python3 -c "import pylint" 2> /dev/null; then
100     cd $WORKSPACE
101     pylint3 --rcfile=.pylint-rcfile --output-format=colorized --reports=n \
102             fdroid \
103             makebuildserver \
104             setup.py \
105             fdroidserver/*.py \
106             tests/*.py \
107             tests/*.TestCase
108 fi