Changing Jenkins HTML build output

pull/1040/head
Brian Daniels 2015-03-31 17:56:00 -05:00
parent 1f6b56d060
commit 8576f74b3c
5 changed files with 105 additions and 32 deletions

View File

@ -29,6 +29,8 @@ from workspace_tools.paths import MBED_TARGETS_PATH, MBED_LIBRARIES, MBED_API, M
from workspace_tools.targets import TARGET_NAMES, TARGET_MAP
from workspace_tools.libraries import Library
from workspace_tools.toolchains import TOOLCHAIN_CLASSES
from jinja2 import FileSystemLoader
from jinja2.environment import Environment
def build_project(src_path, build_path, target, toolchain_name,
@ -531,34 +533,67 @@ def print_build_results(result_list, build_name):
return result
def write_build_report(build_report, filename):
with open(filename, 'w+') as f:
f.write('<section name="Build Summary">\n')
f.write('\t<table sorttable="yes">\n')
build_report_failing = []
build_report_passing = []
f.write('\t\t<tr>\n')
f.write('\t\t\t<td value="Target" fontattribute="bold" />\n')
f.write('\t\t\t<td value="Successes" fontattribute="bold" />\n')
f.write('\t\t\t<td value="Failures" fontattribute="bold" />\n')
f.write('\t\t</tr>\n')
for report in build_report:
if len(report["failing"]) > 0:
build_report_failing.append(report)
else:
build_report_passing.append(report)
'''build_report_failing = [{
"target": "K64F",
"passing": [
{
"toolchain": "GCC_ARM"
},
{
"toolchain": "ARM"
}
],
"failing": [
{
"toolchain": "GCC_CS"
},
{
"toolchain": "IAR"
}
]
},
{
"target": "KL46Z",
"passing": [
{
"toolchain": "GCC_ARM"
}
],
"failing": [
{
"toolchain": "ARM"
},
{
"toolchain": "IAR"
}
]
}]
for report in build_report:
f.write('\t\t<tr>\n')
build_report_passing = [{
"target": "LPC1768",
"passing": [
{
"toolchain": "GCC_ARM"
},
{
"toolchain": "ARM"
}
],
"failing": []
}]'''
color = "#009933"
env = Environment(extensions=['jinja2.ext.with_'])
env.loader = FileSystemLoader('ci_templates/library_build')
template = env.get_template('report.html')
if len(report["failures"]) > 0:
color = "#FF0000"
target_cell = '\t\t\t<td value="%s" bgcolor="%s"/>\n' % (report["target"], color)
f.write(target_cell)
successes_cell = '\t\t\t<td value="%s" />\n' % ("\n".join(report["successes"]))
f.write(successes_cell)
failures_cell = '\t\t\t<td value="%s" />\n' % ("\n".join(report["failures"]))
f.write(failures_cell)
f.write('\t\t</tr>\n')
f.write('\t</table>\n')
f.write('</section>\n')
with open(filename, 'w+') as f:
f.write(template.render(failing_builds=build_report_failing, passing_builds=build_report_passing))

View File

@ -101,7 +101,7 @@ if __name__ == '__main__':
default=False, help="Verbose diagnostic output")
parser.add_option("-t", "--toolchains", dest="toolchains", help="Use toolchains names separated by comma")
parser.add_option("", "--report-jenkins", dest="report_jenkins_file", help="Output the build results to an xml file that is readable by Jenkins")
parser.add_option("", "--report-jenkins", dest="report_jenkins_file_name", help="Output the build results to an xml file that is readable by Jenkins")
options, args = parser.parse_args()
@ -121,17 +121,17 @@ if __name__ == '__main__':
toolchains = toolchainSet and set((options.toolchains).split(','))
cur_target_build_report = { "target": target_name, "successes": [], "failures": []}
cur_target_build_report = { "target": target_name, "passing": [], "failing": []}
for toolchain in toolchains:
id = "%s::%s" % (target_name, toolchain)
try:
build_mbed_libs(TARGET_MAP[target_name], toolchain, verbose=options.verbose, jobs=options.jobs)
successes.append(id)
cur_target_build_report["successes"].append(toolchain)
cur_target_build_report["passing"].append({ "toolchain": toolchain })
except Exception, e:
failures.append(id)
cur_target_build_report["failures"].append(toolchain)
cur_target_build_report["failing"].append({ "toolchain": toolchain })
print e
if len(toolchains) > 0:
@ -140,7 +140,7 @@ if __name__ == '__main__':
# Write summary of the builds
if options.report_jenkins_file:
write_build_report(build_report, options.report_jenkins_file)
write_build_report(build_report, options.report_jenkins_file_name)
print "\n\nCompleted in: (%.2f)s" % (time() - start)

View File

@ -0,0 +1,19 @@
<div>
<h3>
{% if report.failing|length > 0 %}
<span class="redbold">[FAIL]</span>
{% else %}
<span class="greenbold">[OK]</span>
{% endif %}
{{report.target}} - Passing: {{report.passing|length}}, Failing: {{report.failing|length}}</h3>
<h4>Failing</h4>
{% with build = report.failing %}
{% include 'build_report_table.html' %}
{% endwith %}
<h4>Passing</h4>
{% with build = report.passing %}
{% include 'build_report_table.html' %}
{% endwith %}
</div>

View File

@ -0,0 +1,10 @@
<table>
<tr>
<th>Toolchain</th>
</tr>
{% for run in build %}
<tr>
<td>{{run.toolchain}}</td>
</tr>
{% endfor %}
</table>

View File

@ -0,0 +1,9 @@
<h2>Failing Builds</h2>
{% for report in failing_builds %}
{% include 'build_report.html' %}
{% endfor %}
<h2>Passing Builds</h2>
{% for report in passing_builds %}
{% include 'build_report.html' %}
{% endfor %}