Bug 1414919 - [tryselect] Add --rebuild support to |mach try fuzzy|, r=jmaher
authorAndrew Halberstadt <ahalberstadt@mozilla.com>
Tue, 07 Nov 2017 10:27:44 -0500
changeset 444128 7474dc45cbe36534ad063540b5fe4ae4a17eb59c
parent 444127 6d5a445dba8a7ee540eadc2019d29ce0353ac694
child 444129 7e2fd1290064c714a2bd22b6c2ebeb8aca31b10c
push id1618
push userCallek@gmail.com
push dateThu, 11 Jan 2018 17:45:48 +0000
treeherdermozilla-release@882ca853e05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjmaher
bugs1414919
milestone58.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1414919 - [tryselect] Add --rebuild support to |mach try fuzzy|, r=jmaher This allows rebuilding all selected tasks. This defines an upper limit of 20 rebuilds per push. If more are needed, developers can either change it in code or push multiple times. MozReview-Commit-ID: I0XtMP5yEEq
tools/tryselect/selectors/fuzzy.py
tools/tryselect/templates.py
--- a/tools/tryselect/selectors/fuzzy.py
+++ b/tools/tryselect/selectors/fuzzy.py
@@ -96,17 +96,17 @@ class FuzzyParser(BaseTryParser):
                   "target tasks).",
           }],
         [['-p', '--parameters'],
          {'default': None,
           'help': "Use the given parameters.yml to generate tasks, "
                   "defaults to latest parameters.yml from mozilla-central",
           }],
     ]
-    templates = ['artifact', 'env']
+    templates = ['artifact', 'env', 'rebuild']
 
 
 def run(cmd, cwd=None):
     is_win = platform.system() == 'Windows'
     return subprocess.call(cmd, cwd=cwd, shell=True if is_win else False)
 
 
 def run_fzf_install_script(fzf_path):
--- a/tools/tryselect/templates.py
+++ b/tools/tryselect/templates.py
@@ -6,16 +6,17 @@
 Templates provide a way of modifying the task definition of selected
 tasks. They live under taskcluster/taskgraph/templates.
 """
 
 from __future__ import absolute_import, print_function, unicode_literals
 
 import os
 from abc import ABCMeta, abstractmethod
+from argparse import Action
 
 from mozbuild.base import BuildEnvironmentNotFoundException, MozbuildObject
 
 here = os.path.abspath(os.path.dirname(__file__))
 
 
 class Template(object):
     __metaclass__ = ABCMeta
@@ -62,12 +63,42 @@ class Environment(Template):
                                  'Can be passed in multiple times.')
 
     def context(self, env, **kwargs):
         if not env:
             return
         return dict(e.split('=', 1) for e in env)
 
 
+class RangeAction(Action):
+    def __init__(self, min, max, *args, **kwargs):
+        self.min = min
+        self.max = max
+        kwargs['metavar'] = '[{}-{}]'.format(self.min, self.max)
+        super(RangeAction, self).__init__(*args, **kwargs)
+
+    def __call__(self, parser, namespace, values, option_string=None):
+        name = option_string or self.dest
+        if values < self.min:
+            parser.error('{} can not be less than {}'.format(name, self.min))
+        if values > self.max:
+            parser.error('{} can not be more than {}'.format(name, self.max))
+        setattr(namespace, self.dest, values)
+
+
+class Rebuild(Template):
+
+    def add_arguments(self, parser):
+        parser.add_argument('--rebuild', action=RangeAction, min=2, max=20, default=None, type=int,
+                            help='Rebuild all selected tasks the specified number of times.')
+
+    def context(self, rebuild, **kwargs):
+        if not rebuild:
+            return
+
+        return rebuild
+
+
 all_templates = {
     'artifact': Artifact,
     'env': Environment,
+    'rebuild': Rebuild,
 }