chiark / gitweb /
Merge branch 'master' into 'master'
[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 # required Java 7 keytool/jarsigner for :file support
30
31 export PATH=/usr/lib/jvm/java-7-openjdk-amd64/bin:$PATH
32
33 #------------------------------------------------------------------------------#
34 # run local build
35 cd $WORKSPACE/fdroidserver/getsig
36 ./make.sh
37
38
39 #------------------------------------------------------------------------------#
40 # run local tests
41 cd $WORKSPACE/tests
42 ./run-tests.sh
43
44
45 #------------------------------------------------------------------------------#
46 # test building the source tarball
47 cd $WORKSPACE
48 python setup.py sdist
49
50
51 #------------------------------------------------------------------------------#
52 # test install using site packages
53 cd $WORKSPACE
54 rm -rf $WORKSPACE/env
55 virtualenv --system-site-packages $WORKSPACE/env
56 . $WORKSPACE/env/bin/activate
57 pip install -e $WORKSPACE
58 python setup.py install
59
60 # run tests in new pip+virtualenv install
61 . $WORKSPACE/env/bin/activate
62 fdroid=$WORKSPACE/env/bin/fdroid $WORKSPACE/tests/run-tests.sh
63
64
65 #------------------------------------------------------------------------------#
66 # run pyflakes
67 pyflakes fdroid makebuildserver fdroidserver/*.py setup.py
68
69
70 #------------------------------------------------------------------------------#
71 # run pylint
72
73 cd $WORKSPACE
74 set +e
75 # use the virtualenv python so pylint checks against its installed libs
76     PYTHONPATH=$WORKSPACE/.pylint-plugins python /usr/bin/pylint \
77         --output-format=parseable --reports=n \
78         --load-plugins astng_hashlib \
79         fdroidserver/*.py fdroid makebuildserver setup.py > $WORKSPACE/pylint.parseable
80
81 # to only tell jenkins there was an error if we got ERROR or FATAL, uncomment these:
82 # running pylint in the virtualenv is causing this FATAL error, which is a bug:
83 # https://bitbucket.org/logilab/pylint/issue/73/pylint-is-unable-to-import
84 [ $(($? & 1)) = "1" ] && echo "FATALs found"
85 [ $(($? & 2)) = "2" ] && exit 2
86 [ $(($? & 4)) = "4" ] && exit 4
87 set -e
88