-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuildbot_runner.py
114 lines (93 loc) · 2.75 KB
/
buildbot_runner.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/bin/bash
SSHPARAMS="-i /home/buildbot/.ssh/id_rsa.rsync -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
SSHDEST="python-packages@python.mydomain.com"
TMPDIR=/tmp/buildbot/$
branch=$1
giturl=$2
if [ "X$branch" == "X" ]
then
echo "No branch passed"
exit 1
fi
if [ "X$giturl" == "X" ]
then
echo "No branch passed"
exit 1
fi
function finish {
cd /home/buildbot
/bin/rm -rf $TMPDIR
echo "*** cleanup done ***"
}
# sometimes gitlab sends https:// urls not git@
giturl=`echo $giturl | sed -e 's/https:\/\/gitlab.mydomain.com\//git@gitlab.mydomain.com:/g'`
echo "******************** giturl is:$giturl branch is:$branch ********************"
mkdir -p $TMPDIR
cd $TMPDIR
# Exit on error
set -e
set -x
trap finish EXIT TERM HUP
echo "Setting up python virtualenv under $TMPDIR/venv"
virtualenv $TMPDIR/venv -p python3
source $TMPDIR/venv/bin/activate
#########################################################
#
# dependencies & requirements
#
##########################################################
if [ -f $TMPDIR/thisbuild/setup.py ]
then
cd $TMPDIR/thisbuild
echo "******************** Installing dependencies via pip ********************"
pip install --process-dependency-links $TMPDIR/thisbuild/
else
echo "!!!!!!!!!!!!!!!!!!!! No setup.py found !!!!!!!!!!!!!!!!!!!!"
fi
if [ -f $TMPDIR/thisbuild/requirements.txt ]
then
cd $TMPDIR/thisbuild
echo "******************** Installing requirements via pip ********************"
pip install -r $TMPDIR/thisbuild/requirements.txt
else
echo "!!!!!!!!!!!!!!!!!!!! No requirements.txt found !!!!!!!!!!!!!!!!!!!!"
fi
#########################################################
#
# tests
#
##########################################################
if [ -d $TMPDIR/thisbuild/tests ]
then
cd $TMPDIR/thisbuild
echo "******************** Running unit tests ********************"
python -m unittest
else
echo "!!!!!!!!!!!!!!!!!!!! No unit tests found !!!!!!!!!!!!!!!!!!!!"
fi
#########################################################
#
# build & upload
#
##########################################################
if [ -f $TMPDIR/thisbuild/setup.py ]
then
cd $TMPDIR/thisbuild
echo "******************** Building the project ********************"
python setup.py sdist bdist_egg
if [ $? -ne 0 ]
then
echo "!!!!!!!!!!!!!!!!!!!! Build failed !!!!!!!!!!!!!!!!!!!!"
exit 1
fi
# now upload the stuff :-)
ls -alR dist
dstdir=$(python3 setup.py --name 2> /dev/null | tail -n 1)
echo "******************** uploading to $dstdir ********************"
chmod 644 dist/*
ssh $SSHPARAMS $SSHDEST mkdir -p files/${dstdir}
scp $SSHPARAMS dist/* $SSHDEST:files/${dstdir}/
else
echo "!!!!!!!!!!!!!!!!!!!! No setup.py found !!!!!!!!!!!!!!!!!!!!"
fi
echo "******************** build Job completed ********************"