Bug 1374940 - Allow transforms to access info about tasks from kind dependencies of the current kind. r?dustin
--- a/taskcluster/taskgraph/generator.py
+++ b/taskcluster/taskgraph/generator.py
@@ -44,25 +44,30 @@ class Kind(object):
config = copy.deepcopy(self.config)
if 'parse-commit' in self.config:
parse_commit = find_object(config['parse-commit'])
config['args'] = parse_commit(parameters['message'])
else:
config['args'] = None
+ kind_dependencies = config.get('kind-dependencies', [])
+ kind_dependencies_tasks = [task for task in loaded_tasks
+ if task.kind in kind_dependencies]
+
inputs = loader(self.name, self.path, config, parameters, loaded_tasks)
transforms = TransformSequence()
for xform_path in config['transforms']:
transform = find_object(xform_path)
transforms.add(transform)
# perform the transformations on the loaded inputs
- trans_config = TransformConfig(self.name, self.path, config, parameters)
+ trans_config = TransformConfig(self.name, self.path, config, parameters,
+ kind_dependencies_tasks)
tasks = [Task(self.name,
label=task_dict['label'],
attributes=task_dict['attributes'],
task=task_dict['task'],
optimizations=task_dict.get('optimizations'),
dependencies=task_dict.get('dependencies'))
for task_dict in transforms(trans_config, inputs)]
return tasks
--- a/taskcluster/taskgraph/transforms/base.py
+++ b/taskcluster/taskgraph/transforms/base.py
@@ -4,29 +4,34 @@
from __future__ import absolute_import, print_function, unicode_literals
class TransformConfig(object):
"""A container for configuration affecting transforms. The `config`
argument to transforms is an instance of this class, possibly with
additional kind-specific attributes beyond those set here."""
- def __init__(self, kind, path, config, params):
+ def __init__(self, kind, path, config, params,
+ kind_dependencies_tasks=None):
# the name of the current kind
self.kind = kind
# the path to the kind configuration directory
self.path = path
# the parsed contents of kind.yml
self.config = config
# the parameters for this task-graph generation run
self.params = params
+ # a list of all the tasks associated with the kind dependencies of the
+ # current kind
+ self.kind_dependencies_tasks = kind_dependencies_tasks
+
class TransformSequence(object):
"""
Container for a sequence of transforms. Each transform is represented as a
callable taking (config, items) and returning a generator which will yield
transformed items. The resulting sequence has the same interface.
This is convenient to use in a file full of transforms, as it provides a