forked from danmar/cppcheck
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathci.py
More file actions
177 lines (143 loc) · 4.57 KB
/
ci.py
File metadata and controls
177 lines (143 loc) · 4.57 KB
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
#!/usr/bin/python
# continuous integration
# build daily reports (doxygen,coverage,etc)
import datetime
import time
import subprocess
import pexpect
import glob
import os
import sys
import urllib
def wget(url):
try:
fp = urllib.urlopen(url)
data = fp.read()
return data
except IOError:
pass
return ''
# Upload file to sourceforge web server using scp
def upload(file_to_upload, destination):
try:
password = sys.argv[1]
child = pexpect.spawn(
'scp ' + file_to_upload + ' danielmarjamaki,cppcheck@web.sourceforge.net:' + destination)
#child.expect(
# 'danielmarjamaki,cppcheck@web.sourceforge.net\'s password:')
child.expect('Password:')
child.sendline(password)
child.interact()
except IOError:
pass
except OSError:
pass
except pexpect.TIMEOUT:
pass
# Perform a 'make test' on the repo
def maketest(preclean):
if preclean == True:
subprocess.call(['make', 'clean'])
p = subprocess.Popen(
['nice', 'make', 'test'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
comm = p.communicate()
f = open('maketest.txt', 'wt')
f.write('Errors\n======\n')
f.write(comm[1] + '\n')
f.write('Output\n======\n')
f.write(comm[0] + '\n')
f.close()
upload('maketest.txt', 'htdocs/devinfo/')
# git push
def gitpush():
try:
password = sys.argv[1]
child = pexpect.spawn('git push')
child.expect("Enter passphrase for key '/home/daniel/.ssh/id_rsa':")
child.sendline(password)
child.interact()
except IOError:
pass
except OSError:
pass
except pexpect.TIMEOUT:
pass
def iconv(filename):
p = subprocess.Popen(['file', '-i', filename],
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
comm = p.communicate()
if comm[0].find('charset=iso-8859-1') >= 0:
subprocess.call(
["iconv", filename, "--from=ISO-8859-1", "--to=UTF-8", "-o", filename])
# Generate daily webreport
def generate_webreport():
filenames = glob.glob('*/*.cpp')
for filename in filenames:
iconv(filename)
subprocess.call(
["git", "commit", "-a", "-m", '"automatic conversion from iso-8859-1 formatting to utf-8"'])
gitpush()
subprocess.call(["rm", "-rf", "devinfo"])
subprocess.call(['nice', "./webreport.sh"])
upload('-r devinfo', 'htdocs/')
subprocess.call(["make", "clean"])
subprocess.call(["rm", "-rf", "devinfo"])
# Perform a git pull.
def gitpull():
try:
password = sys.argv[1]
child = pexpect.spawn('git pull')
child.expect("Enter passphrase for key '/home/daniel/.ssh/id_rsa':")
child.sendline(password)
child.expect('Already up-to-date.')
child.interact()
except IOError:
pass
except OSError:
pass
except pexpect.TIMEOUT:
pass
except pexpect.EOF:
return True
return False
def daca2report():
print('Generate DACA2 report')
subprocess.call(['rm', '-rf', 'daca2-report'])
subprocess.call(['mkdir', 'daca2-report'])
subprocess.call(['python', 'tools/daca2-report.py', 'daca2-report'])
upload('-r daca2-report', 'htdocs/devinfo/')
def daca2(foldernum):
folders = '0123456789abcdefghijklmnopqrstuvwxyz'
folder = folders[foldernum % len(folders)]
print('Daca2 folder=' + folder)
p = subprocess.Popen(['git', 'show', '--format=%h'],
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
comm = p.communicate()
rev = comm[0]
rev = rev[:rev.find('\n')]
subprocess.call(
['make', 'clean'])
subprocess.call(
['nice', 'make', 'SRCDIR=build', 'CFGDIR='+os.path.expanduser('~/cppcheck/cfg'), 'CXXFLAGS=-O2', 'CPPFLAGS=-DMAXTIME=600'])
subprocess.call(
['mv', 'cppcheck', os.path.expanduser('~/daca2/cppcheck-O2')])
subprocess.call(['python', 'tools/daca2.py', folder, '--rev=' + rev])
daca2report()
subprocess.call(
['python', 'tools/daca2.py', 'lib' + folder, '--rev=' + rev])
daca2report()
t0 = datetime.date.today()
foldernum = 0
while True:
if datetime.date.today() != t0:
print("generate daily reports")
t0 = datetime.date.today()
generate_webreport()
if gitpull() == True:
print("make test")
# maketest(False) # Integral make test build
cmd = wget('http://cppcheck.sourceforge.net/cgi-bin/ci.cgi?clear')
if cmd.find("doxygen") >= 0:
generate_webreport()
daca2(foldernum)
foldernum = foldernum + 1