File indexing completed on 2025-07-11 07:49:40
0001
0002
0003
0004 import argparse
0005 import re
0006 import os
0007 import csv
0008
0009 HERALD_URL = "https://acts-herald.app.cern.ch/view/{repo}/runs/{run_id}/artifacts/{artifact_name}/{path}"
0010 IS_CI = "GITHUB_ACTIONS" in os.environ
0011
0012
0013 parser = argparse.ArgumentParser()
0014 parser.add_argument("results")
0015 parser.add_argument("--html")
0016 parser.add_argument("--md")
0017 args = parser.parse_args()
0018
0019 re_title = re.compile(r'<p class="title">\s*(.*)\s*<\/p>', re.RegexFlag.MULTILINE)
0020 re_check = re.compile(r'<a.*title="(.*)">\s*(.)\s*<\/a>', re.RegexFlag.MULTILINE)
0021
0022 summary = []
0023
0024 with open(args.results) as f:
0025 reader = csv.reader(f)
0026 for title, html_path, ec in reader:
0027 summary.append(
0028 {
0029 "title": title,
0030 "total": ec == "0",
0031 "path": html_path,
0032 }
0033 )
0034
0035 if args.html:
0036 with open(args.html, mode="w", encoding="utf-8") as f:
0037 f.write(
0038 """<!DOCTYPE html>
0039 <html>
0040 <head>
0041 <title>physmon summary</title>
0042 <meta charset="UTF-8">
0043 </head>
0044 <body>
0045 <h1>physmon summary</h1>
0046 <ul>
0047 """
0048 )
0049
0050 for s in summary:
0051 if s["title"].startswith("Comparison"):
0052 f.write(
0053 f"""
0054 <li>🔵 <a href="{s["path"]}">{s["title"]}</a></li>"""
0055 )
0056 else:
0057 f.write(
0058 f"""
0059 <li>{"✅" if s["total"] else "🔴"} <a href="{s["path"]}">{s["title"]}</a></li>"""
0060 )
0061
0062 f.write(
0063 """
0064 </ul>
0065 </body>
0066 </html>
0067 """
0068 )
0069
0070 if args.md:
0071 with open(args.md, mode="w", encoding="utf-8") as f:
0072 f.write("# physmon summary\n")
0073 for s in summary:
0074 if IS_CI:
0075 url = HERALD_URL.format(
0076 repo=os.environ["GITHUB_REPOSITORY"],
0077 run_id=os.environ["GITHUB_RUN_ID"],
0078 artifact_name="physmon",
0079 path=s["path"],
0080 )
0081 else:
0082 url = s["path"]
0083
0084 if s["title"].startswith("Comparison"):
0085 f.write(f" - 🔵️ [{s['title']}]({url})\n")
0086 else:
0087 f.write(f" - {'✅' if s['total'] else '🔴'} [{s['title']}]({url})\n")