Bug 1301720: ensure Buildbot and TaskCluster v2 routes match; r?mshal draft
authorDustin J. Mitchell <dustin@mozilla.com>
Fri, 16 Sep 2016 15:08:57 +0000
changeset 414534 4d1183e2b3d1a032708c0978ac5c04e123fa6a16
parent 414533 ea85232da03696978a4af76503419dc51be28773
child 531462 e6d8d0a28e87861e45ca9625c7d4781e2b34936e
push id29694
push userdmitchell@mozilla.com
push dateFri, 16 Sep 2016 15:11:55 +0000
reviewersmshal
bugs1301720
milestone51.0a1
Bug 1301720: ensure Buildbot and TaskCluster v2 routes match; r?mshal MozReview-Commit-ID: 40FmcJWkIIo
taskcluster/taskgraph/transforms/task.py
--- a/taskcluster/taskgraph/transforms/task.py
+++ b/taskcluster/taskgraph/transforms/task.py
@@ -5,16 +5,17 @@
 These transformations take a task description and turn it into a TaskCluster
 task definition (along with attributes, label, etc.).  The input to these
 transformations is generic to any kind of task, but abstracts away some of the
 complexities of worker implementations, scopes, and treeherder annotations.
 """
 
 from __future__ import absolute_import, print_function, unicode_literals
 
+import json
 import time
 
 from taskgraph.util.treeherder import split_symbol
 from taskgraph.transforms.base import (
     validate_schema,
     TransformSequence
 )
 from voluptuous import Schema, Any, Required, Optional, Extra
@@ -522,8 +523,33 @@ def build_task(config, tasks):
 
         yield {
             'label': task['label'],
             'task': task_def,
             'dependencies': task.get('dependencies', {}),
             'attributes': attributes,
             'when': task.get('when', {}),
         }
+
+
+# Check that the v2 route templates match those used by Mozharness.  This can
+# go away once Mozharness builds are no longer performed in Buildbot, and the
+# Mozharness code referencing routes.json is deleted.
+def check_v2_routes():
+    with open("testing/mozharness/configs/routes.json", "rb") as f:
+        routes_json = json.load(f)
+
+    # we only deal with the 'routes' key here
+    routes = routes_json['routes']
+
+    # we use different variables than mozharness
+    for mh, tg in [
+        ('{index}', 'index'),
+        ('{build_product}', '{product}'),
+        ('{build_name}-{build_type}', '{job-name-gecko-v2}'),
+        ('{year}.{month}.{day}.{pushdate}', '{pushdate_long}')]:
+        routes = [r.replace(mh, tg) for r in routes]
+
+    if sorted(routes) != sorted(V2_ROUTE_TEMPLATES):
+        raise Exception("V2_ROUTE_TEMPLATES does not match Mozharness's routes.json: "
+                        "%s vs %s" % (V2_ROUTE_TEMPLATES, routes))
+
+check_v2_routes()