Bug 1612077 - Use parallel directory processing for Lint when no path is specified or a support file is touched. r=ahal

Differential Revision: https://phabricator.services.mozilla.com/D61219

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Mark Banner 2020-01-31 12:45:12 +00:00
parent 0b1dab0c5a
commit 4948a30dbf

View File

@ -202,17 +202,20 @@ class LintRoller(object):
return 0
def _generate_jobs(self, paths, vcs_paths, num_procs):
def __get_current_paths(path=self.root):
return [os.path.join(path, p) for p in os.listdir(path)]
"""A job is of the form (<linter:dict>, <paths:list>)."""
for linter in self.linters:
if any(os.path.isfile(p) and mozpath.match(p, pattern)
for pattern in linter.get('support-files', []) for p in vcs_paths):
lpaths = [self.root]
lpaths = __get_current_paths()
print("warning: {} support-file modified, linting entire tree "
"(press ctrl-c to cancel)".format(linter['name']))
else:
lpaths = paths.union(vcs_paths)
lpaths = list(lpaths) or [os.getcwd()]
lpaths = list(lpaths) or __get_current_paths(os.getcwd())
chunk_size = min(self.MAX_PATHS_PER_JOB, int(ceil(len(lpaths) / num_procs))) or 1
if linter['type'] == 'global':
# Global linters lint the entire tree in one job.