Bug 1442851 - Use comm-central revision in routes; r=tomprince, r?dustin draft
authorGeoff Lankow <geoff@darktrojan.net>
Thu, 08 Mar 2018 11:23:00 +1300
changeset 764573 161bf849bb58433dc0072ee8027a03b3b57cf15a
parent 762291 5410375734d6ca8be3ff06acdc1c951d87d644ee
push id101792
push userbmo:geoff@darktrojan.net
push dateWed, 07 Mar 2018 22:24:30 +0000
reviewerstomprince, dustin
bugs1442851
milestone60.0a1
Bug 1442851 - Use comm-central revision in routes; r=tomprince, r?dustin MozReview-Commit-ID: 4XV3SGQVT54
taskcluster/taskgraph/transforms/task.py
--- a/taskcluster/taskgraph/transforms/task.py
+++ b/taskcluster/taskgraph/transforms/task.py
@@ -616,41 +616,41 @@ TC_TREEHERDER_SCHEMA_URL = 'https://gith
 
 UNKNOWN_GROUP_NAME = "Treeherder group {} (from {}) has no name; " \
                      "add it to taskcluster/ci/config.yml"
 
 V2_ROUTE_TEMPLATES = [
     "index.{trust-domain}.v2.{project}.latest.{product}.{job-name}",
     "index.{trust-domain}.v2.{project}.pushdate.{build_date_long}.{product}.{job-name}",
     "index.{trust-domain}.v2.{project}.pushlog-id.{pushlog_id}.{product}.{job-name}",
-    "index.{trust-domain}.v2.{project}.revision.{head_rev}.{product}.{job-name}",
+    "index.{trust-domain}.v2.{project}.revision.{branch_rev}.{product}.{job-name}",
 ]
 
 # {central, inbound, autoland} write to a "trunk" index prefix. This facilitates
 # walking of tasks with similar configurations.
 V2_TRUNK_ROUTE_TEMPLATES = [
-    "index.{trust-domain}.v2.trunk.revision.{head_rev}.{product}.{job-name}",
+    "index.{trust-domain}.v2.trunk.revision.{branch_rev}.{product}.{job-name}",
 ]
 
 V2_NIGHTLY_TEMPLATES = [
     "index.{trust-domain}.v2.{project}.nightly.latest.{product}.{job-name}",
-    "index.{trust-domain}.v2.{project}.nightly.{build_date}.revision.{head_rev}.{product}.{job-name}",  # noqa - too long
+    "index.{trust-domain}.v2.{project}.nightly.{build_date}.revision.{branch_rev}.{product}.{job-name}",  # noqa - too long
     "index.{trust-domain}.v2.{project}.nightly.{build_date}.latest.{product}.{job-name}",
-    "index.{trust-domain}.v2.{project}.nightly.revision.{head_rev}.{product}.{job-name}",
+    "index.{trust-domain}.v2.{project}.nightly.revision.{branch_rev}.{product}.{job-name}",
 ]
 
 V2_NIGHTLY_L10N_TEMPLATES = [
     "index.{trust-domain}.v2.{project}.nightly.latest.{product}-l10n.{job-name}.{locale}",
-    "index.{trust-domain}.v2.{project}.nightly.{build_date}.revision.{head_rev}.{product}-l10n.{job-name}.{locale}",  # noqa - too long
+    "index.{trust-domain}.v2.{project}.nightly.{build_date}.revision.{branch_rev}.{product}-l10n.{job-name}.{locale}",  # noqa - too long
     "index.{trust-domain}.v2.{project}.nightly.{build_date}.latest.{product}-l10n.{job-name}.{locale}",  # noqa - too long
-    "index.{trust-domain}.v2.{project}.nightly.revision.{head_rev}.{product}-l10n.{job-name}.{locale}",  # noqa - too long
+    "index.{trust-domain}.v2.{project}.nightly.revision.{branch_rev}.{product}-l10n.{job-name}.{locale}",  # noqa - too long
 ]
 
 V2_L10N_TEMPLATES = [
-    "index.{trust-domain}.v2.{project}.revision.{head_rev}.{product}-l10n.{job-name}.{locale}",
+    "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.
@@ -659,16 +659,26 @@ 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
+        )
+    ]
+
+
 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',
     'comm-esr45': 'highest',
     'comm-esr52': 'highest',
@@ -1323,16 +1333,17 @@ def add_generic_index_routes(config, tas
     verify_index(config, index)
 
     subs = config.params.copy()
     subs['job-name'] = index['job-name']
     subs['build_date_long'] = time.strftime("%Y.%m.%d.%Y%m%d%H%M%S",
                                             time.gmtime(config.params['build_date']))
     subs['product'] = index['product']
     subs['trust-domain'] = config.graph_config['trust-domain']
+    subs['branch_rev'] = get_branch_rev(config)
 
     project = config.params.get('project')
 
     for tpl in V2_ROUTE_TEMPLATES:
         routes.append(tpl.format(**subs))
 
     # Additionally alias all tasks for "trunk" repos into a common
     # namespace.
@@ -1353,16 +1364,17 @@ def add_nightly_index_routes(config, tas
     subs = config.params.copy()
     subs['job-name'] = index['job-name']
     subs['build_date_long'] = time.strftime("%Y.%m.%d.%Y%m%d%H%M%S",
                                             time.gmtime(config.params['build_date']))
     subs['build_date'] = time.strftime("%Y.%m.%d",
                                        time.gmtime(config.params['build_date']))
     subs['product'] = index['product']
     subs['trust-domain'] = config.graph_config['trust-domain']
+    subs['branch_rev'] = get_branch_rev(config)
 
     for tpl in V2_NIGHTLY_TEMPLATES:
         routes.append(tpl.format(**subs))
 
     # Also add routes for en-US
     task = add_l10n_index_routes(config, task, force_locale="en-US")
 
     return task
@@ -1375,16 +1387,17 @@ def add_release_index_routes(config, tas
     release_config = get_release_config(config)
 
     subs = config.params.copy()
     subs['build_number'] = str(release_config['build_number'])
     subs['revision'] = subs['head_rev']
     subs['underscore_version'] = release_config['version'].replace('.', '_')
     subs['product'] = index['product']
     subs['trust-domain'] = config.graph_config['trust-domain']
+    subs['branch_rev'] = get_branch_rev(config)
     subs['branch'] = subs['project']
     if 'channel' in index:
         resolve_keyed_by(
             index, 'channel', item_name=task['label'], project=config.params['project']
         )
         subs['channel'] = index['channel']
 
     for rt in task.get('routes', []):
@@ -1410,16 +1423,17 @@ def add_l10n_index_routes(config, task, 
     verify_index(config, index)
 
     subs = config.params.copy()
     subs['job-name'] = index['job-name']
     subs['build_date_long'] = time.strftime("%Y.%m.%d.%Y%m%d%H%M%S",
                                             time.gmtime(config.params['build_date']))
     subs['product'] = index['product']
     subs['trust-domain'] = config.graph_config['trust-domain']
+    subs['branch_rev'] = get_branch_rev(config)
 
     locales = task['attributes'].get('chunk_locales',
                                      task['attributes'].get('all_locales'))
     # Some tasks has only one locale set
     if task['attributes'].get('locale'):
         locales = [task['attributes']['locale']]
 
     if force_locale:
@@ -1449,16 +1463,17 @@ def add_nightly_l10n_index_routes(config
     verify_index(config, index)
 
     subs = config.params.copy()
     subs['job-name'] = index['job-name']
     subs['build_date_long'] = time.strftime("%Y.%m.%d.%Y%m%d%H%M%S",
                                             time.gmtime(config.params['build_date']))
     subs['product'] = index['product']
     subs['trust-domain'] = config.graph_config['trust-domain']
+    subs['branch_rev'] = get_branch_rev(config)
 
     locales = task['attributes'].get('chunk_locales',
                                      task['attributes'].get('all_locales'))
     # Some tasks has only one locale set
     if task['attributes'].get('locale'):
         locales = [task['attributes']['locale']]
 
     if force_locale:
@@ -1542,25 +1557,22 @@ def build_task(config, tasks):
                 raise RuntimeError("Treeherder group and symbol names must not be longer than "
                                    "25 characters: {} (see {})".format(
                                        task_th['symbol'],
                                        TC_TREEHERDER_SCHEMA_URL,
                                        ))
             treeherder['jobKind'] = task_th['kind']
             treeherder['tier'] = task_th['tier']
 
-            treeherder_rev = config.params[
-                BRANCH_REV_PARAM.get(
-                    config.params['project'],
-                    DEFAULT_BRANCH_REV_PARAM)]
+            branch_rev = get_branch_rev(config)
 
             routes.append(
                 '{}.v2.{}.{}.{}'.format(TREEHERDER_ROUTE_ROOT,
                                         config.params['project'],
-                                        treeherder_rev,
+                                        branch_rev,
                                         config.params['pushlog_id'])
             )
 
         if 'expires-after' not in task:
             task['expires-after'] = '28 days' if config.params['project'] == 'try' else '1 year'
 
         if 'deadline-after' not in task:
             task['deadline-after'] = '1 day'
@@ -1601,17 +1613,17 @@ def build_task(config, tasks):
         }
 
         if task.get('requires', None):
             task_def['requires'] = task['requires']
 
         if task_th:
             # link back to treeherder in description
             th_push_link = 'https://treeherder.mozilla.org/#/jobs?repo={}&revision={}'.format(
-                config.params['project'], treeherder_rev)
+                config.params['project'], branch_rev)
             task_def['metadata']['description'] += ' ([Treeherder push]({}))'.format(
                 th_push_link)
 
         # add the payload and adjust anything else as required (e.g., scopes)
         payload_builders[task['worker']['implementation']](config, task, task_def)
 
         attributes = task.get('attributes', {})
         attributes['run_on_projects'] = task.get('run-on-projects', ['all'])