Bug 1384593 - Add an fzf based fuzzy try selector, r=armenzg

This try selector works as follows:

1. Generate target tasks (similar to ./mach taskgraph target)
2. Pipe all tasks to fzf (a fuzzy finding binary, this will be bootstrapped if necessary)
3. Allow user to make selection
4. Save selected tasks to 'try_task_config.json'. This is a new try scheduling
   mechanism built into taskcluster (see bug 1380306).
5. Use `hg push-to-try` (or git-cinnabar) to push the added file to try. This
   will use a temporary commit, so no trace of 'try_task_config.json' should be
   left over after use.


If you get messages like STOP! No try syntax found, you need to update version-control-tools:
./mach mercurial-setup --update



MozReview-Commit-ID: 4xHwZ9fATLv
This commit is contained in:
Andrew Halberstadt
2017-07-27 11:48:53 -04:00
parent f19d38f596
commit 6361b3f209
4 changed files with 328 additions and 7 deletions

View File

@@ -56,8 +56,7 @@ class TrySelect(MachCommandBase):
The |mach try| command is a frontend for scheduling tasks to
run on try server using selectors. A selector is a subcommand
that provides its own set of command line arguments and are
listed below. Currently there is only single selector called
`syntax`, but more selectors will be added in the future.
listed below.
If no subcommand is specified, the `syntax` selector is run by
default. Run |mach try syntax --help| for more information on
@@ -68,9 +67,60 @@ class TrySelect(MachCommandBase):
return self._mach_context.commands.dispatch(
'try', subcommand='syntax', context=self._mach_context, **kwargs)
@SubCommand('try',
'fuzzy',
description='Select tasks on try using a fuzzy finder')
@CommandArgument('-u', '--update', action='store_true', default=False,
help="Update fzf before running")
def try_fuzzy(self, update):
"""Select which tasks to use with fzf.
This selector runs all task labels through a fuzzy finding interface.
All selected task labels and their dependencies will be scheduled on
try.
Keyboard Shortcuts
------------------
When in the fuzzy finder interface, start typing to filter down the
task list. Then use the following keyboard shortcuts to select tasks:
accept: <enter>
cancel: <ctrl-c> or <esc>
cursor-up: <ctrl-k> or <up>
cursor-down: <ctrl-j> or <down>
toggle-select-down: <tab>
toggle-select-up: <shift-tab>
select-all: <ctrl-a>
deselect-all: <ctrl-d>
toggle-all: <ctrl-t>
clear-input: <alt-bspace>
There are many more shortcuts enabled by default, you can also define
your own shortcuts by setting `--bind` in the $FZF_DEFAULT_OPTS
environment variable. See `man fzf` for more info.
Extended Search
---------------
When typing in search terms, the following modifiers can be applied:
'word: exact match (line must contain the literal string "word")
^word: exact prefix match (line must start with literal "word")
word$: exact suffix match (line must end with literal "word")
!word: exact negation match (line must not contain literal "word")
'a | 'b: OR operator (joins two exact match operators together)
For example:
^start 'exact | !ignore fuzzy end$
"""
from tryselect.selectors.fuzzy import run_fuzzy_try
return run_fuzzy_try(update)
@SubCommand('try',
'syntax',
description='Push selected tasks using try syntax',
description='Select tasks on try using try syntax',
parser=syntax_parser)
def try_syntax(self, **kwargs):
"""Push the current tree to try, with the specified syntax.