forked from frobnitzem/nightly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sum.py
executable file
·90 lines (73 loc) · 2.48 KB
/
sum.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
#!/usr/bin/env python
# Summarize the results of all builds and runs
# by printing a neat markdown summary.
from helpers import *
import re
def show_file(fname):
# print the file inside triple quotes
if not fname.exists():
return 1
print("```")
with open(fname, 'r', encoding = 'utf-8') as f:
print(f.read())
print("```")
return 0
def show_status(base, fname):
# print a status.txt file from base / fname
# and show failing parts
fail = re.compile(r'(\w+) failed after')
with open(base / fname, 'r', encoding = 'utf-8') as f:
for line in f:
if line[0] == ' ': # abnormal format for the line
print(" > " + line.strip())
else:
print(" - " + line.strip())
m = fail.search(line)
if m is not None:
show_file(base / f"{m[1]}.log")
# does the return-code indicate fail?
def failed(b):
return b[2] != "0"
def show_csv(fname):
s = Status(fname)
s.show()
return s
def main(argv):
assert len(argv) == 2, f"Usage: {argv[0]} <config.yaml>"
config = Config(argv[1])
work = config.work
print("# Builds\n")
builds = show_csv(work / 'builds.csv')
fails = [v for k,v in builds.items() if failed(v)]
if len(fails) > 0:
print("\n# Failing Build Info\n")
for b in fails:
ID, date, ret = b[0], b[1], int(b[2])
print(f" * {date}: {work/ID} returned {ret}")
show_status( work / ID , 'status.txt' )
print("\n# Runs")
all_results = None
for buildID,v in builds.items():
print(f"\n## Build {buildID} {v}\n")
print(f"\n### Script submissions\n")
runs = show_csv(work / buildID / 'runs.csv')
fails = [v for k,v in runs.items() if failed(v)]
print(f"\n### Run results\n")
results = Status(work / buildID / 'results.csv')
r = runs.join(results)
if all_results is None:
all_results = r
else:
all_results.update(r)
if len(fails) > 0:
print("\n## Failing Run Info\n")
for r in fails:
ID, date, ret = r[0], r[1], int(r[2])
print(f" * {date}: {work/buildID/ID} returned {ret}")
show_status( work / buildID / ID , 'status.txt' )
if all_results is not None:
print("\n# Result Summary\n")
all_results.show()
if __name__=="__main__":
import sys
exit( main(sys.argv) )