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
|
#!/usr/bin/python3
from collections import defaultdict
from pathlib import Path
import re
import subprocess
import sys
from debian.changelog import Changelog
debian_archs = [
"amd64",
"arm64",
"armel",
"armhf",
"i386",
"mips64el",
"ppc64el",
"riscv64",
"s390x",
]
def fetch_build_logs(package: str, version: str) -> None:
for a in debian_archs:
if not Path(f"{package}_{version}_{a}.log").exists():
cmd = [
"getbuildlog",
package,
version,
a,
]
subprocess.check_call(cmd)
def find_bpass(filepath: Path) -> list[str]:
with open(filepath, "rt") as fh:
bpass = [l for l in fh.readlines() if "BPASS" in l]
return bpass
def process_logs(package: str, version: str) -> dict[str, list[str]]:
filename_re = re.compile(rf"{package}_.*_(.*)\.log")
result: dict[str, list[str]] = {}
for logfilepath in Path(".").glob(f"{package}_{version}_*.log"):
m = filename_re.match(str(logfilepath))
assert m
arch = m.group(1)
bpasses = find_bpass(logfilepath)
result[arch] = bpasses
return result
def print_table(result: dict[str, list[str]]):
tests: dict[str, list[str]] = defaultdict(list)
checked = sorted(result.keys())
linere = re.compile(r"Test +#(\d+): BPASS +(.*)")
for arch in checked:
for line in result[arch]:
m = linere.search(line)
assert m
testname = m.group(2)
tests[testname].append(arch)
collapse_format = False
max_len = max(len(t) for t in tests.keys())
if collapse_format:
max_len //= 2
print(" " * (max_len + 1), end="")
for a in debian_archs:
print(f"{a} ", end="")
print()
for test, archs in tests.items():
if collapse_format:
print(test)
print(" " * max_len, end="")
else:
print(f"{test:{max_len+1}}", end="")
for a in debian_archs:
if a not in checked:
icon = "?"
elif a in archs:
icon = "✔"
else:
icon = "✘"
print(f"{icon: ^{len(a)}} ", end="")
print()
if __name__ == "__main__":
with open("debian/changelog") as fh:
ch = Changelog(fh)
pkg = ch.package
ver = str(ch.version)
if len(sys.argv) == 2:
ver = sys.argv[1]
fetch_build_logs(pkg, ver)
results = process_logs(pkg, ver)
print_table(results)
|