source: branches/testScripts/nightlyBuild.py @ 634

Last change on this file since 634 was 633, checked in by jpfasano, 12 years ago

Created new file(module) for checking the results to see if a test
was successfull. This code was moved out of nightlyBuild.py.
Added code to test if DyLP and Osi were successful based on email from
Lou.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 8.7 KB
Line 
1#! /usr/bin/env python
2
3import os
4import sys
5
6import NBuserConfig
7import NBprojectConfig
8import NBlogMessages
9import NBemail
10import NBosCommand
11import NBsvnCommand
12import NBcheckResult
13
14# TODO:
15#   -After "svn co" then get all 3rd party packages.
16#   -Get some information about the platform and put this in email failure message.
17#   -Implement Kipp's vpath (delete vpath instead of 'make distclean').
18#   Break this file up into multiple files so it is manageable.
19#   Don't do build if 'svn update' doesn't change anything and prior test was OK.
20#     (no need to re-run if nothing has changed since prior run)
21#   Build both trunk and latest stable
22#   Build both optimized and debug (or have a set of config-site scripts to test?)
23#   Check the testing of the success criteria of each projects "make test"
24#   Implement "cbc -miplib" test for successful run.  JohnF sent JP the criteria
25#     to test on in an email dated 10/12/2007 12:01pm
26
27
28
29#------------------------------------------------------------------------
30#  Main Program Starts Here 
31#------------------------------------------------------------------------
32
33#------------------------------------------------------------------------
34#  If needed create the top level directory
35#------------------------------------------------------------------------
36if not os.path.isdir(NBuserConfig.NIGHTLY_BUILD_ROOT_DIR) :
37  os.makedirs(NBuserConfig.NIGHTLY_BUILD_ROOT_DIR)
38os.chdir(NBuserConfig.NIGHTLY_BUILD_ROOT_DIR)
39
40#------------------------------------------------------------------------
41#  Get the data directories if they don't already exist
42#------------------------------------------------------------------------
43dataBaseDir=os.path.join(NBuserConfig.NIGHTLY_BUILD_ROOT_DIR,'Data')
44if not os.path.isdir(dataBaseDir) :
45  os.makedirs(dataBaseDir)
46dataDirs=['Netlib','miplib3']
47for d in dataDirs :
48  dataDir=os.path.join(dataBaseDir,d)
49  if not os.path.isdir(dataDir) :
50    svnCmd=os.path.join(NBuserConfig.SVNPATH_PREFIX,'svn') + ' checkout https://projects.coin-or.org/svn/Data/releases/1.0.0/'+d+' '+d
51    if NBsvnCommand.run(svnCmd,dataBaseDir,'Data')!='OK' :
52      sys.exit(1)
53    result=NBosCommand.run('find '+d+' -name \*.gz -print | xargs gzip -d')
54netlibDir=os.path.join(dataBaseDir,'Netlib')
55miplib3Dir=os.path.join(dataBaseDir,'miplib3')
56
57#------------------------------------------------------------------------
58# Loop once for each project
59#------------------------------------------------------------------------
60for p in NBuserConfig.PROJECTS:
61  NBlogMessages.writeMessage( p )
62
63  #---------------------------------------------------------------------
64  # svn checkout or update the project
65  #---------------------------------------------------------------------
66  projectBaseDir=os.path.join(NBuserConfig.NIGHTLY_BUILD_ROOT_DIR,p)
67  projectCheckOutDir=os.path.join(projectBaseDir,'trunk')
68  if not os.path.isdir(projectBaseDir) :
69    os.makedirs(projectBaseDir)
70  if not os.path.isdir(projectCheckOutDir) :
71    svnCmd=os.path.join(NBuserConfig.SVNPATH_PREFIX,'svn') + ' checkout https://projects.coin-or.org/svn/'+p+'/trunk trunk'
72    if NBsvnCommand.run(svnCmd,projectBaseDir,p)!='OK' :
73      continue
74  else :
75    svnCmd=os.path.join(NBuserConfig.SVNPATH_PREFIX,'svn') + ' update'
76    if NBsvnCommand.run(svnCmd,projectCheckOutDir,p)!='OK' :
77      continue
78
79  #---------------------------------------------------------------------
80  # Should probably run make 'distclean' to do a build from scrath
81  # or delete the VPATH directory when there is one
82  #---------------------------------------------------------------------
83
84
85  #---------------------------------------------------------------------
86  # Run configure part of buid
87  #---------------------------------------------------------------------
88  os.chdir(projectCheckOutDir)
89  configCmd = os.path.join('.','configure -C')
90  if NBcheckResult.didConfigRunOK() :
91    NBlogMessages.writeMessage("  '"+configCmd+"' previously ran. Not rerunning")
92  else :
93    NBlogMessages.writeMessage('  '+configCmd)
94    result=NBosCommand.run(configCmd)
95 
96    # Check if configure worked
97    if result['returnCode'] != 0 :
98      error_msg = result
99      # Add contents of log file to message
100      logFileName = 'config.log'
101      if os.path.isfile(logFileName) :
102        logFilePtr = open(logFileName,'r')
103        error_msg['config.log']  = "config.log contains: \n" 
104        error_msg['config.log'] += logFilePtr.read()
105        logFilePtr.close()
106      NBemail.sendCmdMsgs(p,error_msg,configCmd)
107      continue
108
109  #---------------------------------------------------------------------
110  # Run make part of build
111  #---------------------------------------------------------------------
112  NBlogMessages.writeMessage( '  make' )
113  result=NBosCommand.run('make')
114 
115  # Check if make worked
116  if result['returnCode'] != 0 :
117    NBemail.sendCmdMsgs(p,result,'make')
118    continue
119
120  #---------------------------------------------------------------------
121  # Run 'make test' part of build
122  #---------------------------------------------------------------------
123  NBlogMessages.writeMessage( '  make test' )
124  result=NBosCommand.run('make test')
125 
126  # Check if 'make test' worked
127  if NBcheckResult.didTestFail(result,p,"make test") :
128    NBemail.sendCmdMsgs(p,result,"make test")
129    continue
130
131  #---------------------------------------------------------------------
132  # Run unitTest if available and different from 'make test'
133  #---------------------------------------------------------------------
134  if NBprojectConfig.UNITTEST_CMD.has_key(p) :
135    unitTestPath = os.path.join(projectCheckOutDir,NBprojectConfig.UNITTEST_DIR[p])
136    os.chdir(unitTestPath)
137
138    unitTestCmdTemplate=NBprojectConfig.UNITTEST_CMD[p]
139    unitTestCmd=unitTestCmdTemplate.replace('_NETLIBDIR_',netlibDir)
140    unitTestCmd=unitTestCmd.replace('_MIPLIB3DIR_',miplib3Dir)
141
142    NBlogMessages.writeMessage( '  '+unitTestCmd )
143    result=NBosCommand.run(unitTestCmd)
144 
145    if NBcheckResult.didTestFail(result,p,unitTestCmdTemplate) :
146      NBemail.sendCmdMsgs(p,result,unitTestCmd)
147      continue
148
149  # For testing purposes only do first successful project
150  #break
151
152
153NBlogMessages.writeMessage( "nightlyBuild.py Finished" )
154
155sys.exit(0)
156
157
158# START KIPP
159#----------------------------------------------------------------------
160# CONFIG FILE PATH:
161#   path to the config file for the build
162#   done. If the directory does not exist, it will be created.
163#   this should have all of the user specific data
164#   it should have values for
165#   NIGHTLY_BUILD_ROOT
166#   NBuserConfig.SMTP_SERVER_NAME
167#   NBuserConfig.SMTP_SERVER_PORT
168#   NBuserConfig.SMTP_SSL_SERVER
169#   NBuserConfig.SMTP_USER_NAME
170#   NBuserConfig.SMTP_PASSWORD_FILENAME = '/home/jp/bin/smtpPwFile'
171#   NBuserConfig.SENDER_EMAIL_ADDR='jpfasano _AT_ verizon _DOT_ net'
172#   NBuserConfig.MY_EMAIL_ADDR='jpfasano _AT_ us _DOT_ ibm _DOT_ com'
173#   
174#----------------------------------------------------------------------
175
176CONFIG_FILE_PATH = '/Users/kmartin/Documents/files/configDir/'
177CONFIG_FILENAME = 'config.txt'
178
179
180# Get configFile data
181
182configFile = os.path.join(os.path.dirname( CONFIG_FILE_PATH),
183                                 os.path.basename(CONFIG_FILENAME ))
184if os.path.isfile(  configFile) :
185  pwFilePtr = open(configFile ,'r')
186  d = pwFilePtr.readlines()
187  # do pwFilePtr.read() to get a string object
188  # we have a list object
189  print d[0]
190  print d[1]
191  # make a dictionary
192  config_dic = {}
193
194  #smtppass  = pwFilePtr.read().strip()
195  pwFilePtr.close()
196else :
197  #NBlogMessages.writeMessage( "Failure reading pwFileName=" + CONFIG_FILENAME )
198  #print cmdMsgs
199  sys.exit( 1)
200sys.exit( 0)
201
202
203
204# START KIPP
205#----------------------------------------------------------------------
206#   path to the config file for the build
207#   get the user dependent variables
208# CONFIG FILE PATH:
209#   it should have values for
210#   NIGHTLY_BUILD_ROOT
211#   NBuserConfig.SMTP_SERVER_NAME
212#   NBuserConfig.SMTP_SERVER_PORT
213#   NBuserConfig.SMTP_SSL_SERVER
214#   NBuserConfig.SMTP_USER_NAME
215#   NBuserConfig.SMTP_PASSWORD_FILENAME
216#   NBuserConfig.SENDER_EMAIL_ADDR
217#   NBuserConfig.MY_EMAIL_ADDR
218#   
219#----------------------------------------------------------------------
220
221CONFIG_FILE_PATH = '/Users/kmartin/Documents/files/configDir/'
222CONFIG_FILENAME = 'config.txt'
223
224
225# Get configFile data
226
227configFile = os.path.join(os.path.dirname( CONFIG_FILE_PATH),
228                                 os.path.basename(CONFIG_FILENAME ))
229if os.path.isfile(  configFile) :
230  pwFilePtr = open(configFile ,'r')
231  d = pwFilePtr.readlines()
232  # do pwFilePtr.read() to get a string object
233  # we have a list object
234  print d[0]
235  print d[1]
236  # make a dictionary
237  config_dic = {}
238
239  #smtppass  = pwFilePtr.read().strip()
240  pwFilePtr.close()
241else :
242  #NBlogMessages.writeMessage( "Failure reading pwFileName=" + CONFIG_FILENAME )
243  #print cmdMsgs
244  sys.exit( 1)
245sys.exit( 0)
246
247# END KIPP
Note: See TracBrowser for help on using the repository browser.