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 deepmerge import always_merger | |||||
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 logging | import logging | ||||
import os | import os | ||||
from phabricator_wrapper import ( | from phabricator_wrapper import ( | ||||
BITCOIN_ABC_PROJECT_PHID, | BITCOIN_ABC_PROJECT_PHID, | ||||
▲ Show 20 Lines • Show All 243 Lines • ▼ Show 20 Lines | def build_diff(): | ||||
# Get the configuration from master | # Get the 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")) | ||||
# Get the list of changed files | # Get the list of changed files | ||||
changedFiles = phab.get_revision_changed_files( | changedFiles = phab.get_revision_changed_files( | ||||
revision_id=revision_id) | revision_id=revision_id) | ||||
# Get a list of the templates, if any | |||||
templates = config.get("templates", {}) | |||||
# Get a list of the builds that should run on diffs | # Get a list of the builds that should run on diffs | ||||
builds = [] | builds = [] | ||||
for build_name, v in config.get('builds', {}).items(): | for build_name, v in config.get('builds', {}).items(): | ||||
diffRegexes = v.get('runOnDiffRegex', None) | # Merge the templates | ||||
if v.get('runOnDiff', False) or diffRegexes is not None: | template_config = {} | ||||
template_names = v.get("templates", []) | |||||
for template_name in template_names: | |||||
# Raise an error if the template does not exist | |||||
if template_name not in templates: | |||||
raise AssertionError( | |||||
"Build {} configuration inherits from template {}, but the template does not exist.".format( | |||||
build_name, | |||||
template_name | |||||
) | |||||
) | |||||
always_merger.merge( | |||||
template_config, templates.get(template_name)) | |||||
# Retrieve the full build configuration by applying the templates | |||||
build_config = always_merger.merge(template_config, v) | |||||
diffRegexes = build_config.get('runOnDiffRegex', None) | |||||
if build_config.get('runOnDiff', False) or diffRegexes is not None: | |||||
if diffRegexes: | if diffRegexes: | ||||
# If the regex matches at least one changed file, add this | # If the regex matches at least one changed file, add this | ||||
# build to the list. | # build to the list. | ||||
def regexesMatchAnyFile(regexes, files): | def regexesMatchAnyFile(regexes, files): | ||||
for regex in regexes: | for regex in regexes: | ||||
for filename in files: | for filename in files: | ||||
if re.match(regex, filename): | if re.match(regex, filename): | ||||
return True | return True | ||||
▲ Show 20 Lines • Show All 751 Lines • Show Last 20 Lines |