Bug 1418058: [taskcluster] Add the prefix for the graph parameters of the primary repo to the graph config; r=dustin
authorTom Prince <mozilla@hocat.ca>
Wed, 11 Apr 2018 11:08:48 -0600
changeset 413271 f23ff7f39f9a39acd8e8df718be9475f064a8652
parent 413270 9fbb232ef1f16e423f55a8b0082f1dca58df1081
child 413272 5b90e26146631a54a64cac56758eaabdc228f23f
push id33840
push userapavel@mozilla.com
push dateFri, 13 Apr 2018 21:56:54 +0000
treeherdermozilla-central@6547c27303bc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdustin
bugs1418058
milestone61.0a1
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 1418058: [taskcluster] Add the prefix for the graph parameters of the primary repo to the graph config; r=dustin Differential Revision: https://phabricator.services.mozilla.com/D913
taskcluster/ci/config.yml
taskcluster/taskgraph/actions/registry.py
taskcluster/taskgraph/config.py
taskcluster/taskgraph/transforms/task.py
--- a/taskcluster/ci/config.yml
+++ b/taskcluster/ci/config.yml
@@ -1,9 +1,10 @@
 trust-domain: gecko
+project-repo-param-prefix: ''
 treeherder:
     group-names:
         'cram': 'Cram tests'
         'mocha': 'Mocha unit tests'
         'py': 'Python unit tests'
         'A': 'Android Gradle tests'
         'Fxfn-l': 'Firefox functional tests (local)'
         'Fxfn-l-e10s': 'Firefox functional tests (local) with e10s'
--- a/taskcluster/taskgraph/actions/registry.py
+++ b/taskcluster/taskgraph/actions/registry.py
@@ -172,19 +172,21 @@ def register_callback_action(name, title
         assert not mem['registered'], 'register_callback_action must be used as decorator'
         assert cb.__name__ not in callbacks, 'callback name {} is not unique'.format(cb.__name__)
 
         @register_task_action(name, title, description, order, context, schema)
         def build_callback_action_task(parameters, graph_config):
             if not available(parameters):
                 return None
 
-            match = re.match(r'https://(hg.mozilla.org)/(.*?)/?$', parameters['head_repository'])
+            repo_param = '{}head_repository'.format(graph_config['project-repo-param-prefix'])
+            revision = parameters['{}head_rev'.format(graph_config['project-repo-param-prefix'])]
+            match = re.match(r'https://(hg.mozilla.org)/(.*?)/?$', parameters[repo_param])
             if not match:
-                raise Exception('Unrecognized head_repository')
+                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())
 
             template = os.path.join(GECKO, '.taskcluster.yml')
 
             with open(template, 'r') as f:
@@ -193,24 +195,24 @@ def register_callback_action(name, title
                     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')
 
                 return {
                     '$let': {
                         'tasks_for': 'action',
                         'repository': {
-                            'url': parameters['head_repository'],
+                            'url': parameters[repo_param],
                             'project': parameters['project'],
                             'level': parameters['level'],
                         },
                         'push': {
                             'owner': 'mozilla-taskcluster-maintenance@mozilla.com',
                             'pushlog_id': parameters['pushlog_id'],
-                            'revision': parameters['head_rev'],
+                            'revision': revision,
                         },
                         'action': {
                             'name': name,
                             'title': title,
                             'description': description,
                             'taskGroupId': task_group_id,
                             'repo_scope': repo_scope,
                             'cb_name': cb.__name__,
--- a/taskcluster/taskgraph/config.py
+++ b/taskcluster/taskgraph/config.py
@@ -6,22 +6,26 @@ from __future__ import absolute_import, 
 
 from .util.schema import validate_schema, Schema
 from voluptuous import Required
 
 graph_config_schema = Schema({
     # The trust-domain for this graph.
     # (See https://firefox-source-docs.mozilla.org/taskcluster/taskcluster/taskgraph.html#taskgraph-trust-domain)  # noqa
     Required('trust-domain'): basestring,
+    # This specifes the prefix for repo parameters that refer to the project being built.
+    # This selects between `head_rev` and `comm_head_rev` and related paramters.
+    # (See http://firefox-source-docs.mozilla.org/taskcluster/taskcluster/parameters.html#push-information  # noqa
+    # and http://firefox-source-docs.mozilla.org/taskcluster/taskcluster/parameters.html#comm-push-information)  # noqa
+    Required('project-repo-param-prefix'): basestring,
     Required('treeherder'): {
         # Mapping of treeherder group symbols to descriptive names
         Required('group-names'): {basestring: basestring}
     },
     Required('index'): {
-
         Required('products'): [basestring],
     },
     Required('try'): {
         # We have a few platforms for which we want to do some "extra" builds, or at
         # least build-ish things.  Sort of.  Anyway, these other things are implemented
         # as different "platforms".  These do *not* automatically ride along with "-p
         # all"
         Required('ridealong-builds', default={}): {basestring: [basestring]},
--- a/taskcluster/taskgraph/transforms/task.py
+++ b/taskcluster/taskgraph/transforms/task.py
@@ -609,35 +609,19 @@ V2_L10N_TEMPLATES = [
     "index.{trust-domain}.v2.{project}.revision.{branch_rev}.{product}-l10n.{job-name}.{locale}",
     "index.{trust-domain}.v2.{project}.pushdate.{build_date_long}.{product}-l10n.{job-name}.{locale}",  # noqa - too long
     "index.{trust-domain}.v2.{project}.latest.{product}-l10n.{job-name}.{locale}",
 ]
 
 # the roots of the treeherder routes
 TREEHERDER_ROUTE_ROOT = 'tc-treeherder'
 
-# Which repository repository revision to use when reporting results to treeherder.
-DEFAULT_BRANCH_REV_PARAM = 'head_rev'
-BRANCH_REV_PARAM = {
-    'comm-esr45': 'comm_head_rev',
-    'comm-esr52': 'comm_head_rev',
-    'comm-beta': 'comm_head_rev',
-    'comm-central': 'comm_head_rev',
-    'comm-aurora': 'comm_head_rev',
-    'try-comm-central': 'comm_head_rev',
-}
-
 
 def get_branch_rev(config):
-    return config.params[
-        BRANCH_REV_PARAM.get(
-            config.params['project'],
-            DEFAULT_BRANCH_REV_PARAM
-        )
-    ]
+    return config.params['{}head_rev'.format(config.graph_config['project-repo-param-prefix'])]
 
 
 COALESCE_KEY = '{project}.{job-identifier}'
 SUPERSEDER_URL = 'https://coalesce.mozilla-releng.net/v1/list/{age}/{size}/{key}'
 
 DEFAULT_BRANCH_PRIORITY = 'low'
 BRANCH_PRIORITIES = {
     'mozilla-release': 'highest',