You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zeppelin.apache.org by mo...@apache.org on 2017/02/19 01:49:17 UTC

zeppelin git commit: [MINOR] Improve travis_check.py script

Repository: zeppelin
Updated Branches:
  refs/heads/master 03cdbe313 -> cbe2ef4f9


[MINOR] Improve travis_check.py script

### What is this PR for?
Now travis_check.py script ran by Jenkins in each pullrequest.
In Jenkins output console, outputs are displayed after script return.
This small patch try flush output, so Jenkins output console can display output while script is running.

Also increase check polling up to 2 hours while contributors travis might be busy.

And print link to individual job for convenience.

### What type of PR is it?
Improvement

### Todos
* [x] - flush output
* [x] - increase number of check up to about 2 hours
* [x] - print url link to individual job

### What is the Jira issue?
https://issues.apache.org/jira/browse/ZEPPELIN-2123

### Questions:
* Does the licenses files need update? no
* Is there breaking changes for older versions? no
* Does this needs documentation? no

Author: Lee moon soo <mo...@apache.org>

Closes #2031 from Leemoonsoo/flush_ci_output and squashes the following commits:

d144880 [Lee moon soo] Lambda to function
554f9d3 [Lee moon soo] make 3rd param override check interval. usage in the comment
1f2549a [Lee moon soo] increase polling count. beautifulize output
854be0d [Lee moon soo] Flush output


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

Branch: refs/heads/master
Commit: cbe2ef4f951f6a448daa0fe3c64b307a81a00c67
Parents: 03cdbe3
Author: Lee moon soo <mo...@apache.org>
Authored: Sat Feb 18 14:25:38 2017 +0900
Committer: Lee moon soo <mo...@apache.org>
Committed: Sun Feb 19 10:49:09 2017 +0900

----------------------------------------------------------------------
 travis_check.py | 41 ++++++++++++++++++++++++++++++-----------
 1 file changed, 30 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zeppelin/blob/cbe2ef4f/travis_check.py
----------------------------------------------------------------------
diff --git a/travis_check.py b/travis_check.py
index c110472..a2fa288 100644
--- a/travis_check.py
+++ b/travis_check.py
@@ -17,6 +17,18 @@
 #
 # This script checks build status of given pullrequest identified by author and commit hash.
 #
+# usage)
+#   python travis_check.py [author] [commit hash] [check interval (optional)]
+#
+# example)
+#   # full hash
+#   python travis_check.py Leemoonsoo 1f2549a38f440ebfbfe2d32a041684e3e39b496c
+#
+#   # with short hash
+#   python travis_check.py Leemoonsoo 1f2549a
+#
+#   # with custom check interval
+#   python travis_check.py Leemoonsoo 1f2549a 5,60,60
 
 import os, sys, getopt, traceback, json, requests, time
 
@@ -24,11 +36,14 @@ author = sys.argv[1]
 commit = sys.argv[2]
 
 # check interval in sec
-check = [5, 60, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300]
+check = [5, 60, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 600, 600, 600, 600, 600, 600]
+
+if len(sys.argv) > 3:
+    check = map(lambda x: int(x), sys.argv[3].split(","))
 
 def info(msg):
     print("[" + time.strftime("%Y-%m-%d %H:%M:%S") + "] " + msg)
-
+    sys.stdout.flush()
 
 info("Author: " + author + ", commit: " + commit)
 
@@ -49,35 +64,39 @@ def getBuildStatus(author, commit):
 
     return build
 
+def status(index, msg, jobId):
+    return '{:20}'.format("[" + str(index+1) + "] " + msg) + "https://travis-ci.org/" + author + "/zeppelin/jobs/" + str(jobId)
 
 def printBuildStatus(build):
     failure = 0
     running = 0
+
     for index, job in enumerate(build["matrix"]):
         result = job["result"]
+        jobId = job["id"]
+
         if job["started_at"] == None and result == None:
-            print("[" + str(index+1) + "] Not started")
+            print(status(index, "Not started", jobId))
             running = running + 1
         elif job["started_at"] != None and job["finished_at"] == None:
-            print("[" + str(index+1) + "] Running ...")
+            print(status(index, "Running ...", jobId))
             running = running + 1
         elif job["started_at"] != None and job["finished_at"] != None:
             if result == None:
-                print("[" + str(index+1) + "] Not completed")
+                print(status(index, "Not completed", jobId))
                 failure = failure + 1
             elif result == 0:
-                print("[" + str(index+1) + "] OK")
+                print(status(index, "OK", jobId))
             else:
-                print("[" + str(index+1) + "] Error " + str(result))
+                print(status(index, "Error " + str(result), jobId))
                 failure = failure + 1
         else:
-            print("[" + str(index+1) + "] Unknown state")
+            print(status(index, "Unknown state", jobId))
             failure = failure + 1
 
     return failure, running
 
 
-
 for sleep in check:
     info("--------------------------------")
     time.sleep(sleep);
@@ -87,10 +106,10 @@ for sleep in check:
         info("Can't find build for commit= " + commit)
         sys.exit(1)
 
-    print("https://travis-ci.org/" + author + "/zeppelin/builds/" + str(build["id"]))
+    print("Build https://travis-ci.org/" + author + "/zeppelin/builds/" + str(build["id"]))
     failure, running = printBuildStatus(build)
 
-    print(str(failure) + " job(s) failed, " + str(running) + " job(s) running")
+    print(str(failure) + " job(s) failed, " + str(running) + " job(s) running/pending")
 
     if failure != 0:
         sys.exit(1)