Skip to content

Commit

Permalink
do not fail on non existing branches, add them to the email (#101)
Browse files Browse the repository at this point in the history
* do not fail on non existing branches, add them to the email

* properly change color to red
  • Loading branch information
adrpo authored Apr 17, 2024
1 parent 684b251 commit 1e3d4a8
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 9 deletions.
16 changes: 12 additions & 4 deletions all-plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,19 @@ def plotLibrary(branch, libname, xs, total, frontend,backend,simcode,template,co
for branch in branches:
try:
cursor.execute("SELECT name FROM [sqlite_master] WHERE type='table' AND name=?", (branch,))
v = cursor.fetchone()[0]
one = cursor.fetchone()
if one == None:
print("No such table '%s'; specify it using --branch=XXX when running test.py" % branch)
# ignore this table and continue
continue
else:
v = one[0]
except:
raise Exception("No such table '%s'; specify it using --branch=XXX" % branch)

for branch in branches:
# raise Exception("No such table '%s'; specify it using --branch=XXX" % branch)
print("No such table '%s'; specify it using --branch=XXX when running test.py" % branch)
# ignore this table and continue
continue

cursor.execute('''CREATE INDEX IF NOT EXISTS [idx_%s_date] ON [%s](date)''' % (branch,branch))
libs = {}
for (date,libname,total,frontend,backend,simcode,template,compile,simulate,verify) in cursor.execute("""SELECT date,libname,COUNT(finalphase),COUNT(finalphase>=1 or null),COUNT(finalphase>=2 or null),COUNT(finalphase>=3 or null),COUNT(finalphase>=4 or null),COUNT(finalphase>=5 or null),COUNT(finalphase>=6 or null),COUNT(finalphase>=7 or null)
Expand Down
32 changes: 27 additions & 5 deletions all-reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,26 @@ def libraryLink(branch, libname):
def modelLink(libname, modelname, extension, text):
return '<a href="%s/%s/%s/files/%s_%s.%s">%s</a>' % (baseurl,branch,libname,libname,modelname,extension,text)

missing_branches = []
emails_to_send = {}
for branch in branches:
try:
cursor.execute("SELECT name FROM [sqlite_master] WHERE type='table' AND name=?", (branch,))
v = cursor.fetchone()[0]
except:
raise Exception("No such table '%s'; specify it using --branch=XXX" % branch)
one = cursor.fetchone()
if one == None:
print("No such table '%s'; specify it using --branch=XXX when running test.py" % branch)
# ignore this table and continue
missing_branches.append(branch)
continue
else:
v = one[0]
except:
#raise Exception("No such table '%s'; specify it using --branch=XXX" % branch)
print("No such table '%s'; specify it using --branch=XXX when running test.py" % branch)
# ignore this table and continue
missing_branches.append(branch)
continue

cursor.execute('''CREATE INDEX IF NOT EXISTS [idx_%s_date] ON [%s](date)''' % (branch,branch))
cursor.execute("SELECT date,omcversion FROM [omcversion] WHERE branch LIKE ? COLLATE NOCASE ORDER BY date ASC", (branch,))
entries = cursor.fetchall()
Expand Down Expand Up @@ -256,23 +269,32 @@ def modelLink(libname, modelname, extension, text):
from email.headerregistry import Address
from email.utils import make_msgid

missing_plain = ""
missing_html = ""
if missing_branches:
missing_plain = ", ".join(missing_branches)
missing_plain = "Report asks for missing branches which we ignored: %s\n" % missing_plain
missing_html = ("%s %s %s" % ("<p style=\"color:red;\">", missing_plain, "</p"))

for email in sorted(emails_to_send.keys()):
msg = EmailMessage()
msg['Subject'] = 'OpenModelica Library Testing Regressions'
msg['From'] = Address("OM Hudson", "openmodelicabuilds", "ida.liu.se")
msg['To'] = email
msg.set_content("""\
%s
The following reports contain regressions your account was involved with:
""" + "\n".join(reversed(emails_to_send[email]["plain"])))
""" % missing_plain + "\n".join(reversed(emails_to_send[email]["plain"])))
msg.add_alternative("""\
<html lang="en">
<head></head>
<body>
%s
<p>The following reports contain regressions your account was involved with:</p>
%s
</body>
</html>
""" % "\n".join(reversed(emails_to_send[email]["html"])), subtype='html')
""" % (missing_html, "\n".join(reversed(emails_to_send[email]["html"]))), subtype='html')
with smtplib.SMTP('smtp.office365.com') as s:
s.starttls()
s.ehlo()
Expand Down

0 comments on commit 1e3d4a8

Please sign in to comment.