mesos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ti...@apache.org
Subject mesos git commit: Updated support/mesos-style.py to build the virtualenv less often.
Date Thu, 21 Dec 2017 14:55:52 GMT
Repository: mesos
Updated Branches:
  refs/heads/master 760ab18c5 -> 4d263688a


Updated support/mesos-style.py to build the virtualenv less often.

Instead of just checking if the virtual environment exists, we now
also check if it is required to lint the modified files or not.

The virtual environment will thus be built when using the script as
a git hook only if JavaScript or Python files have been modified.

Review: https://reviews.apache.org/r/64683/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/4d263688
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/4d263688
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/4d263688

Branch: refs/heads/master
Commit: 4d263688a7cdb83b412570b4b4915e73eb827b12
Parents: 760ab18
Author: Armand Grillet <agrillet@mesosphere.io>
Authored: Thu Dec 21 15:18:42 2017 +0100
Committer: Till Toenshoff <toenshoff@me.com>
Committed: Thu Dec 21 15:18:42 2017 +0100

----------------------------------------------------------------------
 support/mesos-style.py | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/4d263688/support/mesos-style.py
----------------------------------------------------------------------
diff --git a/support/mesos-style.py b/support/mesos-style.py
index 315955e..1b34ea2 100755
--- a/support/mesos-style.py
+++ b/support/mesos-style.py
@@ -410,10 +410,6 @@ def should_build_virtualenv(modified_files):
     have changed or if the support script is run with no
     arguments (meaning that the entire codebase should be linted).
     """
-    if not os.path.isdir(os.path.join('support', '.virtualenv')):
-        print 'Virtualenv not detected... building'
-        return True
-
     # NOTE: If the file list is empty, we are linting the entire
     # codebase. We should always rebuild the virtualenv in this case.
     if not modified_files:
@@ -429,6 +425,20 @@ def should_build_virtualenv(modified_files):
         print 'The "build-virtualenv" file has changed.'
         return True
 
+    # The JS and Python linters require a virtual environment.
+    # If all the files modified are not JS or Python files,
+    # we do not need to build the virtual environment.
+    # TODO(ArmandGrillet): There should be no duplicated logic to know
+    # which linters to instantiate depending on the files to analyze.
+    if not os.path.isdir(os.path.join('support', '.virtualenv')):
+        js_and_python_files = [JsLinter().source_files, PyLinter().source_files]
+        js_and_python_files_regex = re.compile('|'.join(js_and_python_files))
+
+        for basename in basenames:
+            if js_and_python_files_regex.search(basename) is not None:
+                print 'Virtualenv not detected and required... building'
+                return True
+
     return False
 
 
@@ -456,6 +466,9 @@ def build_virtualenv():
 if __name__ == '__main__':
     if should_build_virtualenv(sys.argv[1:]):
         build_virtualenv()
+
+    # TODO(ArmandGrillet): We should only instantiate the linters
+    # required to lint the files to analyze. See MESOS-8351.
     CPP_LINTER = CppLinter()
     CPP_ERRORS = CPP_LINTER.main(sys.argv[1:])
     JS_LINTER = JsLinter()


Mime
View raw message