Bug 1609987 - Initial support for extending taskgraph with hooks. r=darktrojan
authorRob Lemley <rob@thunderbird.net>
Sat, 18 Jan 2020 14:48:22 -0500
changeset 28579 bfcc947899e561eb23756dba6841cb17f758d2e3
parent 28578 04d95196247e3a348898c8fcff0ea5bccd7bd76c
child 28580 0b3a6c10489b6d0aa70cb27f8fefa37bbe80b298
push id16937
push usergeoff@darktrojan.net
push dateFri, 24 Jan 2020 03:58:31 +0000
treeherdercomm-central@bfcc947899e5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdarktrojan
bugs1609987
Bug 1609987 - Initial support for extending taskgraph with hooks. r=darktrojan The comm_taskgraph.register function will get called early in the Decision task. The Fenix project uses this to add functionality in key places via hooks that aid in customizing the taskgraph. This is just initial support, extension modules will be added as needed.
build/virtualenv_packages.txt
taskcluster/ci/config.yml
taskcluster/comm_taskgraph/__init__.py
--- a/build/virtualenv_packages.txt
+++ b/build/virtualenv_packages.txt
@@ -1,2 +1,1 @@
-comm.pth:comm/taskcluster
 comm.pth:comm/testing/marionette
--- a/taskcluster/ci/config.yml
+++ b/taskcluster/ci/config.yml
@@ -81,16 +81,19 @@ partner-urls:
 
 task-priority:
     by-project:
         'comm-esr68': 'very-high'
         'comm-beta': 'high'
         'comm-central': 'medium'
         'default': 'low'
 
+taskgraph:
+    register: comm_taskgraph:register
+
 workers:
     aliases:
         b-linux.*:
             provisioner: 'comm-{level}'
             implementation: docker-worker
             os: linux
             worker-type: '{alias}'
         b-win2012:
--- a/taskcluster/comm_taskgraph/__init__.py
+++ b/taskcluster/comm_taskgraph/__init__.py
@@ -1,3 +1,29 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+from __future__ import absolute_import, print_function, unicode_literals
+
+import os
+import logging
+from importlib import import_module
+
+from taskgraph import GECKO
+
+logger = logging.getLogger(__name__)
+
+COMM = os.path.join(GECKO, 'comm')
+
+
+def register(graph_config):
+    """
+    Import all modules that are siblings of this one, triggering decorators in
+    the process.
+    """
+    logger.info("{} path registered".format(__name__))
+    _import_modules([])
+
+
+def _import_modules(modules):
+    for module in modules:
+        import_module(".{}".format(module), package=__name__)