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