From: <raj...@us...> - 2009-03-14 18:48:39
|
Revision: 14492 http://cdk.svn.sourceforge.net/cdk/?rev=14492&view=rev Author: rajarshi Date: 2009-03-14 18:48:18 +0000 (Sat, 14 Mar 2009) Log Message: ----------- Updated config example to include a git branch variable Modified Paths: -------------- nightly/trunk/nightly.config.sample nightly/trunk/nightly.py Modified: nightly/trunk/nightly.config.sample =================================================================== --- nightly/trunk/nightly.config.sample 2009-03-13 16:16:23 UTC (rev 14491) +++ nightly/trunk/nightly.config.sample 2009-03-14 18:48:18 UTC (rev 14492) @@ -1,4 +1,4 @@ -# should point to an SVN repo, within which doing +# should point to a local Git repo, within which doing # ant dist-all should work nightly_repo = '/home/rguha/src/java/cdk-nightly/cdk/' @@ -10,6 +10,9 @@ git_path = 'None' #git_path = 'http://github.com/egonw/cdk/tree/master' +# Which Git branch to build +git_branch = 'master' + # should point to a directory in which this script # is to be placed and will contain log files nightly_dir = '/home/rguha/src/java/cdk-nightly/' @@ -35,8 +38,9 @@ japitools_path = '/home/rguha/src/java/japitools' -# Optional boolean to indicate that no bug statistics should be calculated -#noBugStats=true +# Optional +# boolean to indicate whether bug statistics should be calculated +bugStats=False # Optional # path to the last stable CDK distribution jar Modified: nightly/trunk/nightly.py =================================================================== --- nightly/trunk/nightly.py 2009-03-13 16:16:23 UTC (rev 14491) +++ nightly/trunk/nightly.py 2009-03-14 18:48:18 UTC (rev 14492) @@ -1,7 +1,7 @@ #!/usr/bin/python # -# Rajarshi Guha <rg...@in...> +# Rajarshi Guha <raj...@gm...> # 04/30/2006 # # Requires a Unix system, for now @@ -70,6 +70,7 @@ import string, sys, os, os.path, time, re, glob, shutil, pickle import tarfile, StringIO +import datetime from email.MIMEText import MIMEText import email.Utils import smtplib @@ -80,6 +81,7 @@ # ################################################################# +debug = False pickle_file = None today = time.localtime() @@ -89,7 +91,7 @@ firstTime = False haveXSLT = True noMail = False -runBugStats = True +bugStats = True # check to see if we have libxml2 and libxslt try: @@ -545,16 +547,24 @@ return os.path.join(nightly_dir, logFileName) -def updateSVN(): +def updateRepo(): olddir = os.getcwd() os.chdir(nightly_repo) - status = os.system('svn update > %s' % getLogFilePath('svn.log')) + status = os.system('git checkout %s' % (git_branch)) if status == 0: - print 'svn ok' + print 'git checkout %s ok' % (git_branch) + else: + print 'git checkout %s failed. Not proceeding' % (git_branch) + os.chdir(olddir) + return False + + status = os.system('git pull > %s' % getLogFilePath('git.log')) + if status == 0: + print 'git pull ok' os.chdir(olddir) return True else: - print 'svn failed' + print 'git pull failed' os.chdir(olddir) return False @@ -854,42 +864,35 @@ celltext.append('<a href="emma.log">emma.log</a>') return celltext -def updateVersion(): +def getVersion(): # update the build.props file f = open(os.path.join(nightly_repo, 'build.props'), 'r') lines = [x.strip() for x in f.readlines()] f.close() if lines[0].find('version') != 0: - return False - - tmp = lines[0].split('=') - if tmp[1] == 'svn-%s' % (todayStr): - return True # it's the same day so nothing to do! - - lines[0] = '%s=svn-%s' % (tmp[0], todayStr) - f = open(os.path.join(nightly_repo, 'build.props'), 'w') - f.write('%s\n' % (string.join(lines, '\n'))) - f.close() + return None + else: + return lines[0].split('=')[1].strip() + +def getGitInfo(): + oldDir = os.getcwd() + os.chdir(nightly_repo) - # do we need to do a commit? - - return True - -def getSVNRevision(): - if not os.path.exists(os.path.join(nightly_dir,'svn.log')): - return None - - tmp = [x.strip() for x in open(os.path.join(nightly_dir,'svn.log'), 'r').readlines()] - revision = None - for line in tmp: - if line.startswith('At revision'): - revision = line.split()[2][:-1] - break - elif line.startswith('Updated to revision'): - revision = line.split()[3][:-1] - break - return revision + cmd = 'git log --pretty=medium --date=iso > tmpgit.log' + if debug: print '** Dir: %s Op: %s' % (os.getcwd(), cmd) + os.system(cmd) + gitLog = open('tmpgit.log', 'r').readlines() + if len(gitLog) <= 1: return None, None + + commitHash = gitLog[0].split()[1].strip() + commitDate = ' '.join(gitLog[3].split()[1:3]) + commitDate = datetime.datetime.strptime(commitDate, "%Y-%m-%d %H:%M:%S") + + os.unlink('tmpgit.log') + os.chdir(oldDir) + + return commitHash, commitDate if __name__ == '__main__': if 'help' in sys.argv: @@ -917,7 +920,7 @@ sys.exit(0) myl = {} def dummyFunction(): pass - validConfigVars = ["nightly_repo", "nightly_dir", "nightly_web", "ant_libs", "classpath", "japitools_path", "last_stable", "per_line", "smtpServerName", "fromName", "toName", "smtpLogin", "smtpPassword", "links", "title_web", "git_path", "svn_path", "noBugStats"] + validConfigVars = ["nightly_repo", "nightly_dir", "nightly_web", "ant_libs", "classpath", "japitools_path", "last_stable", "per_line", "smtpServerName", "fromName", "toName", "smtpLogin", "smtpPassword", "links", "title_web", "git_path", "svn_path", "git_branch", "bugStats"] execfile(sys.argv[1], myl) for key in myl.keys(): if key == '__builtins__': continue @@ -932,7 +935,7 @@ Configuration file = %s""" % (sys.argv[1]) # check for the presence of required executable - executableList = ['java', 'ant', 'tar', 'nice', 'svn', 'rm'] + executableList = ['java', 'ant', 'tar', 'nice', 'git', 'rm'] ret = map( executableExists, executableList ) if False in executableList: print 'Could not find one or more required executables: '+executableList @@ -978,9 +981,6 @@ if 'firsttime' in [x.lower() for x in sys.argv] or 'first' in [x.lower() for x in sys.argv]: firstTime= True - if noBugStats == 'true': - runBugStats = False - # print out some status stuff print """ Variable settings @@ -1000,7 +1000,7 @@ successPMD = True successPMDUnused = True successPMDMigrate = True - successSVN = True + successGit = True successJCP = False currentRevision = None @@ -1009,6 +1009,11 @@ start_dir = os.getcwd() os.chdir(nightly_dir) + cdk_version = getVersion() + if not cdk_version: + print 'Error getting curent CDK version string' + sys.exit(-1) + if not dryRun: # before cleaning anything, lets get some old data @@ -1021,6 +1026,7 @@ data = pickle.load(open(pickle_file, 'r')) oldReports = data[0] oldRevision = data[1] + oldDate = data[2] else: print 'Processing old data' reports = glob.glob(os.path.join(nightly_repo, 'reports', '*.txt')) @@ -1030,9 +1036,9 @@ for line in open(report, 'r'): if line.startswith('Testcase:'): oldReports.append(''.join(line.split(':')[:2])) - oldRevision = getSVNRevision() + oldRevision, oldDate = getGitInfo() if not oldRevision and not firstTime: - print 'Error getting the SVN revision. Exiting' + print 'Error getting the Git log info. Exiting' sys.exit(-1) # clean out any files from a previous SEGV in the repo dir @@ -1056,11 +1062,11 @@ os.unlink(logfile) # go into the repo and sync with SVN - successSVN = updateSVN() + successGit = updateRepo() # if we failed, report it and use previous build info - if not successSVN: - print 'Could not connect to SVN. Skipping nightly build' + if not successGit: + print 'Could not update Git. Skipping nightly build' f = open(os.path.join(nightly_web, 'index.html'), 'r') lines = string.join(f.readlines()) f.close() @@ -1076,27 +1082,23 @@ sys.exit(0) # get the latest revision number - currentRevision = getSVNRevision() + currentRevision, currentDate = getGitInfo() if not currentRevision: - print 'Error getting the SVN revision. Exiting' + print 'Error getting git info. exiting' sys.exit(-1) # if there is no change in rev number since our # last run, we can skip the run - print 'Old revision = %s Current Revision = %s' % (oldRevision, currentRevision) - if oldRevision == currentRevision: + print 'Old revision = %s\nCurrent Revision = %s' % (oldRevision, currentRevision) + if oldRevision == currentRevision and not firstTime: print ' No commits since last run. Exiting' - #sys.exit(0) + sys.exit(0) - status = updateVersion() - if not status: - print "Error parsing build.props. Could not a valid version line. Exiting" - sys.exit(-1) # compile the distro successDist = runAntJob('nice -n 19 ant -lib %s clean dist-large' % (ant_libs), 'build.log', 'distro') if successDist: # if we compiled, do the rest of the stuff - successJCP = runAntJob('nice -n 19 ant -lib %s -f build-jchempaint.xml' % (ant_libs), 'jcp.log', 'jcp') +# successJCP = runAntJob('nice -n 19 ant -lib %s -f build-jchempaint.xml' % (ant_libs), 'jcp.log', 'jcp') successTestDist = runAntJob('nice -19 ant -lib %s dist-test-large' % (ant_libs), 'testdist.log', 'testdist') successSrc = runAntJob('nice -19 ant -lib %s sourcedist' % (ant_libs), 'srcdist.log', 'srcdist') successTest = runAntJob('nice -n 19 ant -lib %s -DrunSlowTests=false test-all' % (ant_libs), 'test.log', 'test') @@ -1139,6 +1141,7 @@ os.chdir(start_dir) sys.exit(0) else: + currentRevision, currentDate = getGitInfo() print 'Doing dry run' @@ -1156,7 +1159,7 @@ <html> <head> <title> - %s - %s (%s) [SVN Revision %s] + %s - %s (%s) [Commit %s] </title> <style> <!-- @@ -1168,9 +1171,9 @@ <body> <center> <h2>%s - %s (%s EST) - <i>[<a href=\"https://sourceforge.net/svn/?group_id=20024\">SVN</a> - Revision %s]</i></h2> - """ % (title_web, todayNice, currTime, currentRevision, title_web, todayNice, currTime, currentRevision) + <i>[<a href=\"http://cdk.git.sourceforge.net/git/gitweb.cgi?p=cdk;a=summary">Git</a> + Commit <span style="font-size: small"><a href="http://cdk.git.sourceforge.net/git/gitweb.cgi?p=cdk;a=commit;h=%s">%s</a></span>]</i></h2> + """ % (title_web, todayNice, currTime, currentRevision, title_web, todayNice, currTime, currentRevision, currentRevision) resultTable = HTMLTable() resultTable.addHeaderCell("") @@ -1180,13 +1183,13 @@ # lets now make the web site for nightly builds if successDist: print ' Generating distro section' - distSrc = os.path.join(nightly_repo, 'dist', 'jar', 'cdk-svn-%s.jar' % (todayStr)) - distDest = os.path.join(nightly_web, 'cdk-svn-%s.jar' % (todayStr)) + distSrc = os.path.join(nightly_repo, 'dist', 'jar', 'cdk-%s.jar' % (cdk_version)) + distDest = os.path.join(nightly_web, 'cdk-git-%s.jar' % (todayStr)) shutil.copyfile(distSrc, distDest) resultTable.addRow() resultTable.addCell("Combined CDK jar files:") - resultTable.addCell("<a href=\"cdk-svn-%s.jar\">cdk-svn-%s.jar</a>" % (todayStr, todayStr)) + resultTable.addCell("<a href=\"cdk-git-%s.jar\">cdk-git-%s.jar</a>" % (todayStr, todayStr)) logEntryText = copyLogFile('build.log', nightly_dir, nightly_web) if logEntryText: @@ -1197,29 +1200,29 @@ if successJCP: jcpSrc = glob.glob(os.path.join(nightly_repo, 'dist', 'jar', 'jchempaint*.jar'))[0] - jcpDest = os.path.join(nightly_web, 'jchempaint-svn-%s.jar' % (todayStr)) + jcpDest = os.path.join(nightly_web, 'jchempaint-git-%s.jar' % (todayStr)) shutil.copyfile(jcpSrc, jcpDest) resultTable.addRow() resultTable.addCell('JChemPaint') - resultTable.addCell("<a href='jchempaint-svn-%s.jar'>jchempaint-svn-%s.jar</a>" % (todayStr, todayStr)) + resultTable.addCell("<a href='jchempaint-git-%s.jar'>jchempaint-git-%s.jar</a>" % (todayStr, todayStr)) logEntryText = copyLogFile('jcp.log', nightly_dir, nightly_web) if logEntryText: resultTable.addCell(logEntryText) if successSrc: print ' Generating source distro section' - srcSrc = os.path.join(nightly_repo, 'cdk-src+libs-svn-%s.tar.gz' % (todayStr)) - srcDest = os.path.join(nightly_web, 'cdk-src+libs-svn-%s.tar.gz' % (todayStr)) + srcSrc = os.path.join(nightly_repo, 'cdk-src+libs-%s.tar.gz' % (cdk_version)) + srcDest = os.path.join(nightly_web, 'cdk-src+libs-git-%s.tar.gz' % (todayStr)) shutil.copyfile(srcSrc, srcDest) - srcSrc = os.path.join(nightly_repo, 'cdk-src+libs-svn-%s.zip' % (todayStr)) - srcDest = os.path.join(nightly_web, 'cdk-src+libs-svn-%s.zip' % (todayStr)) + srcSrc = os.path.join(nightly_repo, 'cdk-src+libs-%s.zip' % (cdk_version)) + srcDest = os.path.join(nightly_web, 'cdk-src+libs-git-%s.zip' % (todayStr)) shutil.copyfile(srcSrc, srcDest) resultTable.addRow() resultTable.addCell("CDK Source files:") - resultTable.addCell("<a href=\"cdk-src+libs-svn-%s.tar.gz\">Compressed tar file</a>" % (todayStr)) - resultTable.appendToCell("<a href=\"cdk-src+libs-svn-%s.zip\">ZIP file</a>" % (todayStr)) + resultTable.addCell("<a href=\"cdk-src+libs-git-%s.tar.gz\">Compressed tar file</a>" % (todayStr)) + resultTable.appendToCell("<a href=\"cdk-src+libs-git-%s.zip\">ZIP file</a>" % (todayStr)) if svn_path != 'None': resultTable.appendToCell("<a href=\"%s\">SVN Repository</a>" % (svn_path)) if git_path != 'None': @@ -1248,7 +1251,7 @@ resultTable.addCell("<a href=\"javadoc-%s.tgz\">Tarball</a>" % (todayStr)) - resultTable.appendToCell("<a href=\"api\">Browse online</a>") + resultTable.appendToCell("<a href=\"api/index.html\">Browse online</a>") # check whether we can copy the run output resultTable.addCell(copyLogFile('javadoc.log', nightly_dir, nightly_web)) @@ -1298,7 +1301,7 @@ resultTable.addRule() print ' Generating descriptor summary' - distjar = glob.glob(os.path.join(nightly_repo, 'dist', 'jar', 'cdk-svn-*'))[0] + distjar = glob.glob(os.path.join(nightly_repo, 'dist', 'jar', 'cdk-%s*' % (cdk_version)))[0] cmd = 'java -cp %s:%s bsh.Interpreter %s > %s' % \ (classpath, distjar, os.path.join(nightly_repo, 'tools', 'dnames.bsh'), os.path.join(nightly_web, 'dnames.html')) os.system(cmd) @@ -1348,7 +1351,7 @@ # next run. Byt only do so, if the current version # is newer than the older version if currentRevision != oldRevision: - data = [newReports, currentRevision] + data = [newReports, currentRevision, currentDate] pickle.dump(data, open(pickle_file, 'w')) # dump out a nice HTML diff page @@ -1605,7 +1608,7 @@ # run the bug analysis code print ' Performing bug analysis' sys.path.append( os.path.join(nightly_repo, 'tools') ) - if runBugStats: + if bugStats: import analyzeBugs try: analyzeBugs.analyzeBugs( os.path.join(nightly_web, 'bugs.html'), os.path.join(nightly_repo, 'src/main') ) @@ -1639,12 +1642,21 @@ os.chdir(nightly_repo) os.system('ant info > %s' % (os.path.join(nightly_web, 'antinfo.txt'))) + def getSysInfo(filename): + data = ''.join(open(filename).readlines()) + osname = re.findall('OS:\s+(.*)', data) + osversion = re.findall('Version:\s+(.*)', data) + javaversion = re.findall('Java version:\s+(.*)', data) + javavendor = re.findall('Java vendor:\s+(.*)', data) + return osname[0], osversion[0],javaversion[0],javavendor[0] + + on,ov,jv,jn = getSysInfo(os.path.join(nightly_web, 'antinfo.txt')) + resultTable.addRule() resultTable.addRow() resultTable.addCell("<i>Build details</i>") - resultTable.addCell("<i>Red Hat Enterprise Linux</i>") - resultTable.appendToCell("<i>Sun JDK 1.5.0</i>") - resultTable.appendToCell("<i>Ant 1.6.2</i>") + resultTable.addCell("<i>%s %s</i>" % (on, ov)) + resultTable.appendToCell("<i>%s JDK %s</i>" % (jn, jv)) resultTable.appendToCell("<a href=\"antinfo.txt\">ant info</a>") page = page + str(resultTable) @@ -1673,13 +1685,6 @@ os.path.join(nightly_web, 'javadoc')) os.system(cmd) - # lets get rid of the build.props file - # so that the next build will get the latest from svn - try: - os.unlink(os.path.join(nightly_repo, 'build.props')) - except OSError, e: - pass - # go back to where we started os.chdir(start_dir) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |