зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1700423 - Remove py2 and py3 linters and their config from taskcluster.r=ahal
Differential Revision: https://phabricator.services.mozilla.com/D109647
This commit is contained in:
Родитель
00a2d5f7d4
Коммит
1f5055fa54
|
@ -195,19 +195,6 @@ mingw-cap:
|
|||
- '**/*.h'
|
||||
- 'tools/lint/mingw-capitalization.yml'
|
||||
|
||||
py-compat:
|
||||
description: lint for python 2/3 compatibility issues
|
||||
treeherder:
|
||||
symbol: py(py-compat)
|
||||
run:
|
||||
mach: lint -v -l py2 -l py3 -f treeherder -f json:/builds/worker/mozlint.json *
|
||||
when:
|
||||
files-changed:
|
||||
- '**/*.py'
|
||||
- '**/.flake8'
|
||||
- 'tools/lint/py2.yml'
|
||||
- 'tools/lint/py3.yml'
|
||||
|
||||
py-flake8:
|
||||
description: flake8 run over the gecko codebase
|
||||
treeherder:
|
||||
|
|
|
@ -1,60 +0,0 @@
|
|||
---
|
||||
py2:
|
||||
description: Python 2 compatibility check
|
||||
include: ['.']
|
||||
exclude:
|
||||
- build
|
||||
- dom
|
||||
- editor
|
||||
- gfx
|
||||
- ipc
|
||||
- js/src
|
||||
- layout
|
||||
- modules
|
||||
- mozglue
|
||||
- netwerk
|
||||
- nsprpub
|
||||
- other-licenses
|
||||
- python/mozbuild/mozbuild/fork_interpose.py
|
||||
- security
|
||||
- servo
|
||||
- taskcluster/docker/funsize-update-generator
|
||||
- taskcluster/docker/visual-metrics
|
||||
- testing/condprofile
|
||||
- testing/gtest
|
||||
- testing/mochitest
|
||||
- testing/mozharness
|
||||
- testing/raptor
|
||||
- testing/tools
|
||||
- testing/web-platform
|
||||
- toolkit
|
||||
- tools/update-packaging
|
||||
- xpcom
|
||||
|
||||
# These paths are intentionally excluded (Python 3 only)
|
||||
- config/create_rc.py
|
||||
- config/create_res.py
|
||||
- config/printconfigsetting.py
|
||||
- python/mozbuild/mozbuild/action/unify_symbols.py
|
||||
- python/mozbuild/mozbuild/action/unify_tests.py
|
||||
- python/mozbuild/mozbuild/html_build_viewer.py
|
||||
- python/mozbuild/mozpack/unify.py
|
||||
- python/mozbuild/mozpack/test/test_unify.py
|
||||
- python/mozlint
|
||||
- python/mozperftest
|
||||
- python/mozrelease/mozrelease/partner_repack.py
|
||||
- taskcluster/mach_commands.py
|
||||
- taskcluster/taskgraph/actions/isolate_test.py
|
||||
- taskcluster/test
|
||||
- testing/jsshell
|
||||
- testing/performance
|
||||
- tools/crashreporter/system-symbols/win/symsrv-fetch.py
|
||||
- tools/github-sync
|
||||
- tools/lint
|
||||
- tools/tryselect
|
||||
extensions: ['py']
|
||||
support-files:
|
||||
- 'tools/lint/python/*compat*'
|
||||
type: external
|
||||
payload: python.compat:lintpy2
|
||||
setup: python.compat:setuppy2
|
|
@ -1,28 +0,0 @@
|
|||
---
|
||||
py3:
|
||||
description: Python 3 compatibility check
|
||||
include: ['.']
|
||||
exclude:
|
||||
- browser/app
|
||||
- build
|
||||
- dom/canvas/test
|
||||
- gfx
|
||||
- ipc/ipdl
|
||||
- layout/style/ServoCSSPropList.mako.py
|
||||
- security/manager/ssl
|
||||
- testing/awsy
|
||||
- testing/condprofile/condprof/android.py
|
||||
- testing/condprofile/condprof/desktop.py
|
||||
- testing/gtest
|
||||
- testing/mozharness
|
||||
- testing/tps
|
||||
- testing/web-platform/tests
|
||||
- testing/web-platform/mozilla/tests/tools/wptserve_py2/
|
||||
- toolkit
|
||||
- xpcom/idl-parser
|
||||
extensions: ['py']
|
||||
support-files:
|
||||
- 'tools/lint/python/*compat*'
|
||||
type: external
|
||||
payload: python.compat:lintpy3
|
||||
setup: python.compat:setuppy3
|
|
@ -1,87 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
import ast
|
||||
import json
|
||||
import sys
|
||||
|
||||
|
||||
def parse_file(f):
|
||||
with open(f, "rb") as fh:
|
||||
content = fh.read()
|
||||
try:
|
||||
return ast.parse(content)
|
||||
except SyntaxError as e:
|
||||
err = {
|
||||
"path": f,
|
||||
"message": e.msg,
|
||||
"lineno": e.lineno,
|
||||
"column": e.offset,
|
||||
"source": e.text,
|
||||
"rule": "is-parseable",
|
||||
}
|
||||
print(json.dumps(err))
|
||||
|
||||
|
||||
def check_compat_py2(f):
|
||||
"""Check Python 2 and Python 3 compatibility for a file with Python 2"""
|
||||
root = parse_file(f)
|
||||
|
||||
# Ignore empty or un-parseable files.
|
||||
if not root or not root.body:
|
||||
return
|
||||
|
||||
futures = set()
|
||||
haveprint = False
|
||||
future_lineno = 1
|
||||
may_have_relative_imports = False
|
||||
for node in ast.walk(root):
|
||||
if isinstance(node, ast.ImportFrom):
|
||||
if node.module == "__future__":
|
||||
future_lineno = node.lineno
|
||||
futures |= set(n.name for n in node.names)
|
||||
else:
|
||||
may_have_relative_imports = True
|
||||
elif isinstance(node, ast.Import):
|
||||
may_have_relative_imports = True
|
||||
elif isinstance(node, ast.Print):
|
||||
haveprint = True
|
||||
|
||||
err = {
|
||||
"path": f,
|
||||
"lineno": future_lineno,
|
||||
"column": 1,
|
||||
}
|
||||
|
||||
if "absolute_import" not in futures and may_have_relative_imports:
|
||||
err["rule"] = "require absolute_import"
|
||||
err["message"] = "Missing from __future__ import absolute_import"
|
||||
print(json.dumps(err))
|
||||
|
||||
if haveprint and "print_function" not in futures:
|
||||
err["rule"] = "require print_function"
|
||||
err["message"] = "Missing from __future__ import print_function"
|
||||
print(json.dumps(err))
|
||||
|
||||
|
||||
def check_compat_py3(f):
|
||||
"""Check Python 3 compatibility of a file with Python 3."""
|
||||
parse_file(f)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if sys.version_info[0] == 2:
|
||||
fn = check_compat_py2
|
||||
else:
|
||||
fn = check_compat_py3
|
||||
|
||||
manifest = sys.argv[1]
|
||||
with open(manifest, "r") as fh:
|
||||
files = fh.read().splitlines()
|
||||
|
||||
for f in files:
|
||||
fn(f)
|
||||
|
||||
sys.exit(0)
|
|
@ -1,91 +0,0 @@
|
|||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
import json
|
||||
import os
|
||||
from distutils.spawn import find_executable
|
||||
|
||||
import mozfile
|
||||
from mozprocess import ProcessHandlerMixin
|
||||
|
||||
from mozlint import result
|
||||
from mozlint.pathutils import expand_exclusions
|
||||
|
||||
here = os.path.abspath(os.path.dirname(__file__))
|
||||
|
||||
results = []
|
||||
|
||||
|
||||
class PyCompatProcess(ProcessHandlerMixin):
|
||||
def __init__(self, config, *args, **kwargs):
|
||||
self.config = config
|
||||
kwargs["processOutputLine"] = [self.process_line]
|
||||
ProcessHandlerMixin.__init__(self, *args, **kwargs)
|
||||
|
||||
def process_line(self, line):
|
||||
try:
|
||||
res = json.loads(line)
|
||||
except ValueError:
|
||||
print(
|
||||
"Non JSON output from {} linter: {}".format(self.config["name"], line)
|
||||
)
|
||||
return
|
||||
|
||||
res["level"] = "error"
|
||||
results.append(result.from_config(self.config, **res))
|
||||
|
||||
|
||||
def setup(python):
|
||||
"""Setup doesn't currently do any bootstrapping. For now, this function
|
||||
is only used to print the warning message.
|
||||
"""
|
||||
binary = find_executable(python)
|
||||
if not binary:
|
||||
# TODO Bootstrap python2/python3 if not available
|
||||
print("warning: {} not detected, skipping py-compat check".format(python))
|
||||
|
||||
|
||||
def run_linter(python, paths, config, **lintargs):
|
||||
log = lintargs["log"]
|
||||
binary = find_executable(python)
|
||||
if not binary:
|
||||
# If we're in automation, this is fatal. Otherwise, the warning in the
|
||||
# setup method was already printed.
|
||||
if "MOZ_AUTOMATION" in os.environ:
|
||||
return 1
|
||||
return []
|
||||
|
||||
files = expand_exclusions(paths, config, lintargs["root"])
|
||||
|
||||
with mozfile.NamedTemporaryFile(mode="w") as fh:
|
||||
fh.write("\n".join(files))
|
||||
fh.flush()
|
||||
|
||||
cmd = [binary, os.path.join(here, "check_compat.py"), fh.name]
|
||||
log.debug("Command: {}".format(" ".join(cmd)))
|
||||
|
||||
proc = PyCompatProcess(config, cmd)
|
||||
proc.run()
|
||||
try:
|
||||
proc.wait()
|
||||
except KeyboardInterrupt:
|
||||
proc.kill()
|
||||
|
||||
return results
|
||||
|
||||
|
||||
def setuppy2(**lintargs):
|
||||
return setup("python2")
|
||||
|
||||
|
||||
def lintpy2(*args, **kwargs):
|
||||
return run_linter("python2", *args, **kwargs)
|
||||
|
||||
|
||||
def setuppy3(**lintargs):
|
||||
return setup("python3")
|
||||
|
||||
|
||||
def lintpy3(*args, **kwargs):
|
||||
return run_linter("python3", *args, **kwargs)
|
Загрузка…
Ссылка в новой задаче