Bug 1447460: [taskgraph] Use the graph config root to guess find the path to `.taskcluster.yml` in actions; r=dustin
authorTom Prince <mozilla@hocat.ca>
Wed, 02 May 2018 20:30:15 -0600
changeset 418628 2f824659695ac2108ee23b42ec2ab843854a62f1
parent 418627 3b2bb2730502079ef9c2344b9cf678d1a368057e
child 418629 d16f0251c0c8c2c5ae2636484e967dfd5ec6ea0e
push id34007
push usercsabou@mozilla.com
push dateThu, 17 May 2018 09:47:02 +0000
treeherdermozilla-central@8fb36531f7d0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1447460: [taskgraph] Use the graph config root to guess find the path to `.taskcluster.yml` in actions; r=dustin Differential Revision: https://phabricator.services.mozilla.com/D1126
--- a/taskcluster/taskgraph/actions/registry.py
+++ b/taskcluster/taskgraph/actions/registry.py
@@ -8,17 +8,17 @@ from __future__ import absolute_import, 
 import json
 import os
 import re
 import yaml
 from slugid import nice as slugid
 from types import FunctionType
 from collections import namedtuple
-from taskgraph import create, GECKO
+from taskgraph import create
 from taskgraph.config import load_graph_config
 from taskgraph.util import taskcluster
 from taskgraph.parameters import Parameters
 actions = []
 callbacks = {}
@@ -182,22 +182,17 @@ def register_callback_action(name, title
             match = re.match(r'https://(hg.mozilla.org)/(.*?)/?$', parameters[repo_param])
             if not match:
                 raise Exception('Unrecognized {}'.format(repo_param))
             repo_scope = 'assume:repo:{}/{}:branch:default'.format(
                 match.group(1), match.group(2))
             task_group_id = os.environ.get('TASK_ID', slugid())
-            # FIXME: https://bugzilla.mozilla.org/show_bug.cgi?id=1454034
-            # trust-domain works, but isn't semantically correct here.
-            if graph_config['trust-domain'] == 'comm':
-                template = os.path.join(GECKO, 'comm', '.taskcluster.yml')
-            else:
-                template = os.path.join(GECKO, '.taskcluster.yml')
+            template = graph_config.taskcluster_yml
             with open(template, 'r') as f:
                 taskcluster_yml = yaml.safe_load(f)
                 if taskcluster_yml['version'] != 1:
                     raise Exception('actions.json must be updated to work with .taskcluster.yml')
                 if not isinstance(taskcluster_yml['tasks'], list):
                     raise Exception('.taskcluster.yml "tasks" must be a list for action tasks')
--- a/taskcluster/taskgraph/config.py
+++ b/taskcluster/taskgraph/config.py
@@ -3,16 +3,17 @@
 # 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
 import attr
 import yaml
+from mozpack import path
 from .util.schema import validate_schema, Schema
 from voluptuous import Required, Optional
 logger = logging.getLogger(__name__)
 graph_config_schema = Schema({
     # The trust-domain for this graph.
@@ -64,16 +65,28 @@ graph_config_schema = Schema({
 class GraphConfig(object):
     _config = attr.ib()
     root_dir = attr.ib()
     def __getitem__(self, name):
         return self._config[name]
+    @property
+    def taskcluster_yml(self):
+        if path.split(self.root_dir)[-2:] != ['taskcluster', 'ci']:
+            raise Exception(
+                "Not guessing path to `.taskcluster.yml`. "
+                "Graph config in non-standard location."
+            )
+        return os.path.join(
+            os.path.dirname(os.path.dirname(self.root_dir)),
+            ".taskcluster.yml",
+        )
 def validate_graph_config(config):
     return validate_schema(graph_config_schema, config, "Invalid graph configuration:")
 def load_graph_config(root_dir):
     config_yml = os.path.join(root_dir, "config.yml")
     if not os.path.exists(config_yml):