chiark / gitweb /
Bump to 0.4.0
[fdroidserver.git] / jenkins-build
1 #!/bin/bash
2 #
3 # this is the script run by the Jenkins server to run the build and tests.  Be
4 # sure to always run it in its dir, i.e. ./jenkins-build.sh, otherwise it might
5 # remove things that you don't want it to.
6
7 if [ `dirname $0` != "." ]; then
8     echo "only run this script like ./`basename $0`"
9     exit
10 fi
11
12 set -e
13 set -x
14
15 if [ -z $WORKSPACE ]; then
16     export WORKSPACE=`pwd`
17 fi
18
19 if [ -z $ANDROID_HOME ]; then
20     if [ -e ~/.android/bashrc ]; then
21         . ~/.android/bashrc
22     else
23         echo "ANDROID_HOME must be set!"
24         exit
25     fi
26 fi
27
28
29 #------------------------------------------------------------------------------#
30 # cache pypi downloads
31 if [ -z $PIP_DOWNLOAD_CACHE ]; then
32     export PIP_DOWNLOAD_CACHE=$HOME/.pip_download_cache
33 fi
34
35
36 #------------------------------------------------------------------------------#
37 # required Java 7 keytool/jarsigner for :file support
38
39 export PATH=/usr/lib/jvm/java-7-openjdk-amd64/bin:$PATH
40
41
42 #------------------------------------------------------------------------------#
43 # run local tests, don't scan fdroidserver/ project for APKs
44
45 # this is a local repo on the Guardian Project Jenkins server
46 apksource=/var/www/fdroid
47
48 cd $WORKSPACE/tests
49 ./run-tests $apksource
50
51
52 #------------------------------------------------------------------------------#
53 # test building the source tarball, then installing it
54 cd $WORKSPACE
55 python2 setup.py sdist
56
57 rm -rf $WORKSPACE/env
58 virtualenv --python=python2 $WORKSPACE/env
59 . $WORKSPACE/env/bin/activate
60 pip install dist/fdroidserver-*.tar.gz
61
62 # run tests in new pip+virtualenv install
63 fdroid=$WORKSPACE/env/bin/fdroid $WORKSPACE/tests/run-tests $apksource
64
65
66 #------------------------------------------------------------------------------#
67 # test install using install direct from git repo
68 cd $WORKSPACE
69 rm -rf $WORKSPACE/env
70 virtualenv --python=python2 --system-site-packages $WORKSPACE/env
71 . $WORKSPACE/env/bin/activate
72 pip install -e $WORKSPACE
73 python2 setup.py install
74
75 # run tests in new pip+virtualenv install
76 fdroid=$WORKSPACE/env/bin/fdroid $WORKSPACE/tests/run-tests $apksource
77
78
79 #------------------------------------------------------------------------------#
80 # run git pre-commit hook for pep8, pyflakes, etc
81 sh hooks/pre-commit
82
83
84 #------------------------------------------------------------------------------#
85 # run pylint
86
87 cd $WORKSPACE
88 set +e
89 # use the virtualenv python so pylint checks against its installed libs
90     PYTHONPATH=$WORKSPACE/.pylint-plugins python2 /usr/bin/pylint \
91         --output-format=parseable --reports=n \
92         --load-plugins astng_hashlib \
93         fdroidserver/*.py fdroid makebuildserver setup.py > $WORKSPACE/pylint.parseable
94
95 # to only tell jenkins there was an error if we got ERROR or FATAL, uncomment these:
96 # running pylint in the virtualenv is causing this FATAL error, which is a bug:
97 # https://bitbucket.org/logilab/pylint/issue/73/pylint-is-unable-to-import
98 [ $(($? & 1)) = "1" ] && echo "FATALs found"
99 [ $(($? & 2)) = "2" ] && exit 2
100 [ $(($? & 4)) = "4" ] && exit 4
101 set -e
102