Bug 1374940 - Allow transforms to access info about tasks from kind dependencies of the current kind. r?dustin draft
authorMike Hommey <mh+mozilla@glandium.org>
Wed, 19 Jul 2017 07:25:26 +0900
changeset 612571 cb64b3cd99195b3de90a27c6a95ce85ba6ec1cbc
parent 612570 53c1868cdcb4219d5fd136e168d18e21535bf4bb
child 612572 069daa0c1f0f7ca83a4ebe8cd07a0757d196ae7c
push id69542
push userbmo:mh+mozilla@glandium.org
push dateThu, 20 Jul 2017 21:02:57 +0000
reviewersdustin
bugs1374940
milestone56.0a1
Bug 1374940 - Allow transforms to access info about tasks from kind dependencies of the current kind. r?dustin
taskcluster/taskgraph/generator.py
taskcluster/taskgraph/transforms/base.py
--- 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