diff --git a/bin/travis-ci-status/make_binpacked_travis_ci_conf.py b/bin/travis-ci-status/make_binpacked_travis_ci_conf.py index 31137e2..b2065d9 100755 --- a/bin/travis-ci-status/make_binpacked_travis_ci_conf.py +++ b/bin/travis-ci-status/make_binpacked_travis_ci_conf.py @@ -2,52 +2,62 @@ import binpacking, sys, pprint -MAXBINDURATION = 2000 # seconds +MAXBINDURATION = 2000 # seconds + def parseOutput(fn): lines = [l.strip() for l in open(fn).readlines()] out = {} for l in lines: - [distro, tool, success, duration] = l.split(" ") - if not distro in out: - out[distro] = {} - out[distro][tool] = { - "success": success == "SUCCEEDED", - "duration": int(duration) - } + [distro, tool, success, duration] = l.split(" ") + if not distro in out: + out[distro] = {} + out[distro][tool] = { + "success": success == "SUCCEEDED", + "duration": int(duration) + } return out + 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) for b in bins: - tools = " ".join(sorted(b.keys())) - duration = sum(b.values()) - if expectfail: - print("- DISTRO='{}' EXPECTFAIL=1 TOOL='{}' # estimated {} seconds".format(distro, tools, duration)) - else: - print("- DISTRO='{}' TOOL='{}' # estimated {} seconds".format(distro, tools, duration)) + tools = " ".join(sorted(b.keys())) + duration = sum(b.values()) + if expectfail: + print( + "- DISTRO='{}' EXPECTFAIL=1 TOOL='{}' # estimated {} seconds". + format(distro, tools, duration)) + else: + print("- DISTRO='{}' TOOL='{}' # estimated {} seconds".format( + distro, tools, duration)) + def getToolsFromTimingdata(timingdata): out = {} for d, dd in timingdata.items(): for t, td in dd.items(): - out[t] = 1 + out[t] = 1 return out.keys() + if __name__ == "__main__": timingdata = parseOutput(sys.argv[1]) - distros = sorted(timingdata.keys()) # all distros seen during previous build - tools = sorted(getToolsFromTimingdata(timingdata)) # all tools seen during previous build + distros = sorted( + timingdata.keys()) # all distros seen during previous build + tools = sorted(getToolsFromTimingdata( + timingdata)) # all tools seen during previous build for distro in distros: - printBins(timingdata, distro, False) - 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)) + printBins(timingdata, distro, False) + 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)) diff --git a/bin/travis-ci-status/make_build_status_md.py b/bin/travis-ci-status/make_build_status_md.py index 6265184..9442f83 100755 --- a/bin/travis-ci-status/make_build_status_md.py +++ b/bin/travis-ci-status/make_build_status_md.py @@ -4,40 +4,48 @@ from make_binpacked_travis_ci_conf import * if __name__ == "__main__": timingdata = parseOutput(sys.argv[1]) - distros = sorted(timingdata.keys()) # all distros seen during previous build - tools = sorted(getToolsFromTimingdata(timingdata)) # all tools seen during previous build + # all distros seen during previous build + distros = sorted(timingdata.keys()) + # all tools seen during previous build + tools = sorted(getToolsFromTimingdata(timingdata)) fulltable = [] summarytable = [] - fulltable += [" | ".join([""] + distros)] - fulltable += [" | ".join(["-----"] * (1+len(distros)))] - + fulltable.append("| " + " | ".join([""] + distros) + " |") + fulltable.append("| " + " | ".join(["-----"] * len(distros)) + " |") + summary = {} for tool in tools: - parts = [] - for distro in distros: - val = "unknown" - if tool in timingdata[distro]: - val = "success" if timingdata[distro][tool]["success"] else "fail" - parts += [val] - if distro not in summary: - summary[distro] = { - "unknown": 0, - "success": 0, - "fail": 0, - "total": 0, - } - summary[distro][val] += 1 - summary[distro]["total"] += 1 - fulltable += [" | ".join([tool] + ["![{0}]({0}.png)".format(x) for x in parts])] + parts = [] + for distro in distros: + val = "unknown" + if tool in timingdata[distro]: + val = ("success" + if timingdata[distro][tool]["success"] else "fail") + parts += [val] + if distro not in summary: + summary[distro] = { + "unknown": 0, + "success": 0, + "fail": 0, + "total": 0, + } + summary[distro][val] += 1 + 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"]: - 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"]: - 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("")