Bug 1403342 - default to -j none and do not optimize_target_tasks for try; r=ahal

With this in place, all `-j`obs will not run by default on try.  This will omit
such jobs in most try pushes even if files-changed matches. This is
unfortunate, but better than running them unconditionally.  Fuzzy selections,
and later `just try it` pushes, are the ultimate solution here.

With this change, a push with no try syntax or try_task_config.json will schedule
no tasks at all.

MozReview-Commit-ID: FGjqlDW1FT6

--HG--
extra : rebase_source : 727ceafb1b6d24f83c0c7382b6a877ecb65863ab
This commit is contained in:
Dustin J. Mitchell 2017-10-03 21:15:15 +00:00
parent 43bb5cba13
commit 3e72eff02a
6 changed files with 35 additions and 35 deletions

View File

@ -13,7 +13,8 @@ integration branches are at SCM level 3.
Scheduling a Task on Try
------------------------
There are two methods for scheduling a task on try.
There are three methods for scheduling a task on try: legacy try option syntax,
try task config, and an empty try.
Try Option Syntax
:::::::::::::::::
@ -132,6 +133,14 @@ It looks like this:
See the `existing templates`_ for examples.
Empty Try
:::::::::
If there is no try syntax or ``try_task_config.json``, the ``try_mode``
parameter is None and no tasks are selected to run. The resulting push will
only have a decision task, but one with an "add jobs" action that can be used
to add the desired jobs to the try push.
.. _tryselect: https://dxr.mozilla.org/mozilla-central/source/tools/tryselect
.. _JSON-e: https://taskcluster.github.io/json-e/
.. _taskgraph module: https://dxr.mozilla.org/mozilla-central/source/taskcluster/taskgraph/templates

View File

@ -215,11 +215,7 @@ def get_decision_parameters(options):
else:
parameters['try_options'] = None
if parameters['try_mode'] == 'try_option_syntax':
# Try option syntax is imprecise, so optimize away tasks even if they
# are selected by the syntax.
parameters['optimize_target_tasks'] = True
elif parameters['try_mode'] == 'try_task_config':
if parameters['try_mode']:
# The user has explicitly requested a set of jobs, so run them all
# regardless of optimization. Their dependencies can be optimized,
# though.

View File

@ -110,11 +110,9 @@ def target_tasks_try(full_task_graph, parameters):
elif try_mode == 'try_option_syntax':
return _try_option_syntax(full_task_graph, parameters)
else:
# With no try mode, we would like to schedule everything (following
# run_on_projects) and let optimization trim it down. But optimization
# isn't yet up to the task, so instead we use try_option_syntax with
# an empty message (which basically just schedules `-j`objs)
return _try_option_syntax(full_task_graph, parameters)
# With no try mode, we schedule nothing, allowing the user to add tasks
# later via treeherder.
return []
@_target_task('default')

View File

@ -84,16 +84,17 @@ class TestTargetTasks(unittest.TestCase):
finally:
try_option_syntax.TryOptionSyntax = orig_TryOptionSyntax
def test_just_try_it(self):
"try_mode = None runs try optoin syntax with no options"
def test_empty_try(self):
"try_mode = None runs nothing"
tg = self.make_task_graph()
method = target_tasks.get_method('try_tasks')
with self.fake_TryOptionSyntax():
params = {
'try_mode': None,
'message': '',
}
self.assertEqual(method(tg, params), ['b'])
params = {
'try_mode': None,
'project': 'try',
'message': '',
}
# only runs the task with run_on_projects: try
self.assertEqual(method(tg, params), [])
def test_try_option_syntax(self):
"try_mode = try_option_syntax uses TryOptionSyntax"

View File

@ -69,7 +69,7 @@ class TestTryOptionSyntax(unittest.TestCase):
tos = TryOptionSyntax(parameters, graph_with_jobs)
# equilvant to "try:"..
self.assertEqual(tos.build_types, [])
self.assertEqual(tos.jobs, None)
self.assertEqual(tos.jobs, [])
def test_apostrophe_in_message(self):
"apostrophe does not break parsing"

View File

@ -323,7 +323,9 @@ class TryOptionSyntax(object):
self.include_nightly = options['include_nightly']
def parse_jobs(self, jobs_arg):
if not jobs_arg or jobs_arg == ['all']:
if not jobs_arg or jobs_arg == ['none']:
return [] # default is `-j none`
if jobs_arg == ['all']:
return None
expanded = []
for job in jobs_arg:
@ -597,23 +599,17 @@ class TryOptionSyntax(object):
else:
return False
job_try_name = attr('job_try_name')
if job_try_name:
if attr('job_try_name'):
# Beware the subtle distinction between [] and None for self.jobs and self.platforms.
# They will be [] if there was no try syntax, and None if try syntax was detected but
# they remained unspecified.
if self.jobs:
return job_try_name in self.jobs
elif not self.jobs and 'build' in task.dependencies:
# We exclude tasks with build dependencies from the default set of jobs because
# they will schedule their builds even if they end up optimized away. This means
# to run these tasks on try, they'll need to be explicitly specified by -j until
# we find a better solution (see bug 1372510).
return False
elif not self.jobs and attr('build_platform'):
if self.platforms is None or attr('build_platform') in self.platforms:
return True
return False
if self.jobs is not None:
return attr('job_try_name') in self.jobs
# User specified `-j all`
if self.platforms is not None and attr('build_platform') not in self.platforms:
return False # honor -p for jobs governed by a platform
# "all" means "everything with `try` in run_on_projects"
return check_run_on_projects()
elif attr('kind') == 'test':
return match_test(self.unittests, 'unittest_try_name') \