Changeset View
Changeset View
Standalone View
Standalone View
contrib/buildbot/server.py
#!/usr/bin/env python3 | #!/usr/bin/env python3 | ||||
# | # | ||||
# Copyright (c) 2019 The Bitcoin ABC developers | # Copyright (c) 2019 The Bitcoin ABC developers | ||||
# Distributed under the MIT software license, see the accompanying | # Distributed under the MIT software license, see the accompanying | ||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php. | # file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
from build import BuildStatus, BuildTarget | from build import BuildStatus, BuildTarget | ||||
from flask import abort, Flask, request | from flask import abort, Flask, request | ||||
from functools import wraps | from functools import wraps | ||||
import hashlib | import hashlib | ||||
import hmac | import hmac | ||||
import json | |||||
import os | import os | ||||
from phabricator_wrapper import ( | from phabricator_wrapper import ( | ||||
BITCOIN_ABC_PROJECT_PHID, | BITCOIN_ABC_PROJECT_PHID, | ||||
) | ) | ||||
import re | import re | ||||
from shieldio import RasterBadge | from shieldio import RasterBadge | ||||
from shlex import quote | from shlex import quote | ||||
from teamcity import TeamcityRequestException | from teamcity import TeamcityRequestException | ||||
import yaml | |||||
# Some keywords used by TeamCity and tcWebHook | # Some keywords used by TeamCity and tcWebHook | ||||
SUCCESS = "success" | SUCCESS = "success" | ||||
FAILURE = "failure" | FAILURE = "failure" | ||||
RUNNING = "running" | RUNNING = "running" | ||||
UNRESOLVED = "UNRESOLVED" | UNRESOLVED = "UNRESOLVED" | ||||
▲ Show 20 Lines • Show All 183 Lines • ▼ Show 20 Lines | def build_diff(): | ||||
) | ) | ||||
) | ) | ||||
return value | return value | ||||
staging_ref = get_mandatory_argument('stagingRef') | staging_ref = get_mandatory_argument('stagingRef') | ||||
target_phid = get_mandatory_argument('targetPHID') | target_phid = get_mandatory_argument('targetPHID') | ||||
# Get the configuration from master | # Get the configuration from master | ||||
config = json.loads(phab.get_file_content_from_master( | config = yaml.safe_load(phab.get_file_content_from_master( | ||||
"contrib/teamcity/build-configurations.json")) | "contrib/teamcity/build-configurations.yaml")) | ||||
# Get a list of the builds that should run on diffs | # Get a list of the builds that should run on diffs | ||||
builds = [ | builds = [ | ||||
k for k, | k for k, | ||||
v in config.get( | v in config.get( | ||||
'builds', | 'builds', | ||||
{}).items() if v.get( | {}).items() if v.get( | ||||
'runOnDiff', | 'runOnDiff', | ||||
▲ Show 20 Lines • Show All 213 Lines • ▼ Show 20 Lines | def update_build_status_panel(updated_build_type_id): | ||||
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 Travis build from a | ||||
# Github repo that is not managed by the build-configurations.json 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_default_branch = 'master' | ||||
sepc256k1_travis_status = travis.get_branch_status( | sepc256k1_travis_status = travis.get_branch_status( | ||||
27431354, sepc256k1_default_branch) | 27431354, sepc256k1_default_branch) | ||||
travis_badge_url = BADGE_TRAVIS_BASE.get_badge_url( | travis_badge_url = BADGE_TRAVIS_BASE.get_badge_url( | ||||
message=sepc256k1_travis_status.value, | message=sepc256k1_travis_status.value, | ||||
color='brightgreen' if sepc256k1_travis_status == BuildStatus.Success else 'red', | color='brightgreen' if sepc256k1_travis_status == BuildStatus.Success else 'red', | ||||
) | ) | ||||
# Add secp256k1 Travis to the status panel. | # Add secp256k1 Travis 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://travis-ci.org/github/bitcoin-abc/secp256k1', | ||||
sepc256k1_default_branch, | sepc256k1_default_branch, | ||||
travis_badge_url, | travis_badge_url, | ||||
sepc256k1_travis_status.value, | sepc256k1_travis_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 = json.loads(phab.get_file_content_from_master( | config = yaml.safe_load(phab.get_file_content_from_master( | ||||
"contrib/teamcity/build-configurations.json")) | "contrib/teamcity/build-configurations.yml")) | ||||
# Get a list of the builds to display | # Get a list of the builds to display | ||||
config_build_names = [ | config_build_names = [ | ||||
k for k, v in config.get( | k for k, v in config.get( | ||||
'builds', {}).items() if not v.get( | 'builds', {}).items() if not v.get( | ||||
'hideOnStatusPanel', False)] | 'hideOnStatusPanel', False)] | ||||
# If there is no build to display, don't update the panel with teamcity | # If there is no build to display, don't update the panel with teamcity | ||||
▲ Show 20 Lines • Show All 421 Lines • Show Last 20 Lines |