зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1525736: [taskgraph] Allow looking up parameters by project for trust-domains other than `gecko`; r=dustin
Previously, this code looked parameters under `gecko.v2`, but that doesn't work for projects using the out-of-tree taskgraph code, or Thunderbird. This moves the parameter loading slightly later to vary the index used based on trust domain. Differential Revision: https://phabricator.services.mozilla.com/D19028 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
3fcd2d85d2
Коммит
4ecf218463
|
@ -299,7 +299,12 @@ class MachCommands(MachCommandBase):
|
|||
else:
|
||||
input = None
|
||||
|
||||
parameters = taskgraph.parameters.load_parameters_file(options['parameters'])
|
||||
parameters = taskgraph.parameters.load_parameters_file(
|
||||
options['parameters'],
|
||||
strict=False,
|
||||
# FIXME: There should be a way to parameterize this.
|
||||
trust_domain="gecko",
|
||||
)
|
||||
parameters.check()
|
||||
|
||||
root = options['root']
|
||||
|
@ -345,8 +350,7 @@ class MachCommands(MachCommandBase):
|
|||
|
||||
try:
|
||||
self.setup_logging(quiet=options['quiet'], verbose=options['verbose'])
|
||||
parameters = taskgraph.parameters.load_parameters_file(options['parameters'])
|
||||
parameters.check()
|
||||
parameters = taskgraph.parameters.parameters_loader(options['parameters'])
|
||||
|
||||
tgg = taskgraph.generator.TaskGraphGenerator(
|
||||
root_dir=options.get('root'),
|
||||
|
@ -404,14 +408,13 @@ class MachCommands(MachCommandBase):
|
|||
|
||||
try:
|
||||
self.setup_logging(quiet=options['quiet'], verbose=options['verbose'])
|
||||
parameters = taskgraph.parameters.load_parameters_file(options['parameters'])
|
||||
parameters.check()
|
||||
parameters = taskgraph.parameters.parameters_loader(options['parameters'])
|
||||
|
||||
tgg = taskgraph.generator.TaskGraphGenerator(
|
||||
root_dir=options.get('root'),
|
||||
parameters=parameters)
|
||||
|
||||
actions = taskgraph.actions.render_actions_json(parameters, tgg.graph_config)
|
||||
actions = taskgraph.actions.render_actions_json(tgg.parameters, tgg.graph_config)
|
||||
print(json.dumps(actions, sort_keys=True, indent=2, separators=(',', ': ')))
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
|
|
|
@ -185,7 +185,7 @@ class Parameters(ReadOnlyDict):
|
|||
return release_level(self['project'])
|
||||
|
||||
|
||||
def load_parameters_file(filename, strict=True, overrides=None):
|
||||
def load_parameters_file(filename, strict=True, overrides=None, trust_domain=None):
|
||||
"""
|
||||
Load parameters from a path, url, decision task-id or project.
|
||||
|
||||
|
@ -212,7 +212,13 @@ def load_parameters_file(filename, strict=True, overrides=None):
|
|||
if filename.startswith("task-id="):
|
||||
task_id = filename.split("=")[1]
|
||||
elif filename.startswith("project="):
|
||||
index = "gecko.v2.{project}.latest.taskgraph.decision".format(
|
||||
if trust_domain is None:
|
||||
raise ValueError(
|
||||
"Can't specify parameters by project "
|
||||
"if trust domain isn't supplied.",
|
||||
)
|
||||
index = "{trust_domain}.v2.{project}.latest.taskgraph.decision".format(
|
||||
trust_domain=trust_domain,
|
||||
project=filename.split("=")[1],
|
||||
)
|
||||
task_id = find_task_id(index)
|
||||
|
@ -231,3 +237,16 @@ def load_parameters_file(filename, strict=True, overrides=None):
|
|||
kwargs.update(overrides)
|
||||
|
||||
return Parameters(strict=strict, **kwargs)
|
||||
|
||||
|
||||
def parameters_loader(filename, strict=True, overrides=None):
|
||||
def get_parameters(graph_config):
|
||||
parameters = load_parameters_file(
|
||||
filename,
|
||||
strict=strict,
|
||||
overrides=overrides,
|
||||
trust_domain=graph_config["trust-domain"],
|
||||
)
|
||||
parameters.check()
|
||||
return parameters
|
||||
return get_parameters
|
||||
|
|
|
@ -22,7 +22,7 @@ import taskgraph
|
|||
from taskgraph.generator import TaskGraphGenerator
|
||||
from taskgraph.parameters import (
|
||||
ParameterMismatch,
|
||||
load_parameters_file,
|
||||
parameters_loader,
|
||||
)
|
||||
from taskgraph.taskgraph import TaskGraph
|
||||
|
||||
|
@ -81,19 +81,18 @@ def generate_tasks(params, full, root):
|
|||
os.makedirs(cache_dir)
|
||||
|
||||
print("Task configuration changed, generating {}".format(attr.replace('_', ' ')))
|
||||
try:
|
||||
params = load_parameters_file(params, strict=False, overrides={'try_mode': 'try_select'})
|
||||
params.check()
|
||||
except ParameterMismatch as e:
|
||||
print(PARAMETER_MISMATCH.format(e.args[0]))
|
||||
sys.exit(1)
|
||||
|
||||
taskgraph.fast = True
|
||||
cwd = os.getcwd()
|
||||
os.chdir(build.topsrcdir)
|
||||
|
||||
root = os.path.join(root, 'taskcluster', 'ci')
|
||||
tg = getattr(TaskGraphGenerator(root_dir=root, parameters=params), attr)
|
||||
params = parameters_loader(params, strict=False, overrides={'try_mode': 'try_select'})
|
||||
try:
|
||||
tg = getattr(TaskGraphGenerator(root_dir=root, parameters=params), attr)
|
||||
except ParameterMismatch as e:
|
||||
print(PARAMETER_MISMATCH.format(e.args[0]))
|
||||
sys.exit(1)
|
||||
|
||||
os.chdir(cwd)
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче