Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(82)

Side by Side Diff: visual_studio/NativeClientVSAddIn/buildbot_run.py

Issue 124123002: Fix buildbot upload of vs_addin archive. (Closed) Base URL: https://nativeclient-sdk.googlecode.com/svn/trunk/src
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Entry point for the AddIn build bot. 6 """Entry point for the AddIn build bot.
7 7
8 Perform build steps and output results using the buildbot 8 Perform build steps and output results using the buildbot
9 annootator syntax 9 annootator syntax
10 """ 10 """
(...skipping 10 matching lines...) Expand all
21 GSPATH = 'nativeclient-mirror/nacl/nacl_sdk/sdk' 21 GSPATH = 'nativeclient-mirror/nacl/nacl_sdk/sdk'
22 SDKROOT = os.path.join('..', '..', 'out', 'sdk') 22 SDKROOT = os.path.join('..', '..', 'out', 'sdk')
23 SDK_VERSIONS = ['pepper_31', 'pepper_32', 'pepper_canary'] 23 SDK_VERSIONS = ['pepper_31', 'pepper_32', 'pepper_canary']
24 24
25 25
26 def Log(msg): 26 def Log(msg):
27 sys.stdout.write(msg + '\n') 27 sys.stdout.write(msg + '\n')
28 sys.stdout.flush() 28 sys.stdout.flush()
29 29
30 30
31 def RunCommand(cmd, env=None): 31 def RunCommand(cmd, env=None, check_return_code=True):
32 Log("Running: %s" % cmd) 32 Log("Running: %s" % cmd)
33 Log("CWD: %s" % os.getcwd()) 33 Log("CWD: %s" % os.getcwd())
34 if type(cmd) == str: 34 if type(cmd) == str:
35 cmd = cmd.split() 35 cmd = cmd.split()
36 36
37 if sys.platform == 'cygwin': 37 if sys.platform == 'cygwin':
38 # allow bat files in the current working directory to 38 # allow bat files in the current working directory to
39 # be executed on cygwin as they are on win32 39 # be executed on cygwin as they are on win32
40 if not os.path.dirname(cmd[0]) and os.path.exists(cmd[0]): 40 if not os.path.dirname(cmd[0]) and os.path.exists(cmd[0]):
41 cmd[0] = './' + cmd[0] 41 cmd[0] = './' + cmd[0]
42 42
43 rtn = subprocess.call(cmd, env=env) 43 rtn = subprocess.call(cmd, env=env)
44 if rtn: 44 if check_return_code and rtn:
45 Log("Command returned non-zero exit code: %s" % rtn) 45 Log("Command returned non-zero exit code: %s" % rtn)
46 Log('@@@STEP_FAILURE@@@') 46 Log('@@@STEP_FAILURE@@@')
47 sys.exit(1) 47 sys.exit(1)
48 48
49 return rtn
49 50
50 def StepBuild(): 51
52 def StepBuild(revision):
51 Log('@@@BUILD_STEP build addin@@@') 53 Log('@@@BUILD_STEP build addin@@@')
52 54
53 rev = os.environ.get('BUILDBOT_GOT_REVISION') 55 if revision[0] == 'r':
54 if not rev: 56 revision = revision[1:]
55 Log('No BUILDBOT_GOT_REVISION found in environ')
56 Log('@@@STEP_FAILURE@@@')
57 sys.exit(1)
58
59 if rev[0] == 'r':
60 rev = rev[1:]
61 57
62 # make a backup of AssemblyInfo.cs before we modify it 58 # make a backup of AssemblyInfo.cs before we modify it
63 filename = os.path.join('NativeClientVSAddIn', 'AssemblyInfo.cs') 59 filename = os.path.join('NativeClientVSAddIn', 'AssemblyInfo.cs')
64 backup = filename + '.orig' 60 backup = filename + '.orig'
65 shutil.copyfile(filename, backup) 61 shutil.copyfile(filename, backup)
66 62
67 try: 63 try:
68 # Before we do the build, insert the revsion information 64 # Before we do the build, insert the revsion information
69 # info AssemblyInfo.cs. Thie will then be reported as 65 # info AssemblyInfo.cs. Thie will then be reported as
70 # the addin version in visual studio. 66 # the addin version in visual studio.
71 with open(filename, 'rb') as f: 67 with open(filename, 'rb') as f:
72 contents = f.read() 68 contents = f.read()
73 69
74 pattern = r'(\[assembly: AssemblyInformationalVersion\("\d+\.\d+\.).*"\)\]' 70 pattern = r'(\[assembly: AssemblyInformationalVersion\("\d+\.\d+\.).*"\)\]'
75 contents = re.sub(pattern, r'\g<1>%s")]' % rev, contents) 71 contents = re.sub(pattern, r'\g<1>%s")]' % revision, contents)
76 72
77 with open(filename, 'wb') as f: 73 with open(filename, 'wb') as f:
78 f.write(contents) 74 f.write(contents)
79 75
80 RunCommand('build.bat') 76 RunCommand('build.bat')
81 finally: 77 finally:
82 # Once build is done restore original file 78 # Once build is done restore original file
83 os.remove(filename) 79 os.remove(filename)
84 os.rename(backup, filename) 80 os.rename(backup, filename)
85 81
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 gsutil = [gsutil] 151 gsutil = [gsutil]
156 else: 152 else:
157 if os.name == 'nt': 153 if os.name == 'nt':
158 gsutil = [sys.executable, _FindInPath('gsutil')] 154 gsutil = [sys.executable, _FindInPath('gsutil')]
159 else: 155 else:
160 gsutil = ['gsutil'] 156 gsutil = ['gsutil']
161 157
162 return gsutil 158 return gsutil
163 159
164 160
165 def StepArchive(): 161 def StepArchive(revision):
166 rev = os.environ.get('BUILDBOT_GOT_REVISION') 162 # The BUILDBOT_REVISION environment variable gets set to the revsion that
167 if not rev: 163 # triggered a given build. For periodic schedulers this will be an empty
168 Log('No BUILDBOT_GOT_REVISION found in environ') 164 # string since they are not triggered by a particular revision. We don't
165 # want to upload the build results to google storage for periodic schedulers
166 # so we skip this step in that case.
167 triggered_revision = os.environ.get('BUILDBOT_REVISION')
168 if triggered_revision == '' or triggered_revision is None:
169 Log('Skipping archive step: BUILDBOT_REVISION not set')
170 return
171
172 Log('@@@BUILD_STEP archive build [r%s]@@@' % revision)
173 basename = 'vs_addin.tgz'
174 remote_name = '%s/%s/%s' % (GSPATH, revision, basename)
175 local_filename = os.path.join('..', '..', 'out',
176 'vs_addin', basename)
177 gs_remote_name = 'gs://' + remote_name
178 gsutil = _GetGsutil()
179
180 # Check for existing file on google storage
181 if RunCommand(gsutil + ['ls', gs_remote_name], check_return_code=False) == 0:
182 Log('File already exists on google storage: %s' % gs_remote_name)
169 Log('@@@STEP_FAILURE@@@') 183 Log('@@@STEP_FAILURE@@@')
170 sys.exit(1) 184 sys.exit(1)
171 Log('@@@BUILD_STEP archive build [r%s]@@@' % rev) 185
172 basename = 'vs_addin.tgz' 186 # Upload to google storage
173 remote_name = '%s/%s/%s' % (GSPATH, rev, basename) 187 cmd = gsutil + ['cp', '-a', 'public-read', local_filename, gs_remote_name]
174 local_filename = os.path.join('..', '..', 'out',
175 'vs_addin', basename)
176 cmd = _GetGsutil()
177 cmd += ['cp', '-a', 'public-read', local_filename,
178 'gs://' + remote_name]
179 RunCommand(cmd) 188 RunCommand(cmd)
180 url = "%s/%s" % (GSURL, remote_name) 189 url = "%s/%s" % (GSURL, remote_name)
181 Log('@@@STEP_LINK@download@%s@@@' % url) 190 Log('@@@STEP_LINK@download@%s@@@' % url)
182 191
183 192
184 def main(): 193 def main():
185 # Remove BOTO_CONFIG from the environment -- we want to use the NaCl .boto 194 # Remove BOTO_CONFIG from the environment -- we want to use the NaCl .boto
186 # file that has access to gs://nativeclient-mirror. 195 # file that has access to gs://nativeclient-mirror.
187 if 'BOTO_CONFIG' in os.environ: 196 if 'BOTO_CONFIG' in os.environ:
188 del os.environ['BOTO_CONFIG'] 197 del os.environ['BOTO_CONFIG']
189 if 'AWS_CREDENTIAL_FILE' in os.environ: 198 if 'AWS_CREDENTIAL_FILE' in os.environ:
190 del os.environ['AWS_CREDENTIAL_FILE'] 199 del os.environ['AWS_CREDENTIAL_FILE']
191 StepBuild() 200
201 revision = os.environ.get('BUILDBOT_GOT_REVISION')
202 if revision is None:
203 Log('No BUILDBOT_GOT_REVISION found in environ')
204 Log('@@@STEP_FAILURE@@@')
205 sys.exit(1)
206
207 StepBuild(revision)
192 StepInstall() 208 StepInstall()
193 StepInstallSDK() 209 StepInstallSDK()
194 StepTest() 210 StepTest()
195 StepArchive() 211 StepArchive(revision)
196 212
197 213
198 if __name__ == '__main__': 214 if __name__ == '__main__':
199 main() 215 main()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698