Changeset View
Changeset View
Standalone View
Standalone View
contrib/buildbot/server.py
Show First 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | |||||
# logo='data:image/png;base64,{}'.format( | # logo='data:image/png;base64,{}'.format( | ||||
# icon.read().strip().decode('utf-8')), | # icon.read().strip().decode('utf-8')), | ||||
# ) | # ) | ||||
BADGE_TC_BASE = RasterBadge( | BADGE_TC_BASE = RasterBadge( | ||||
label='TC build', | label='TC build', | ||||
logo='TeamCity' | logo='TeamCity' | ||||
) | ) | ||||
BADGE_TRAVIS_BASE = RasterBadge( | BADGE_CIRRUS_BASE = RasterBadge( | ||||
label='Travis build', | label='Cirrus build', | ||||
logo='travis' | logo='cirrus-ci' | ||||
) | ) | ||||
def create_server(tc, phab, slackbot, travis, | def create_server(tc, phab, slackbot, cirrus, | ||||
db_file_no_ext=None, jsonEncoder=None): | db_file_no_ext=None, jsonEncoder=None): | ||||
# Create Flask app for use as decorator | # Create Flask app for use as decorator | ||||
app = Flask("abcbot") | app = Flask("abcbot") | ||||
app.logger.setLevel(logging.INFO) | app.logger.setLevel(logging.INFO) | ||||
# json_encoder can be overridden for testing | # json_encoder can be overridden for testing | ||||
if jsonEncoder: | if jsonEncoder: | ||||
app.json_encoder = jsonEncoder | app.json_encoder = jsonEncoder | ||||
phab.setLogger(app.logger) | phab.setLogger(app.logger) | ||||
tc.set_logger(app.logger) | tc.set_logger(app.logger) | ||||
travis.set_logger(app.logger) | cirrus.set_logger(app.logger) | ||||
# 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 | ||||
▲ Show 20 Lines • Show All 515 Lines • ▼ Show 20 Lines | def update_build_status_panel(updated_build_type_id): | ||||
return panel_content + line + '\n' | return panel_content + line + '\n' | ||||
def add_project_header_to_panel(project_name): | def add_project_header_to_panel(project_name): | ||||
return panel_content + ( | return panel_content + ( | ||||
'| {} | Status |\n' | '| {} | Status |\n' | ||||
'|---|---|\n' | '|---|---|\n' | ||||
).format(project_name) | ).format(project_name) | ||||
# secp256k1 is a special case because it has a Travis build from a | # secp256k1 is a special case because it has a Cirrus build from a | ||||
# Github repo that is not managed by the build-configurations.yml config. | # Github repo that is not managed by the build-configurations.yml config. | ||||
# The status always need to be fetched. | # The status always need to be fetched. | ||||
sepc256k1_default_branch = 'master' | sepc256k1_cirrus_status = cirrus.get_default_branch_status() | ||||
sepc256k1_travis_status = travis.get_branch_status( | cirrus_badge_url = BADGE_CIRRUS_BASE.get_badge_url( | ||||
27431354, sepc256k1_default_branch) | message=sepc256k1_cirrus_status.value, | ||||
travis_badge_url = BADGE_TRAVIS_BASE.get_badge_url( | color=('brightgreen' if sepc256k1_cirrus_status == BuildStatus.Success else | ||||
message=sepc256k1_travis_status.value, | 'red' if sepc256k1_cirrus_status == BuildStatus.Failure else | ||||
color='brightgreen' if sepc256k1_travis_status == BuildStatus.Success else 'red', | 'blue' if sepc256k1_cirrus_status == BuildStatus.Running else | ||||
'lightblue' if sepc256k1_cirrus_status == BuildStatus.Queued else | |||||
'inactive'), | |||||
) | ) | ||||
# Add secp256k1 Travis to the status panel. | # Add secp256k1 Cirrus to the status panel. | ||||
panel_content = add_project_header_to_panel( | panel_content = add_project_header_to_panel( | ||||
'secp256k1 ([[https://github.com/Bitcoin-ABC/secp256k1 | Github]])') | 'secp256k1 ([[https://github.com/Bitcoin-ABC/secp256k1 | Github]])') | ||||
panel_content = add_line_to_panel( | panel_content = add_line_to_panel( | ||||
'| [[{} | {}]] | {{image uri="{}", alt="{}"}} |'.format( | '| [[{} | {}]] | {{image uri="{}", alt="{}"}} |'.format( | ||||
'https://travis-ci.org/github/bitcoin-abc/secp256k1', | 'https://cirrus-ci.com/github/Bitcoin-ABC/secp256k1', | ||||
sepc256k1_default_branch, | 'master', | ||||
travis_badge_url, | cirrus_badge_url, | ||||
sepc256k1_travis_status.value, | sepc256k1_cirrus_status.value, | ||||
) | ) | ||||
) | ) | ||||
panel_content = add_line_to_panel('') | panel_content = add_line_to_panel('') | ||||
# Download the build configuration from master | # Download the build configuration from master | ||||
config = yaml.safe_load(phab.get_file_content_from_master( | config = yaml.safe_load(phab.get_file_content_from_master( | ||||
"contrib/teamcity/build-configurations.yml")) | "contrib/teamcity/build-configurations.yml")) | ||||
▲ Show 20 Lines • Show All 436 Lines • Show Last 20 Lines |