Bug 1289824 - Add "add-talos" taskgraph action
MozReview-Commit-ID: A5KVIgAZccV
--- a/taskcluster/mach_commands.py
+++ b/taskcluster/mach_commands.py
@@ -273,16 +273,40 @@ class MachCommands(MachCommandBase):
import taskgraph.cron
try:
self.setup_logging()
return taskgraph.cron.taskgraph_cron(options)
except Exception:
traceback.print_exc()
sys.exit(1)
+ @SubCommand('taskgraph', 'add-talos',
+ description="Run the add-talos task")
+ @CommandArgument('--root', '-r',
+ default='taskcluster/ci',
+ help="root of the taskgraph definition relative to topsrcdir")
+ @CommandArgument('--decision-task-id',
+ required=True,
+ help="Id of the decision task that is part of the push to be talos'd")
+ @CommandArgument('--times',
+ required=False,
+ default=1,
+ type=int,
+ help="Number of times to add each job.")
+ def taskgraph_add_talos(self, **options):
+ """Add all talos jobs for a push."""
+
+ import taskgraph.action
+ try:
+ self.setup_logging()
+ return taskgraph.action.add_talos(options['decision_task_id'], options['times'])
+ except Exception:
+ traceback.print_exc()
+ sys.exit(1)
+
def setup_logging(self, quiet=False, verbose=True):
"""
Set up Python logging for all loggers, sending results to stderr (so
that command output can be redirected easily) and adding the typical
mach timestamp.
"""
# remove the old terminal handler
old = self.log_manager.replace_terminal_handler(None)
--- a/taskcluster/taskgraph/action.py
+++ b/taskcluster/taskgraph/action.py
@@ -95,16 +95,29 @@ def backfill(project, job_id):
params = {"id__lt": job["result_set_id"], "count": MAX_BACKFILL_RESULTSETS}
results = s.get(url=resultset_url, params=params).json()["results"]
resultsets = [resultset["id"] for resultset in results]
for decision in load_decisions(s, project, resultsets, filters):
add_tasks(decision, [job["job_type_name"]], '{}-'.format(decision))
+def add_talos(decision_task_id, times=1):
+ """
+ Run the add-talos task. This function implements `mach taskgraph add-talos`,
+ and is responsible for
+
+ * Adding all talos jobs to a push.
+ """
+ full_task_json = get_artifact(decision_task_id, "public/full-task-graph.json")
+ task_labels = [label for label in full_task_json if "talos" in label]
+ for time in xrange(times):
+ add_tasks(decision_task_id, task_labels, '{}-'.format(time))
+
+
def load_decisions(s, project, resultsets, filters):
"""
Given a project, a list of revisions, and a dict of filters, return
a list of taskIds from decision tasks.
"""
project_url = "{}/project/{}/jobs/".format(TREEHERDER_URL, project)
decision_url = "{}/jobdetail/".format(TREEHERDER_URL)
decisions = []