Bug 1602773 - Fix ./mach lint -l yaml to use the vendored yamllint. r=ahal

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Alessio Placitelli 2020-03-02 15:40:04 +00:00
Родитель 0bc364b2c9
Коммит f02eb5ecda
2 изменённых файлов: 5 добавлений и 47 удалений

Просмотреть файл

@ -13,15 +13,7 @@ from mozlint import result
from mozlint.pathutils import get_ancestors_by_name
from mozprocess import ProcessHandlerMixin
here = os.path.abspath(os.path.dirname(__file__))
YAMLLINT_REQUIREMENTS_PATH = os.path.join(here, 'yamllint_requirements.txt')
YAMLLINT_INSTALL_ERROR = """
Unable to install correct version of yamllint
Try to install it manually with:
$ pip install -U --require-hashes -r {}
""".strip().format(YAMLLINT_REQUIREMENTS_PATH)
YAMLLINT_FORMAT_REGEX = re.compile('(.*):(.*):(.*): \[(error|warning)\] (.*) \((.*)\)$')
results = []
@ -60,7 +52,7 @@ class YAMLLintProcess(ProcessHandlerMixin):
signal.signal(signal.SIGINT, orig)
def get_yamllint_binary():
def get_yamllint_binary(mc_root):
"""
Returns the path of the first yamllint binary available
if not found returns None
@ -69,7 +61,9 @@ def get_yamllint_binary():
if binary:
return binary
return which('yamllint')
# yamllint is vendored in mozilla-central: let's use this
# if no environment variable is found.
return os.path.join(mc_root, 'third_party', 'python', 'yamllint')
def _run_pip(*args):
@ -85,19 +79,6 @@ def _run_pip(*args):
return False
def reinstall_yamllint():
"""
Try to install yamllint at the target version, returns True on success
otherwise prints the otuput of the pip command and returns False
"""
if _run_pip('install', '-U',
'--require-hashes', '-r',
YAMLLINT_REQUIREMENTS_PATH):
return True
return False
def run_process(config, cmd):
proc = YAMLLintProcess(config, cmd)
proc.run()
@ -118,11 +99,8 @@ def gen_yamllint_args(cmdargs, paths=None, conf_file=None):
def lint(files, config, **lintargs):
log = lintargs['log']
if not reinstall_yamllint():
print(YAMLLINT_INSTALL_ERROR)
return 1
binary = get_yamllint_binary()
binary = get_yamllint_binary(lintargs['root'])
cmdargs = [
which('python'),

Просмотреть файл

@ -1,20 +0,0 @@
yamllint==1.20.0 \
--hash=sha256:7318e189027951983c3cb4d6bcaa1e75deef7c752320ca3ce84e407f2551e8ce
PyYAML==3.12 \
--hash=sha256:3262c96a1ca437e7e4763e2843746588a965426550f3797a79fca9c6199c431f \
--hash=sha256:16b20e970597e051997d90dc2cddc713a2876c47e3d92d59ee198700c5427736 \
--hash=sha256:e863072cdf4c72eebf179342c94e6989c67185842d9997960b3e69290b2fa269 \
--hash=sha256:bc6bced57f826ca7cb5125a10b23fd0f2fff3b7c4701d64c439a300ce665fff8 \
--hash=sha256:c01b880ec30b5a6e6aa67b09a2fe3fb30473008c85cd6a67359a1b15ed6d83a4 \
--hash=sha256:827dc04b8fa7d07c44de11fabbc888e627fa8293b695e0f99cb544fdfa1bf0d1 \
--hash=sha256:592766c6303207a20efc445587778322d7f73b161bd994f227adaa341ba212ab \
--hash=sha256:592766c6303207a20efc445587778322d7f73b161bd994f227adaa341ba212ab \
--hash=sha256:5f84523c076ad14ff5e6c037fe1c89a7f73a3e04cf0377cb4d017014976433f3 \
--hash=sha256:0c507b7f74b3d2dd4d1322ec8a94794927305ab4cebbe89cc47fe5e81541e6e8 \
--hash=sha256:b4c423ab23291d3945ac61346feeb9a0dc4184999ede5e7c43e1ffb975130ae6 \
--hash=sha256:ca233c64c6e40eaa6c66ef97058cdc80e8d0157a443655baa1b2966e812807ca \
--hash=sha256:4474f8ea030b5127225b8894d626bb66c01cda098d47a2b0d3429b6700af9fd8 \
--hash=sha256:326420cbb492172dec84b0f65c80942de6cedb5233c413dd824483989c000608 \
--hash=sha256:5ac82e411044fb129bae5cfbeb3ba626acb2af31a8d17d175004b70862a741a7
pathspec==0.5.3 \
--hash=sha256:54478a66a360f4ebe4499c9235e4206fca5dec837b8e272d1ce37e0a626cc64d