Changeset View
Changeset View
Standalone View
Standalone View
contrib/buildbot/server.py
Show First 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | def create_server(tc, phab, slackbot, travis, | ||||
# Optionally persistable database | # Optionally persistable database | ||||
create_server.db = { | create_server.db = { | ||||
# A collection of the known build targets | # A collection of the known build targets | ||||
'diff_targets': {}, | 'diff_targets': {}, | ||||
# Build status panel data | # Build status panel data | ||||
'panel_data': {}, | 'panel_data': {}, | ||||
# Whether the last status check of master was green | # Whether the last status check of master was green | ||||
'master_is_green': True, | 'master_is_green': True, | ||||
# Coverage panel data | |||||
'coverage_data': {}, | |||||
} | } | ||||
# If db_file_no_ext is not None, attempt to restore old database state | # If db_file_no_ext is not None, attempt to restore old database state | ||||
if db_file_no_ext: | if db_file_no_ext: | ||||
app.logger.info( | app.logger.info( | ||||
"Loading persisted state database with base name '{}'...".format(db_file_no_ext)) | "Loading persisted state database with base name '{}'...".format(db_file_no_ext)) | ||||
try: | try: | ||||
with shelve.open(db_file_no_ext, flag='r') as db: | with shelve.open(db_file_no_ext, flag='r') as db: | ||||
▲ Show 20 Lines • Show All 677 Lines • ▼ Show 20 Lines | def update_build_status_panel(updated_build_type_id): | ||||
badge_url, | badge_url, | ||||
build_status_message, | build_status_message, | ||||
) | ) | ||||
) | ) | ||||
panel_content = add_line_to_panel('') | panel_content = add_line_to_panel('') | ||||
phab.set_text_panel_content(17, panel_content) | phab.set_text_panel_content(17, panel_content) | ||||
def update_coverage_panel(coverage_summary): | def update_coverage_panel(build_type_id, project_name, coverage_summary): | ||||
# FIXME don't harcode the permalink but pull it from some configuration | coverage_permalink = "**[[ https://build.bitcoinabc.org/viewLog.html?buildId=lastSuccessful&buildTypeId={}&tab=report__Root_Code_Coverage&guest=1 | {} coverage report ]]**\n\n".format( | ||||
coverage_permalink = "**[[ https://build.bitcoinabc.org/viewLog.html?buildId=lastSuccessful&buildTypeId=BitcoinABC_Master_BitcoinAbcMasterCoverage&tab=report__Root_Code_Coverage&guest=1 | HTML coverage report ]]**\n\n" | build_type_id, project_name) | ||||
coverage_report = "| Granularity | % hit | # hit | # total |\n" | coverage_report = "| Granularity | % hit | # hit | # total |\n" | ||||
coverage_report += "| ----------- | ----- | ----- | ------- |\n" | coverage_report += "| ----------- | ----- | ----- | ------- |\n" | ||||
# Convert the textual coverage summary report to a pretty remarkup | # Convert the textual coverage summary report to a pretty remarkup | ||||
# content. | # content. | ||||
# | # | ||||
# The content loooks like this: | # The content loooks like this: | ||||
Show All 13 Lines | def update_coverage_panel(build_type_id, project_name, coverage_summary): | ||||
coverage_report += "| {} | {} | {} | {} |\n".format( | coverage_report += "| {} | {} | {} | {} |\n".format( | ||||
match.group('granularity').capitalize(), | match.group('granularity').capitalize(), | ||||
match.group('percent'), | match.group('percent'), | ||||
match.group('hit'), | match.group('hit'), | ||||
match.group('total'), | match.group('total'), | ||||
) | ) | ||||
# Cache the coverage data for this build type | |||||
coverage_data = create_server.db['coverage_data'] | |||||
coverage_data[build_type_id] = coverage_permalink + coverage_report | |||||
# Update the coverage panel with our remarkup content | # Update the coverage panel with our remarkup content | ||||
phab.set_text_panel_content(21, coverage_permalink + coverage_report) | phab.set_text_panel_content(21, "\n".join(coverage_data.values())) | ||||
def handle_build_result(buildName, buildTypeId, buildResult, | def handle_build_result(buildName, buildTypeId, buildResult, | ||||
buildURL, branch, buildId, buildTargetPHID, **kwargs): | buildURL, branch, buildId, buildTargetPHID, projectName, **kwargs): | ||||
# Do not report build status for ignored builds | # Do not report build status for ignored builds | ||||
if phab.getIgnoreKeyword() in buildTypeId: | if phab.getIgnoreKeyword() in buildTypeId: | ||||
return SUCCESS, 200 | return SUCCESS, 200 | ||||
# Build didn't have a branch | # Build didn't have a branch | ||||
if branch == "UNRESOLVED": | if branch == "UNRESOLVED": | ||||
return FAILURE, 400 | return FAILURE, 400 | ||||
Show All 14 Lines | def handle_build_result(buildName, buildTypeId, buildResult, | ||||
try: | try: | ||||
coverage_summary = tc.get_coverage_summary(buildId) | coverage_summary = tc.get_coverage_summary(buildId) | ||||
except TeamcityRequestException: | except TeamcityRequestException: | ||||
# The coverage report is not guaranteed to exist, in this | # The coverage report is not guaranteed to exist, in this | ||||
# case teamcity will raise an exception. | # case teamcity will raise an exception. | ||||
coverage_summary = None | coverage_summary = None | ||||
if coverage_summary: | if coverage_summary: | ||||
update_coverage_panel(coverage_summary) | update_coverage_panel( | ||||
buildTypeId, projectName, coverage_summary) | |||||
# If we have a buildTargetPHID, report the status. | # If we have a buildTargetPHID, report the status. | ||||
build_target = create_server.db['diff_targets'].get( | build_target = create_server.db['diff_targets'].get( | ||||
buildTargetPHID, None) | buildTargetPHID, None) | ||||
if build_target is not None: | if build_target is not None: | ||||
phab.update_build_target_status(build_target, buildId, status) | phab.update_build_target_status(build_target, buildId, status) | ||||
send_harbormaster_build_link_if_required( | send_harbormaster_build_link_if_required( | ||||
▲ Show 20 Lines • Show All 213 Lines • Show Last 20 Lines |