Commit 6fecf6ca authored by David Diederich's avatar David Diederich
Browse files

Include badge generation in the Summarize_Newman_Html_Reports.py script

parent fc46b131
......@@ -7,6 +7,7 @@ import xlsxwriter
from bs4 import BeautifulSoup
import requests
import datetime
from pybadges import badge
#
# This script processes all the html files that are generated by using the Postman Newman (htmlextra)
# program to run the postman collections for "OSDU Platform Validation project."
......@@ -99,6 +100,15 @@ def processFile(fnm, platform, rowNo, colOffset, envFileNamesPopulated):
# Compute the pass rate (percentage of test that passed for the collection); Avoid ZeroDivisionError
if (float(totalAssertionPassed) > 0.0):
passRate = (100 * ( (float(totalAssertionPassed) - float(totalAssertionFailed)) / float(totalAssertionPassed) ) )
# Add up the total numbers for each platform
if (platform not in env_total_assertions):
env_total_assertions[platform] = 0
env_passing_assertions[platform] = 0
# Despite the name, "totalAssertionPassed" is the number executed, not the number that passed
env_total_assertions[platform] += int(totalAssertionPassed)
env_passing_assertions[platform] += int(totalAssertionPassed) - int(totalAssertionFailed)
else:
passRate = 0.0
......@@ -149,6 +159,8 @@ print("Starting to summarize all the html reports")
records = []
env_file_names = []
env_file_names_populated = False
env_total_assertions = {}
env_passing_assertions = {}
collection_run_date = []
#
fillColList = [5,9,13] # column list that are acting as separator between platforms
......@@ -335,6 +347,19 @@ for i in range(numOfEnvs):
rowIndx += 1
# Close the Excel file
workbook.close()
# Output the test result badges, stylized to match GitLab pipeline badges
for platform in env_total_assertions:
passRate = 100.0 * env_passing_assertions[platform] / env_total_assertions[platform]
if env_passing_assertions[platform] == env_total_assertions[platform]:
badgeColor = '#4c1' # green
elif passRate >= 60.0:
badgeColor = '#dfb317' # yellow
else:
badgeColor = '#e05d44' # red
with open(platform + '.svg', 'w') as f:
f.write(badge(left_text=platform, right_text=('%.1f%%' % passRate), right_color=badgeColor));
# Log some summary data
print(env_file_names)
print(collection_run_date)
......
......@@ -7,3 +7,4 @@ requests==2.24.0
soupsieve==2.0.1
urllib3==1.25.10
XlsxWriter==1.3.6
pybadges==2.2.1
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment