chiark / gitweb /
37e594897c5de656261429bd69d23eb6d044b74c
[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 building the source tarball, then installing it
79 cd $WORKSPACE
80 python3 setup.py compile_catalog sdist
81
82 # make sure translation files got compiled and included
83 tar tzf dist/fdroidserver-*.tar.gz | grep locale/de/LC_MESSAGES/fdroidserver.mo
84
85 rm -rf $WORKSPACE/env
86 $pyvenv $WORKSPACE/env
87 . $WORKSPACE/env/bin/activate
88 # workaround https://github.com/pypa/setuptools/issues/937
89 pip3 install --quiet setuptools==33.1.1
90 pip3 install --quiet dist/fdroidserver-*.tar.gz
91
92 # make sure translation files were installed
93 test -e $WORKSPACE/env/share/locale/de/LC_MESSAGES/fdroidserver.mo
94
95 # run tests in new pip+pyvenv install
96 fdroid=$WORKSPACE/env/bin/fdroid $WORKSPACE/tests/run-tests $apksource
97
98
99 #------------------------------------------------------------------------------#
100 # test install using install direct from git repo
101 cd $WORKSPACE
102 rm -rf $WORKSPACE/env
103 $pyvenv $WORKSPACE/env
104 . $WORKSPACE/env/bin/activate
105 # workaround https://github.com/pypa/setuptools/issues/937
106 pip3 install --quiet setuptools==33.1.1 Babel
107 pip3 install --quiet -e $WORKSPACE
108 python3 setup.py compile_catalog install
109
110 # make sure translation files were installed
111 test -e $WORKSPACE/env/share/locale/de/LC_MESSAGES/fdroidserver.mo
112
113 # run tests in new pip+pyvenv install
114 fdroid=$WORKSPACE/env/bin/fdroid $WORKSPACE/tests/run-tests $apksource
115
116
117 #------------------------------------------------------------------------------#
118 # run git pre-commit hook for pep8, pyflakes, etc
119 sh hooks/pre-commit
120
121
122 #------------------------------------------------------------------------------#
123 # run pylint
124
125 # only run it where it will work, for example, the pyvenvs above don't have pylint
126 if which pylint3 && python3 -c "import pylint" 2> /dev/null; then
127     cd $WORKSPACE
128     pylint3 --rcfile=.pylint-rcfile --output-format=colorized --reports=n \
129             fdroid \
130             makebuildserver \
131             setup.py \
132             fdroidserver/*.py \
133             tests/*.py \
134             tests/*.TestCase
135 fi