Bug 1524912 - Add a 'times' value to add-new-jobs action r=dustin a=NPOTB
authorGurzau Raul <rgurzau@mozilla.com>
Thu, 14 Feb 2019 12:09:57 +0200
changeset 513055 d8098728a641
parent 513054 a71a9abe0f42
child 513056 2e57d1c9a449
push id10699
push userrgurzau@mozilla.com
push dateThu, 14 Feb 2019 10:20:00 +0000
treeherdermozilla-beta@d8098728a641 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdustin, NPOTB
bugs1524912
milestone66.0
Bug 1524912 - Add a 'times' value to add-new-jobs action r=dustin a=NPOTB Reviewers: dustin Reviewed By: dustin Bug #: 1524912 Differential Revision: https://phabricator.services.mozilla.com/D18773
taskcluster/taskgraph/actions/add_new_jobs.py
--- a/taskcluster/taskgraph/actions/add_new_jobs.py
+++ b/taskcluster/taskgraph/actions/add_new_jobs.py
@@ -3,17 +3,21 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 from __future__ import absolute_import, print_function, unicode_literals
 
 from .registry import register_callback_action
 
-from .util import (create_tasks, fetch_graph_and_labels)
+from .util import (
+    combine_task_graph_files,
+    create_tasks,
+    fetch_graph_and_labels,
+)
 
 
 @register_callback_action(
     name='add-new-jobs',
     title='Add new jobs',
     kind='hook',
     generic=True,
     symbol='add-new',
@@ -24,24 +28,35 @@ from .util import (create_tasks, fetch_g
         'type': 'object',
         'properties': {
             'tasks': {
                 'type': 'array',
                 'description': 'An array of task labels',
                 'items': {
                     'type': 'string'
                 }
+            },
+            'times': {
+                'type': 'integer',
+                'default': 1,
+                'minimum': 1,
+                'maximum': 100,
+                'title': 'Times',
+                'description': 'How many times to run each task.',
             }
         }
     }
 )
 def add_new_jobs_action(parameters, graph_config, input, task_group_id, task_id, task):
     decision_task_id, full_task_graph, label_to_taskid = fetch_graph_and_labels(
         parameters, graph_config)
 
     to_run = []
     for elem in input['tasks']:
         if elem in full_task_graph.tasks:
             to_run.append(elem)
         else:
             raise Exception('{} was not found in the task-graph'.format(elem))
 
-    create_tasks(to_run, full_task_graph, label_to_taskid, parameters, decision_task_id)
+    times = input.get('times', 1)
+    for i in xrange(times):
+        create_tasks(to_run, full_task_graph, label_to_taskid, parameters, decision_task_id, i)
+    combine_task_graph_files(list(range(times)))