chiark / gitweb /
all: switch to jdk8 as default
[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 #------------------------------------------------------------------------------#
52 # test building the source tarball, then installing it
53 cd $WORKSPACE
54 python3 setup.py sdist
55
56 rm -rf $WORKSPACE/env
57 pyvenv $WORKSPACE/env
58 . $WORKSPACE/env/bin/activate
59 pip3 install dist/fdroidserver-*.tar.gz
60
61 # run tests in new pip+pyvenv install
62 fdroid=$WORKSPACE/env/bin/fdroid $WORKSPACE/tests/run-tests $apksource
63
64
65 #------------------------------------------------------------------------------#
66 # test install using install direct from git repo
67 cd $WORKSPACE
68 rm -rf $WORKSPACE/env
69 pyvenv $WORKSPACE/env
70 . $WORKSPACE/env/bin/activate
71 pip3 install -e $WORKSPACE
72 python3 setup.py install
73
74 # run tests in new pip+pyvenv install
75 fdroid=$WORKSPACE/env/bin/fdroid $WORKSPACE/tests/run-tests $apksource
76
77
78 #------------------------------------------------------------------------------#
79 # run git pre-commit hook for pep8, pyflakes, etc
80 sh hooks/pre-commit
81
82
83 #------------------------------------------------------------------------------#
84 # run pylint
85
86 cd $WORKSPACE
87 set +e
88 # use the pyvenv so pylint checks against its installed libs
89     PYTHONPATH=$WORKSPACE/.pylint-plugins python3 /usr/bin/pylint \
90         --output-format=parseable --reports=n \
91         --load-plugins astng_hashlib \
92         fdroidserver/*.py fdroid makebuildserver setup.py > $WORKSPACE/pylint.parseable
93
94 # to only tell jenkins there was an error if we got ERROR or FATAL, uncomment these:
95 # running pylint in the pyvenv/virtualenv is causing this FATAL error, which is a bug:
96 # https://bitbucket.org/logilab/pylint/issue/73/pylint-is-unable-to-import
97 [ $(($? & 1)) = "1" ] && echo "FATALs found"
98 [ $(($? & 2)) = "2" ] && exit 2
99 [ $(($? & 4)) = "4" ] && exit 4
100 set -e
101