You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by sa...@apache.org on 2016/06/21 04:05:10 UTC

[06/14] lucene-solr:branch_5x: - Fail if there are unpushed commits in the Git working tree - Drop obsolete "--push-remote" param - Drop obsolete "--smoke-test" param - Update example RM cmdline usage - Support relative working tree root directory - Conv

- Fail if there are unpushed commits in the Git working tree
- Drop obsolete "--push-remote" param
- Drop obsolete "--smoke-test" param
- Update example RM cmdline usage
- Support relative working tree root directory
- Convert "root" positional cmdline arg into an optional "--root" arg defaulting to '.'
- Use sys.executable instead of $PYTHON_EXEC when printing smoke tester cmdline
- Add new fail-fast checks:
   - Check for a functional "git" executable
   - Ensure "ant" version is 1.8.X
   - Ensure working tree is under Git control, and contains 'lucene/', 'solr/' and 'dev-tools/' dirs


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

Branch: refs/heads/branch_5x
Commit: 427531286fe5e731ce6f7335faf5606e2391f1b0
Parents: ddc4fc5
Author: Steve Rowe <sa...@apache.org>
Authored: Mon May 23 15:28:06 2016 -0400
Committer: Steve Rowe <sa...@apache.org>
Committed: Tue Jun 21 00:03:01 2016 -0400

----------------------------------------------------------------------
 dev-tools/scripts/buildAndPushRelease.py | 85 ++++++++-------------------
 1 file changed, 26 insertions(+), 59 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/42753128/dev-tools/scripts/buildAndPushRelease.py
----------------------------------------------------------------------
diff --git a/dev-tools/scripts/buildAndPushRelease.py b/dev-tools/scripts/buildAndPushRelease.py
index 47a986d..8da13d3 100644
--- a/dev-tools/scripts/buildAndPushRelease.py
+++ b/dev-tools/scripts/buildAndPushRelease.py
@@ -61,8 +61,10 @@ def getGitRev():
   status = os.popen('git status').read().strip()
   if 'nothing to commit, working directory clean' not in status:
     raise RuntimeError('git clone is dirty:\n\n%s' % status)
+  unpushedCommits = os.popen('git log origin..').read().strip()
+  if len(unpushedCommits) > 0:
+    raise RuntimeError('There are unpushed commits - "git log origin.." output is:\n\n%s' % unpushedCommits)
 
-  # TODO: we should also detect unpushed changes here?  Something like "git cherry -v origin/branch_5_5"?
   print('  git clone is clean')
   return os.popen('git rev-parse HEAD').read().strip()
 
@@ -115,47 +117,6 @@ def prepare(root, version, gpgKeyID, gpgPassword):
   print()
   return rev
 
-def push(version, root, rev, rcNum, username):
-  print('Push...')
-  dir = 'lucene-solr-%s-RC%d-rev%s' % (version, rcNum, rev)
-  s = os.popen('ssh %s@people.apache.org "ls -ld public_html/staging_area/%s" 2>&1' % (username, dir)).read()
-  if 'no such file or directory' not in s.lower():
-    print('  Remove old dir...')
-    run('ssh %s@people.apache.org "chmod -R u+rwX public_html/staging_area/%s; rm -rf public_html/staging_area/%s"' % 
-        (username, dir, dir))
-  run('ssh %s@people.apache.org "mkdir -p public_html/staging_area/%s/lucene public_html/staging_area/%s/solr"' % \
-      (username, dir, dir))
-  print('  Lucene')
-  os.chdir('%s/lucene/dist' % root)
-  print('    zip...')
-  if os.path.exists('lucene.tar.bz2'):
-    os.remove('lucene.tar.bz2')
-  run('tar cjf lucene.tar.bz2 *')
-  print('    copy...')
-  run('scp lucene.tar.bz2 %s@people.apache.org:public_html/staging_area/%s/lucene' % (username, dir))
-  print('    unzip...')
-  run('ssh %s@people.apache.org "cd public_html/staging_area/%s/lucene; tar xjf lucene.tar.bz2; rm -f lucene.tar.bz2"' % (username, dir))
-  os.remove('lucene.tar.bz2')
-
-  print('  Solr')
-  os.chdir('%s/solr/package' % root)
-  print('    zip...')
-  if os.path.exists('solr.tar.bz2'):
-    os.remove('solr.tar.bz2')
-  run('tar cjf solr.tar.bz2 *')
-  print('    copy...')
-  run('scp solr.tar.bz2 %s@people.apache.org:public_html/staging_area/%s/solr' % (username, dir))
-  print('    unzip...')
-  run('ssh %s@people.apache.org "cd public_html/staging_area/%s/solr; tar xjf solr.tar.bz2; rm -f solr.tar.bz2"' % (username, dir))
-  os.remove('solr.tar.bz2')
-
-  print('  chmod...')
-  run('ssh %s@people.apache.org "chmod -R a+rX-w public_html/staging_area/%s"' % (username, dir))
-
-  print('  done!')
-  url = 'http://people.apache.org/~%s/staging_area/%s' % (username, dir)
-  return url
-
 def pushLocal(version, root, rev, rcNum, localDir):
   print('Push local [%s]...' % localDir)
   os.makedirs(localDir)
@@ -206,29 +167,23 @@ def read_version(path):
 def parse_config():
   epilogue = textwrap.dedent('''
     Example usage for a Release Manager:
-    python3.2 -u buildAndPushRelease.py --push-remote mikemccand --sign 6E68DA61 --rc-num 1 /path/to/lucene_solr_4_7
+    python3 -u dev-tools/scripts/buildAndPushRelease.py --push-local /tmp/releases/6.0.1 --sign 6E68DA61 --rc-num 1
   ''')
   description = 'Utility to build, push, and test a release.'
   parser = argparse.ArgumentParser(description=description, epilog=epilogue,
                                    formatter_class=argparse.RawDescriptionHelpFormatter)
   parser.add_argument('--no-prepare', dest='prepare', default=True, action='store_false',
                       help='Use the already built release in the provided checkout')
-  parser.add_argument('--push-remote', metavar='USERNAME',
-                      help='Push the release to people.apache.org for the given user')
   parser.add_argument('--push-local', metavar='PATH',
                       help='Push the release to the local path')
   parser.add_argument('--sign', metavar='KEYID',
                       help='Sign the release with the given gpg key')
   parser.add_argument('--rc-num', metavar='NUM', type=int, default=1,
                       help='Release Candidate number, required')
-  parser.add_argument('--smoke-test', metavar='PATH', 
-                      help='Run the smoker tester on the release in the given directory')
-  parser.add_argument('root', metavar='checkout_path',
-                      help='Root of SVN checkout for lucene-solr')
+  parser.add_argument('--root', metavar='WORKING_TREE_PATH', default='.',
+                      help='Root of Git working tree for lucene-solr')
   config = parser.parse_args()
 
-  if config.push_remote is not None and config.push_local is not None:
-    parser.error('Cannot specify --push-remote and --push-local together')
   if not config.prepare and config.sign:
     parser.error('Cannot sign already built release')
   if config.push_local is not None and os.path.exists(config.push_local):
@@ -236,8 +191,13 @@ def parse_config():
   if config.rc_num <= 0:
     parser.error('Release Candidate number must be a positive integer')
   if not os.path.isdir(config.root):
-    # TODO: add additional git check to ensure dir is a real lucene-solr checkout
-    parser.error('Root path is not a valid lucene-solr checkout')
+    parser.error('Root path "%s" is not a directory' % config.root)
+  cwd = os.getcwd()
+  os.chdir(config.root)
+  config.root = os.getcwd() # Absolutize root dir
+  if os.system('git rev-parse') or 3 != len([d for d in ('dev-tools','lucene','solr') if os.isdir(d)]):
+    parser.error('Root path "%s" is not a valid lucene-solr checkout' % config.root)
+  os.chdir(cwd)
 
   config.version = read_version(config.root)
   print('Building version: %s' % config.version)
@@ -251,8 +211,17 @@ def parse_config():
     config.gpg_password = None
 
   return config
+
+def check_cmdline_tools():  # Fail fast if there are cmdline tool problems
+  if os.system('git --version'):
+    raise RuntimeError('"git --version" returned a non-zero exit code.')
+  antVersion = os.popen('ant -version').read().strip()
+  if not antVersion.startswith('Apache Ant(TM) version 1.8'):
+    raise RuntimeError('ant version is not 1.8.X: "%s"' % antVersion)
   
 def main():
+  check_cmdline_tools()
+
   c = parse_config()
 
   if c.prepare:
@@ -261,19 +230,17 @@ def main():
     os.chdir(root)
     rev = open('rev.txt', encoding='UTF-8').read()
 
-  if c.push_remote:
-    url = push(c.version, c.root, rev, c.rc_num, c.push_remote)
-  elif c.push_local:
+  if c.push_local:
     url = pushLocal(c.version, c.root, rev, c.rc_num, c.push_local)
   else:
     url = None
 
   if url is not None:
     print('  URL: %s' % url)
-    print('Next set the PYTHON_EXEC env var and you can run the smoker tester:')
-    p = re.compile("(.*)\/")
+    print('Next run the smoker tester:')
+    p = re.compile(".*/")
     m = p.match(sys.argv[0])
-    print(' $PYTHON_EXEC %ssmokeTestRelease.py %s' % (m.group(), url))
+    print('%s -u %(s)smokeTestRelease.py %s' % (sys.executable, m.group(), url))
 
 if __name__ == '__main__':
   try: