forked from red56/django-immutablemodel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jenkins.py
51 lines (42 loc) · 1.11 KB
/
jenkins.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
#! /usr/bin/env python
'''
file to run in jenkins
'''
import os
import sys
ROOT = os.path.abspath(os.path.dirname(__file__))
VIRTUALENV_DIR = os.path.join(os.path.dirname(ROOT),'virtualenv')
def print_ln(msg):
sys.stderr.write(msg)
sys.stderr.write("\n")
def print_header(msg):
print_ln("="*80)
print_ln(" " + msg)
print_ln("="*80)
def ensure_virtualenv():
if os.path.exists(os.path.join(VIRTUALENV_DIR,'bin')):
return
os.path
print_header("setting up virtualenv")
system(
"virtualenv -p python2.5 --no-site-packages %s" % (VIRTUALENV_DIR, )
)
def pip_install():
print_header("doing pip install")
system(
"%s/bin/pip install -r %s/requirements.txt" % (VIRTUALENV_DIR, ROOT, )
)
def do_test():
print_header("doing test")
return_code = system(
"%s/bin/python %s/runtests.py" % (VIRTUALENV_DIR, ROOT)
)
if return_code:
sys.exit("Test failure or error")
def system(cmd):
print_ln(cmd)
return os.system(cmd)
if __name__=="__main__":
ensure_virtualenv()
pip_install()
do_test()