Commit 48a00614 authored by Denis Karpenok (EPAM)'s avatar Denis Karpenok (EPAM)
Browse files

New excel

parent a86cc398
#!/usr/bin/env python3
# importing the libraries
import csv
import os
import re
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."
# it expects the report files to follow the assumptions and rules mentioned in file
# OSDU Platform Validation CI_CD_Notes.md of "Platform Validation project"
# At present it is assuming 11 collections being run each of the four platforms
# AWS, AZURE, GCP, IBM
# AT present
# Number of collection can vary, but number of platforms is fixed.
# Also it expects to have the collection report for each platform.
# The Collection run date is extracted from the first collection report processed.
# Also environment file is extracted from the first collection processed for each platform
#
# In future work can be done to make the number of platforms also variable
# At present this restriction is there because
# of the way the writing of the excel file is implemented.
# Also the Columns for each platform are fixed
#=======================================================================================================
# Method to process html report file and summarize the results in Excel file
def processFile(fnm, platform, rowNo, colOffset, envFileNamesPopulated):
# print("fileName: " + fnm)
# print("Platform: " + platform)
# print("Row: ", rowNo)
# print("Total Rows: ", totRows)
# print("Column offset", colOffset)
#
# Open the html file for reading
html = open(fnm, 'r').read() # local html
bs = BeautifulSoup(html, features="html.parser") # parse the file
# Find the desired section of the file, extract the text and split to extract required information
mydivs = bs.findAll("div", {"class": "col-sm-12 mb-3"})
txt = mydivs[0].get_text()
fileInfo = txt.split("\n")
# Get file and environment information
collectionName = ""
enviornmentName = ""
count = 0
pattern = re.compile("Collection:")
# Parse and extract all the necessary values
for elm in fileInfo:
if pattern.search(elm):
if (count == 0):
collectionstr = elm.split(":")
collectionName = collectionstr[1]
pattern = re.compile("Environment:")
count += 1
elif (count == 1):
environmentstr = elm.split(":")
enviornmentName = environmentstr[1]
#
print(collectionName)
print(enviornmentName)
# Save/Collect environment file names (only once, not for each collection)
if (envFileNamesPopulated == False):
if (colOffset == 0):
env_file_names.append(enviornmentName)
elif (colOffset == 6):
env_file_names.append(enviornmentName)
elif (colOffset == 10):
env_file_names.append(enviornmentName)
elif(colOffset == 14):
env_file_names.append(enviornmentName)
from time import strftime, gmtime
from openpyxl import Workbook, load_workbook
from bs4 import BeautifulSoup as BS
from openpyxl.styles import Font, PatternFill, Alignment
envs = []
collections = []
for result_file in sorted(os.listdir('public')):
if result_file.endswith('.html'):
result_file_parts = result_file.split('.')
if result_file_parts[0] not in envs:
envs.append(result_file_parts[0])
envs.sort()
if result_file_parts[1] not in collections:
collections.append(result_file_parts[1])
collections.sort()
result_file = Workbook()
result_data = result_file.active
result_data.title = 'Data'
result_data.cell(2, 1).value = 'Collection Name'
result_data.cell(2, 1).font = Font(bold=True)
result_data.cell(2, 1).fill = PatternFill("solid", fgColor="00CCCCFF")
result_data.cell(2, 1).alignment = Alignment(horizontal='center')
data_row = 3
ordered_collections = {}
for collection in collections:
result_data.cell(data_row, 1).value = collection.split('CI-CD')[0].replace('_', ' ')
result_data.cell(data_row, 1).font = Font(bold=True)
ordered_collections[collection] = data_row
data_row += 1
total_row_number = max([i for i in ordered_collections.values()]) + 1
result_data.cell(total_row_number, 1).value = 'Total'
result_data.cell(total_row_number, 1).font = Font(bold=True)
result_data.cell(total_row_number, 1).fill = PatternFill("solid", fgColor="d2e9c3")
env_number = 0
for env in envs:
env_columns = 5 * env_number
result_data.cell(1, 2 + env_columns).value = env
result_data.merge_cells(start_row=1, end_row=1,
start_column=(2 + env_columns), end_column=(5 + env_columns))
result_data.cell(1, 2 + env_columns).font = Font(size=14)
result_data.cell(1, 2 + env_columns).fill = PatternFill("solid", fgColor="009999FF")
result_data.cell(1, 2 + env_columns).alignment = Alignment(horizontal='center')
result_data.cell(2, 2 + env_columns).value = 'Requests'
result_data.cell(2, 3 + env_columns).value = 'Executed'
result_data.cell(2, 4 + env_columns).value = 'Failed'
result_data.cell(2, 5 + env_columns).value = 'Pass Rate'
result_data.cell(2, 2 + env_columns).font = Font(bold=True)
result_data.cell(2, 2 + env_columns).fill = PatternFill("solid", fgColor="00CCCCFF")
result_data.cell(2, 2 + env_columns).alignment = Alignment(horizontal='center')
result_data.cell(2, 3 + env_columns).font = Font(bold=True)
result_data.cell(2, 3 + env_columns).fill = PatternFill("solid", fgColor="00CCCCFF")
result_data.cell(2, 3 + env_columns).alignment = Alignment(horizontal='center')
result_data.cell(2, 4 + env_columns).font = Font(bold=True, color="FF0000")
result_data.cell(2, 4 + env_columns).fill = PatternFill("solid", fgColor="00CCCCFF")
result_data.cell(2, 4 + env_columns).alignment = Alignment(horizontal='center')
result_data.cell(2, 5 + env_columns).font = Font(bold=True)
result_data.cell(2, 5 + env_columns).fill = PatternFill("solid", fgColor="00CCCCFF")
result_data.cell(2, 5 + env_columns).alignment = Alignment(horizontal='center')
for html_report in sorted(os.listdir('public')):
if html_report.endswith('.html') and env in html_report:
executed_requests = 'N/C'
failed_request = 'N/C'
executed = 'N/C'
failed = 'N/C'
html = open('public/' + html_report, 'r', encoding='utf-8').read()
parsed_report = BS(html, 'html.parser')
text_data = parsed_report.find_all('div', class_='col-sm-12 mb-3')[2].get_text().split()
for line in range(len(text_data)):
if text_data[line] == 'Requests':
executed_requests = int(text_data[line + 1])
failed_request = int(text_data[line + 2])
if text_data[line] == 'Assertions':
executed = int(text_data[line + 1])
failed = int(text_data[line + 2])
if failed_request == 0:
result_data.cell(ordered_collections[html_report.split('.')[1]], 2 + env_columns).value = \
executed_requests
else:
print("Something wrong while populating env file names")
#
#Get the summary of Total requests pass/fail, Total assertions pass/fail, Total tests skipped
mytab = bs.findAll("table", {"class": "table table-striped table-bordered"})
txt2 = mytab[0].get_text()
summaryInfo = txt2.split()
# Initialize the values
totalRequestsPassed = 0
totalRequestsFailed = 0
totalAssertionPassed = 0
totalAssertionFailed = 0
skippedTests = 0
count = 0
# Parse and extract all the necessary values
for info in summaryInfo:
if (count == 5):
totalRequestsPassed = info
elif (count == 6):
totalRequestsFailed = info
elif (count == 16):
totalAssertionPassed = info
elif (count == 17):
totalAssertionFailed = info
elif (count == 20):
skippedTests = info
count += 1
# 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)
result_data.cell(ordered_collections[html_report.split('.')[1]], 2 + env_columns).value = \
f'{executed_requests}/{failed_request}'
result_data.cell(ordered_collections[html_report.split('.')[1]], 2 + env_columns).font = \
Font(bold=True, color='00FF0000')
result_data.cell(ordered_collections[html_report.split('.')[1]], 2 + env_columns).fill = \
PatternFill("solid", fgColor="d2e9c3")
result_data.cell(ordered_collections[html_report.split('.')[1]], 2 + env_columns).alignment = \
Alignment(horizontal='center')
result_data.cell(ordered_collections[html_report.split('.')[1]], 3 + env_columns).value = executed
result_data.cell(ordered_collections[html_report.split('.')[1]], 3 + env_columns).alignment = \
Alignment(horizontal='center')
result_data.cell(ordered_collections[html_report.split('.')[1]], 4 + env_columns).value = failed
result_data.cell(ordered_collections[html_report.split('.')[1]], 4 + env_columns).alignment = \
Alignment(horizontal='center')
if failed == 'N/C':
pass_rate = 'N/C'
elif failed == 0:
pass_rate = 100
result_data.cell(ordered_collections[html_report.split('.')[1]], 5 + env_columns).font = \
Font(color='00339966', bold=True)
else:
passRate = 0.0
# print("totalRequestsPassed: " + totalRequestsPassed)
# print("totalRequestsFailed: " + totalRequestsFailed)
# print("totalAssertionPassed: " + totalAssertionPassed)
# print("totalAssertionFailed: " + totalAssertionFailed)
# print("skippedTests: " + skippedTests)
# print(passRate)
#
# save the information
records.append((collectionName, totalRequestsPassed, totalAssertionPassed, totalAssertionFailed, passRate ))
curRow = len(records) - 1
# print(records[curRow])
# write the data to Excel file
for col_num, data in enumerate(records[curRow]):
l_colNum = col_num
if (col_num > 1) and (colOffset > 5):
l_colNum = col_num + colOffset-2
if (l_colNum == 0):
worksheet.write(rowNo, l_colNum, data, collection_cell_format)
elif (l_colNum == 1):
worksheet.write(rowNo, l_colNum, int(data), request_cell_format)
elif (l_colNum in pctColList):
if (passRate >= 100.0):
worksheet.write(rowNo, l_colNum, data, greenPct_cell_format)
elif (passRate < 60.0):
worksheet.write(rowNo, l_colNum, data, redPct_cell_format)
pass_rate = round((executed - failed) * 100 / executed, 2)
if pass_rate < 60:
result_data.cell(ordered_collections[html_report.split('.')[1]], 5 + env_columns).font = \
Font(color='00FF0000', bold=True)
else:
worksheet.write(rowNo, l_colNum, data, pct_cell_format)
result_data.cell(ordered_collections[html_report.split('.')[1]], 5 + env_columns).font = Font(
bold=True)
result_data.cell(ordered_collections[html_report.split('.')[1]], 5 + env_columns).value = pass_rate
result_data.cell(ordered_collections[html_report.split('.')[1]], 5 + env_columns).alignment = \
Alignment(horizontal='center')
raw_data_csv_file = '../pass_rate/raw_data.csv'
headers = ['Collection', 'Date', 'Time', 'Env', 'Requests', 'Pass', 'Fail', 'Pass Rate', 'Service Version',
'Run Mode']
if not os.path.isfile(raw_data_csv_file):
with open(raw_data_csv_file, 'w', newline='') as csvfile:
writer = csv.DictWriter(csvfile, fieldnames=headers, delimiter=',')
writer.writeheader()
with open(raw_data_csv_file, 'a', newline='') as csvfile:
writer = csv.DictWriter(csvfile, fieldnames=headers, delimiter=',')
writer.writerow({
'Collection': html_report.split('.')[1].split('CI-CD')[0].replace('_', ' '),
'Date': strftime("%Y/%m/%d", gmtime()),
'Time': strftime("%H:%M:%S", gmtime()),
'Env': env,
'Requests': executed_requests,
'Pass': executed - failed,
'Fail': failed,
'Pass Rate': pass_rate,
'Service Version': 'n/a',
'Run Mode': 'CI/CD'
})
total_requests = [result_data.cell(i, 2 + env_columns).value for i in range(3, total_row_number)]
for i in range(len(total_requests)):
if isinstance(total_requests[i], str):
total_requests[i] = int(total_requests[i].split('/')[0])
if total_requests[i] is None:
total_requests[i] = 0
result_data.cell(total_row_number, 2 + env_columns).value = sum(total_requests)
result_data.cell(total_row_number, 2 + env_columns).font = Font(bold=True)
result_data.cell(total_row_number, 2 + env_columns).fill = PatternFill("solid", fgColor="d2e9c3")
result_data.cell(total_row_number, 2 + env_columns).alignment = Alignment(horizontal='center')
total_executed = [result_data.cell(i, 3 + env_columns).value for i in range(3, total_row_number)]
for i in range(len(total_executed)):
if isinstance(total_executed[i], str) or total_executed[i] is None:
total_executed[i] = 0
result_data.cell(total_row_number, 3 + env_columns).value = sum(total_executed)
result_data.cell(total_row_number, 3 + env_columns).font = Font(bold=True)
result_data.cell(total_row_number, 3 + env_columns).fill = PatternFill("solid", fgColor="d2e9c3")
result_data.cell(total_row_number, 3 + env_columns).alignment = Alignment(horizontal='center')
total_pass = [result_data.cell(i, 4 + env_columns).value for i in range(3, total_row_number)]
for i in range(len(total_pass)):
if isinstance(total_pass[i], str) or total_pass[i] is None:
total_pass[i] = 0
result_data.cell(total_row_number, 4 + env_columns).value = sum(total_pass)
result_data.cell(total_row_number, 4 + env_columns).font = Font(bold=True)
result_data.cell(total_row_number, 4 + env_columns).fill = PatternFill("solid", fgColor="d2e9c3")
result_data.cell(total_row_number, 4 + env_columns).alignment = Alignment(horizontal='center')
total_pass_rate = [result_data.cell(i, 5 + env_columns).value for i in range(3, total_row_number)]
for i in range(len(total_pass_rate)):
if isinstance(total_pass_rate[i], str) or total_pass_rate[i] is None:
total_pass_rate[i] = 0
total_pass_rate_value = round(sum(total_pass_rate) / len(range(3, total_row_number)), 2)
result_data.cell(total_row_number, 5 + env_columns).value = total_pass_rate_value
if total_pass_rate_value > 90:
result_data.cell(total_row_number, 5 + env_columns).font = Font(bold=True, color='00339966')
elif total_pass_rate_value < 60:
result_data.cell(total_row_number, 5 + env_columns).font = Font(bold=True, color='00FF0000')
else:
worksheet.write(rowNo, l_colNum, int(data), cell_format)
#
#Extract run Date Info only once from the first collection
if (len(collection_run_date) == 0):
mydivs3 = bs.findAll("div", {"class": "col-md-9 col-lg-12 main"})
txt3 = mydivs3[0].get_text()
dateInfo = txt3.split("\n")
collection_run_date.append(dateInfo[2])
#
#=======================================================================================================
# Start of Main
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
pctColList = [4,8,12,16] # column list that hold passRate (percent) values
passColList = [2,6,10,14] # column list that hold number of request pass values
failColList = [3,7,11,15] # column list that hold number of request fail values
#
# Define the headers for the excel file
records.append(("","","","AWS","","","","AZURE","","","","GCP","","","","IBM",""))
# Note: Pass column name was changed to Executed. The variable names were not changed only column name was changed.
records.append(("Collection Name", "#of Requests", "Executed", "Fail", "PassRate","","Executed", "Fail", "PassRate","","Executed", "Fail", "PassRate","","Executed", "Fail", "PassRate"))
#Create and initialize the excel file
workbook = xlsxwriter.Workbook('NewmanHtmlReportsSummary.xlsx')
worksheet = workbook.add_worksheet()
# set the column width
worksheet.set_column(0, 0, 40) # Column for Collection Name
worksheet.set_column(1, 1, 12) # Column for number of request
for iCol in passColList:
worksheet.set_column(iCol, iCol, 10) # column width for executed
# set variaous formats that will be used to wirte the data to the Excel file
cell_format = workbook.add_format({'align': 'center', 'bold': True})
#
summ_cell_format = workbook.add_format({'align': 'left', 'bold': True})
summ_right_cell_format = workbook.add_format({'align': 'right', 'bold': True})
#
request_cell_format = workbook.add_format({'align': 'center', 'bg_color': '#D8E4BC'})
#
collection_cell_format = workbook.add_format({'align': 'center', 'bold': True})
collection_cell_format.set_font_color('blue')
#
total_cell_format = workbook.add_format({'align': 'center', 'bold': True, 'bg_color': 'orange', 'font_color': 'blue'})
#
total_num_cell_format = workbook.add_format({'align': 'center', 'bold': True, 'bg_color': 'orange', 'font_color': 'blue'})
total_num_cell_format.set_num_format('0')
#
total_pct_cell_format = workbook.add_format({'align': 'center', 'bold': True, 'bg_color': 'orange', 'font_color': 'blue'})
total_pct_cell_format.set_num_format('0.00')
#
pct_cell_format = workbook.add_format({'align': 'center', 'bold': True})
pct_cell_format.set_num_format('0.00')
#
greenPct_cell_format = workbook.add_format({'align': 'center', 'bold': True})
greenPct_cell_format.set_font_color('green')
greenPct_cell_format.set_num_format('0.00')
#
redPct_cell_format = workbook.add_format({'align': 'center', 'bold': True})
redPct_cell_format.set_font_color('red')
redPct_cell_format.set_num_format('0.00')
#
head_cell_format = workbook.add_format({'align': 'center', 'bold': True, 'bg_color': '#78B0DE'})
head_cell_format.set_font_size(14)
#
head2_cell_format = workbook.add_format({'align': 'center', 'bold': True, 'bg_color': '#BBD7EF', 'font_color': 'black'})
head2_cell_format.set_font_size(12)
#
head2_green_cell_format = workbook.add_format({'align': 'center', 'bold': True, 'bg_color': '#BBD7EF', 'font_color': 'green'})
head2_green_cell_format.set_font_size(12)
head2_red_cell_format = workbook.add_format({'align': 'center', 'bold': True, 'bg_color': '#BBD7EF', 'font_color': 'red'})
head2_red_cell_format.set_font_size(12)
#
#Write the header records to excel file
rowNum = 0
col_offset = 0
for row_num in records:
for col_num, data in enumerate(records[rowNum]):
if (rowNum == 0):
worksheet.write(rowNum, col_num, data, head_cell_format)
else:
# print("rowNum: ", rowNum, " col_num: ", col_num)
if (rowNum == 1):
if (col_num in passColList):
worksheet.write(rowNum, col_num, data, head2_green_cell_format)
elif (col_num in failColList):
worksheet.write(rowNum, col_num, data, head2_red_cell_format)
else:
worksheet.write(rowNum, col_num, data, head2_cell_format)
rowNum += 1
#process all the reports to summarize the results
curPlatform = ""
localRowNo = rowNum
collName = []
for file in sorted(os.listdir(".")):
if (file.endswith(".html")): # process only html files
fileParts = file.split(".")
if (fileParts[0] == "index"):
print("Skip - " + file) # skip processing of index.html file
continue
else:
# print(file)
# Extract platform from the filename and set the start column offset value for the platform
# First platform (AWS) start column offset also accomodates number of request column
if (fileParts[0] != curPlatform):
#
localRowNo = rowNum
curPlatform = fileParts[0]
#
if (fileParts[0] == "aws"):
col_offset = 0
elif (fileParts[0] == "azure"):
col_offset = 6
elif (fileParts[0] == "gcp"):
col_offset = 10
elif (fileParts[0] == "ibm"):
col_offset = 14
else:
print("Invalid platform: " + fileParts[0])
continue
env_file_names_populated = False # platform changed, save environment file
else:
env_file_names_populated = True # want to save environment file only once for each platform
if (fileParts[0] == "aws"):
collName.append(fileParts[1])
# Process, extract and write the information to the Excel file
processFile(file, fileParts[0], localRowNo, col_offset, env_file_names_populated) # process html report file
localRowNo += 1
print("")
# Summarize the results
print("Total number of collections: ", len(collName) )
print("Total number of reports summarized: ", (len(records)-2) )
print("Total number of platforms", ((len(records) - 2)/len(collName)) )
# Populate the Separator columns
fill_cell_format = workbook.add_format({'bg_color': '#FFE1E5'})
total_row_num = len(collName) + 2
colList = [5,9,13]
for i in range(2, total_row_num):
for j in range(len(colList)):
worksheet.write(i, colList[j], "", fill_cell_format)
# Write the summary data to the Excel file, Values for the Total row, Collection run and summary report date and list of environment files
total_cols = 17
rowIndx = total_row_num
rowIndxStr = str(rowIndx+1)
sumStartIdx =3
sumEndIdx = rowIndx
sumStartIdxStr = str(sumStartIdx)
sumEndIdxStr = str(sumEndIdx)
# popluate the arrays to sum the pass, fail and passRate values for each platform as well as total number of requests
# e.g. [ ['B14', '{=SUM(B3:B13)}'],...,[...]]
# passRate = (100 * ( (float(totalAssertionPassed) - float(totalAssertionFailed)) / float(totalAssertionPassed) ) )
# E14 = 100 * ( (C14-D14)/C14) )
# "E"+rowIndxStr, "{=(100.0 * ( (C"+rowIndxStr+"-D"+rowIndxStr+")/C"+rowIndxStr +") )}"
col_lables = [["B"+rowIndxStr, "{=SUM(B"+sumStartIdxStr+":B"+sumEndIdxStr+")}"], ["C"+rowIndxStr, "{=SUM(C"+sumStartIdxStr+":C"+sumEndIdxStr+")}"],
["D"+rowIndxStr, "{=SUM(D"+sumStartIdxStr+":D"+sumEndIdxStr+")}"], ["E"+rowIndxStr, "{=(100.0 * ( (C"+rowIndxStr+"-D"+rowIndxStr+")/C"+rowIndxStr +") )}"],
["G"+rowIndxStr, "{=SUM(G"+sumStartIdxStr+":G"+sumEndIdxStr+")}"], ["H"+rowIndxStr, "{=SUM(H"+sumStartIdxStr+":H"+sumEndIdxStr+")}"], ["I"+rowIndxStr, "{=(100.0 * ( (G"+rowIndxStr+"-H"+rowIndxStr+")/G"+rowIndxStr +") )}"],
["K"+rowIndxStr, "{=SUM(K"+sumStartIdxStr+":K"+sumEndIdxStr+")}"], ["L"+rowIndxStr, "{=SUM(L"+sumStartIdxStr+":L"+sumEndIdxStr+")}"], ["M"+rowIndxStr, "{=(100.0 * ( (K"+rowIndxStr+"-L"+rowIndxStr+")/K"+rowIndxStr +") )}"],
["O"+rowIndxStr, "{=SUM(O"+sumStartIdxStr+":O"+sumEndIdxStr+")}"], ["P"+rowIndxStr, "{=SUM(P"+sumStartIdxStr+":P"+sumEndIdxStr+")}"], ["Q"+rowIndxStr, "{=(100.0 * ( (O"+rowIndxStr+"-P"+rowIndxStr+")/O"+rowIndxStr +") )}"]]
col_label_indx = 0
# Populate/write the Total Row
for j in range(total_cols):
if (j == 0):
worksheet.write(rowIndx, j, "Total", total_cell_format)
elif (j in fillColList):
worksheet.write(total_row_num, j, "", total_cell_format)
# continue
else:
colIndx = col_lables[col_label_indx]
if (j in pctColList):
worksheet.write_formula(colIndx[0], colIndx[1], total_pct_cell_format)
else:
worksheet.write_formula(colIndx[0], colIndx[1], total_num_cell_format)
col_label_indx += 1
# Write the collection run date
date_time_obj = datetime.datetime.strptime(collection_run_date[0], '%A, %d %B %Y %H:%M:%S')
str1 = "Collection run date: " + date_time_obj.strftime('%m/%d/%Y, %H:%M:%S')
rowIndx += 2
worksheet.write(rowIndx, 0, str1, summ_cell_format)
# Write the summary report date
# str1 = "Summary report run date:\t " + (datetime.datetime.now().strftime('%A, %d %B %Y %H:%M:%S'))
str1 = "Summary report date: " + (datetime.datetime.now().strftime('%m/%d/%Y, %H:%M:%S'))
rowIndx += 1
worksheet.write(rowIndx, 0, str1, summ_cell_format)
# Wrtie the list of environment files
rowIndx += 1
worksheet.write(rowIndx, 0, "Environment Files:", summ_cell_format)
numOfEnvs = len(env_file_names)
rowIndx += 1
for i in range(numOfEnvs):
worksheet.write(rowIndx, 0, env_file_names[i], cell_format)
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));
result_data.cell(total_row_number, 5 + env_columns).font = Font(bold=True)
result_data.cell(total_row_number, 5 + env_columns).fill = PatternFill("solid", fgColor="d2e9c3")
result_data.cell(total_row_number, 5 + env_columns).alignment = Alignment(horizontal='center')
if env_number < (len(envs) - 1):
result_data.cell(total_row_number, 6 + env_columns).fill = PatternFill("solid", fgColor="d2e9c3")
env_number += 1
# Log some summary data
print(env_file_names)
print(collection_run_date)
print("Summary Report Date: ", datetime.datetime.now())
print("Done")
exit()
# End
for col in result_data.columns:
max_length = 0
column = col[1].column_letter
for cell in col:
if len(str(cell.value)) > max_length: