Bug 1111980 - Part 6 Add slugjar to back the as_slugid functionality needed for decision tasks. r=garndt
authorjlal@mozilla.com
Thu, 11 Dec 2014 12:53:10 -0800
changeset 239058 e59bd4518cf92e152b40098bcd29a848fca1c19a
parent 239057 798f98058d46a70c2cc434dc65bf95dbdf4a5d93
child 239059 859715bb610dd8a6b8d6d0fb792187758a406e4f
push id487
push userbcampen@mozilla.com
push dateMon, 26 Jan 2015 23:32:56 +0000
reviewersgarndt
bugs1111980
milestone38.0a1
Bug 1111980 - Part 6 Add slugjar to back the as_slugid functionality needed for decision tasks. r=garndt
testing/taskcluster/taskcluster_graph/slugidjar.py
testing/taskcluster/tasks/decision/try.yml
testing/taskcluster/tests/test_slugidjar.py
new file mode 100644
--- /dev/null
+++ b/testing/taskcluster/taskcluster_graph/slugidjar.py
@@ -0,0 +1,20 @@
+from taskcluster_graph.slugid import slugid
+
+class SlugidJar():
+    '''
+    Container of seen slugid's used to implement the as_slugid functionality
+    used in the task graph templates.
+    '''
+    def __init__(self):
+        self._names = {}
+
+    def __call__(self, name):
+        '''
+        So this object can easily be passed to mustache we allow it to be called
+        directly...
+        '''
+        if name in self._names:
+            return self._names[name];
+
+        self._names[name] = slugid()
+        return self._names[name]
--- a/testing/taskcluster/tasks/decision/try.yml
+++ b/testing/taskcluster/tasks/decision/try.yml
@@ -21,20 +21,20 @@ scopes:
   - "docker-worker:cache:build-b2g-desktop-objects"
   - "docker-worker:cache:build-emulator-kk-opt"
   - "docker-worker:cache:build-emulator-jb-debug"
   - "docker-worker:cache:tc-vcs"
   - "docker-worker:cache:sources-gecko"
   - "docker-worker:cache:sources-gaia"
   - "docker-worker:cache:build-emulator-ics-debug"
 tasks:
-  - taskId: '{{ "decision task" | as-slugid }}'
+  - taskId: '{{#as_slugid }}decision task{{/as_slugid}}'
     task:
       created: '{{now}}'
-      deadline: '{{ "1 day" | from-now }}'
+      deadline: '{{#from_now }}1 day{{#/from_now}}'
       metadata:
         source: '{{source}}'
         owner: '{{owner}}'
         name: Initial decision task for try
         description: |
           This is the single most important task as it decides how all other tasks
           get built.
 
new file mode 100755
--- /dev/null
+++ b/testing/taskcluster/tests/test_slugidjar.py
@@ -0,0 +1,19 @@
+import unittest
+import mozunit
+from datetime import datetime
+from taskcluster_graph.slugidjar import SlugidJar
+
+class SlugidJarTest(unittest.TestCase):
+
+    def test_slugidjar(self):
+        subject = Jar()
+        self.assertEqual(subject('woot'), subject('woot'))
+        self.assertTrue(type(subject('woot')) is str)
+
+        other_jar = Jar()
+        self.assertNotEqual(subject('woot'), other_jar('woot'))
+
+if __name__ == '__main__':
+    mozunit.main()
+
+