Browse Source

Speedup travis-ci for pull requests

Cache result of `git diff`
Use python's re module instead of calling subprocess for simple grep
Hamilton Turner 11 years ago
parent
commit
3ac5af0b7c
1 changed files with 8 additions and 11 deletions
  1. 8 11
      toolset/run-ci.py

+ 8 - 11
toolset/run-ci.py

@@ -52,11 +52,6 @@ class CIRunnner:
       last_commit = subprocess.check_output("git rev-parse HEAD^", shell=True).rstrip('\n')
       last_commit = subprocess.check_output("git rev-parse HEAD^", shell=True).rstrip('\n')
       self.commit_range = "%s...HEAD" % last_commit
       self.commit_range = "%s...HEAD" % last_commit
 
 
-    log.info("Using commit range %s", self.commit_range)
-    log.info("Running `git diff --name-only %s`" % self.commit_range)
-    changes = subprocess.check_output("git diff --name-only %s" % self.commit_range, shell=True)
-    log.info(changes)
-
     #
     #
     # Find the one test from benchmark_config that we are going to run
     # Find the one test from benchmark_config that we are going to run
     #
     #
@@ -111,18 +106,20 @@ class CIRunnner:
     def touch(fname):
     def touch(fname):
       open(fname, 'a').close()
       open(fname, 'a').close()
 
 
+    log.info("Using commit range %s", self.commit_range)
+    log.info("Running `git diff --name-only %s`" % self.commit_range)
+    changes = subprocess.check_output("git diff --name-only %s" % self.commit_range, shell=True)
+    changes = "mojolicious/app.pl\nmojolicious/bash_profile.sh"
+    log.info(changes)
+
     # Look for changes to core TFB framework code
     # Look for changes to core TFB framework code
-    find_tool_changes = "git diff --name-only %s | grep '^toolset/' | wc -l" % self.commit_range
-    changes = subprocess.check_output(find_tool_changes, shell=True)  
-    if int(changes) != 0:
+    if re.search(r'^toolset/', changes, re.M) is not None: 
       log.info("Found changes to core framework code")
       log.info("Found changes to core framework code")
       touch('.run-ci.should_run')
       touch('.run-ci.should_run')
       return True
       return True
   
   
     # Look for changes relevant to this test
     # Look for changes relevant to this test
-    find_test_changes = "git diff --name-only %s | grep '^%s/' | wc -l" % (self.commit_range, self.directory)
-    changes = subprocess.check_output(find_test_changes, shell=True)
-    if int(changes) == 0:
+    if re.search("^%s/" % self.directory, changes, re.M) is None:
       log.info("No changes found for %s", self.name)
       log.info("No changes found for %s", self.name)
       touch('.run-ci.should_not_run')
       touch('.run-ci.should_not_run')
       return False
       return False