improved/fixed buildstatus script

yapf autoformatted python scripts
This commit is contained in:
Michael Rodler 2017-09-27 13:52:57 +02:00 committed by Yan
parent 2fe5959e48
commit 407952f696
2 changed files with 68 additions and 50 deletions

View file

@ -2,52 +2,62 @@
import binpacking, sys, pprint import binpacking, sys, pprint
MAXBINDURATION = 2000 # seconds MAXBINDURATION = 2000 # seconds
def parseOutput(fn): def parseOutput(fn):
lines = [l.strip() for l in open(fn).readlines()] lines = [l.strip() for l in open(fn).readlines()]
out = {} out = {}
for l in lines: for l in lines:
[distro, tool, success, duration] = l.split(" ") [distro, tool, success, duration] = l.split(" ")
if not distro in out: if not distro in out:
out[distro] = {} out[distro] = {}
out[distro][tool] = { out[distro][tool] = {
"success": success == "SUCCEEDED", "success": success == "SUCCEEDED",
"duration": int(duration) "duration": int(duration)
} }
return out return out
def printBins(timingdata, distro, expectfail): def printBins(timingdata, distro, expectfail):
inputs = dict([(t, v["duration"]) for (t, v) in timingdata[distro].items() if v["success"] != expectfail]) inputs = dict([(t, v["duration"]) for (t, v) in timingdata[distro].items()
if v["success"] != expectfail])
bins = binpacking.to_constant_volume(inputs, MAXBINDURATION) bins = binpacking.to_constant_volume(inputs, MAXBINDURATION)
for b in bins: for b in bins:
tools = " ".join(sorted(b.keys())) tools = " ".join(sorted(b.keys()))
duration = sum(b.values()) duration = sum(b.values())
if expectfail: if expectfail:
print("- DISTRO='{}' EXPECTFAIL=1 TOOL='{}' # estimated {} seconds".format(distro, tools, duration)) print(
else: "- DISTRO='{}' EXPECTFAIL=1 TOOL='{}' # estimated {} seconds".
print("- DISTRO='{}' TOOL='{}' # estimated {} seconds".format(distro, tools, duration)) format(distro, tools, duration))
else:
print("- DISTRO='{}' TOOL='{}' # estimated {} seconds".format(
distro, tools, duration))
def getToolsFromTimingdata(timingdata): def getToolsFromTimingdata(timingdata):
out = {} out = {}
for d, dd in timingdata.items(): for d, dd in timingdata.items():
for t, td in dd.items(): for t, td in dd.items():
out[t] = 1 out[t] = 1
return out.keys() return out.keys()
if __name__ == "__main__": if __name__ == "__main__":
timingdata = parseOutput(sys.argv[1]) timingdata = parseOutput(sys.argv[1])
distros = sorted(timingdata.keys()) # all distros seen during previous build distros = sorted(
tools = sorted(getToolsFromTimingdata(timingdata)) # all tools seen during previous build timingdata.keys()) # all distros seen during previous build
tools = sorted(getToolsFromTimingdata(
timingdata)) # all tools seen during previous build
for distro in distros: for distro in distros:
printBins(timingdata, distro, False) printBins(timingdata, distro, False)
printBins(timingdata, distro, True) printBins(timingdata, distro, True)
# no timing data, assume the build took too long for this tool on this distro
nodata = [t for t in tools if t not in timingdata[distro]]
for tool in nodata:
print("# - DISTRO='{}' TOOL='{}' # unknown duration...".format(distro, tool))
# no timing data, assume the build took too long for this tool on this distro
nodata = [t for t in tools if t not in timingdata[distro]]
for tool in nodata:
print("# - DISTRO='{}' TOOL='{}' # unknown duration...".format(
distro, tool))

View file

@ -4,40 +4,48 @@ from make_binpacked_travis_ci_conf import *
if __name__ == "__main__": if __name__ == "__main__":
timingdata = parseOutput(sys.argv[1]) timingdata = parseOutput(sys.argv[1])
distros = sorted(timingdata.keys()) # all distros seen during previous build # all distros seen during previous build
tools = sorted(getToolsFromTimingdata(timingdata)) # all tools seen during previous build distros = sorted(timingdata.keys())
# all tools seen during previous build
tools = sorted(getToolsFromTimingdata(timingdata))
fulltable = [] fulltable = []
summarytable = [] summarytable = []
fulltable += [" | ".join([""] + distros)] fulltable.append("| " + " | ".join([""] + distros) + " |")
fulltable += [" | ".join(["-----"] * (1+len(distros)))] fulltable.append("| " + " | ".join(["-----"] * len(distros)) + " |")
summary = {} summary = {}
for tool in tools: for tool in tools:
parts = [] parts = []
for distro in distros: for distro in distros:
val = "unknown" val = "unknown"
if tool in timingdata[distro]: if tool in timingdata[distro]:
val = "success" if timingdata[distro][tool]["success"] else "fail" val = ("success"
parts += [val] if timingdata[distro][tool]["success"] else "fail")
if distro not in summary: parts += [val]
summary[distro] = { if distro not in summary:
"unknown": 0, summary[distro] = {
"success": 0, "unknown": 0,
"fail": 0, "success": 0,
"total": 0, "fail": 0,
} "total": 0,
summary[distro][val] += 1 }
summary[distro]["total"] += 1 summary[distro][val] += 1
fulltable += [" | ".join([tool] + ["![{0}]({0}.png)".format(x) for x in parts])] summary[distro]["total"] += 1
fulltable.append("| " + " | ".join(
[tool] + ["![{0}]({0}.png)".format(x) for x in parts]) + " |")
summarytable.append("| " + " | ".join([""] + distros) + " |")
summarytable.append("| " + " | ".join(["-----"] * len(distros)) + " |")
summarytable += [" | ".join([""] + distros)]
summarytable += [" | ".join(["-----"] * (1+len(distros)))]
for x in ["success", "fail", "unknown"]: for x in ["success", "fail", "unknown"]:
summarytable += [" | ".join(["![{0}]({0}.png)".format(x)] + ["{}".format(summary[d][x]) for d in distros])] summarytable.append("| " + " | ".join(["![{0}]({0}.png)".format(
x)] + [str(summary[d][x]) for d in distros]) + " |")
for x in ["total"]: for x in ["total"]:
summarytable += [" | ".join([x] + ["{}".format(summary[d][x]) for d in distros])] summarytable.append("| " + " | ".join(
[x] + [str(summary[d][x]) for d in distros]) + " |")
print("\n".join(summarytable)) print("\n".join(summarytable))
print("") print("")