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
--- 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,
}