File indexing completed on 2025-01-18 09:10:43
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 f.write(
0052 f"""
0053 <li>{"✅" if s["total"] else "🔴"} <a href="{s["path"]}">{s["title"]}</a></li>"""
0054 )
0055
0056 f.write(
0057 """
0058 </ul>
0059 </body>
0060 </html>
0061 """
0062 )
0063
0064 if args.md:
0065 with open(args.md, mode="w", encoding="utf-8") as f:
0066 f.write("# physmon summary\n")
0067 for s in summary:
0068 if IS_CI:
0069 url = HERALD_URL.format(
0070 repo=os.environ["GITHUB_REPOSITORY"],
0071 run_id=os.environ["GITHUB_RUN_ID"],
0072 artifact_name="physmon",
0073 path=s["path"],
0074 )
0075 else:
0076 url = s["path"]
0077 f.write(f" - {'✅' if s['total'] else '🔴'} [{s['title']}]({url})\n")