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

Side by Side Diff: editor/build/promote.py

Issue 26607003: Change promote script to be able to archive to the new gs://dart-archive/ location (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 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 | tools/bots/bot_utils.py » ('j') | 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 # 2 #
3 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 3 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
4 # for details. All rights reserved. Use of this source code is governed by a 4 # for details. All rights reserved. Use of this source code is governed by a
5 # BSD-style license that can be found in the LICENSE file. 5 # BSD-style license that can be found in the LICENSE file.
6 6
7 # Dart Editor promote and google storage cleanup tools. 7 # Dart Editor promote and google storage cleanup tools.
8 8
9 import gsutil 9 import gsutil
10 import imp
10 import optparse 11 import optparse
11 import os 12 import os
12 import subprocess 13 import subprocess
13 import sys 14 import sys
14 import urllib 15 import urllib
15 16
16 from os.path import join 17 from os.path import join
17 18
18 CONTINUOUS = 'gs://dart-editor-archive-continuous' 19 CONTINUOUS = 'gs://dart-editor-archive-continuous'
19 TRUNK = 'gs://dart-editor-archive-trunk' 20 TRUNK = 'gs://dart-editor-archive-trunk'
20 TESTING = 'gs://dart-editor-archive-testing' 21 TESTING = 'gs://dart-editor-archive-testing'
21 INTEGRATION = 'gs://dart-editor-archive-integration' 22 INTEGRATION = 'gs://dart-editor-archive-integration'
22 RELEASE = 'gs://dart-editor-archive-release' 23 RELEASE = 'gs://dart-editor-archive-release'
23 INTERNAL = 'gs://dart-editor-archive-internal' 24 INTERNAL = 'gs://dart-editor-archive-internal'
24 25
25 DART_PATH = os.path.join('..', '..', '..', 'dart') 26 DART_PATH = os.path.abspath(os.path.join(__file__, '..', '..', '..'))
27 BOT_UTILS = os.path.abspath(os.path.join(
28 DART_PATH, 'tools', 'bots', 'bot_utils.py'))
29
30 bot_utils = imp.load_source('bot_utils', BOT_UTILS)
26 31
27 def _BuildOptions(): 32 def _BuildOptions():
28 """Setup the argument processing for this program. 33 """Setup the argument processing for this program.
29 34
30 Returns: 35 Returns:
31 the OptionParser to process the CLI 36 the OptionParser to process the CLI
32 """ 37 """
33 usage = """usage: %prog [options] cleanup|promote 38 usage = """usage: %prog [options] cleanup|promote
34 where: 39 where:
35 cleanup will cleanup the Google storage continuous bucket 40 cleanup will cleanup the Google storage continuous bucket
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 action='store_true') 74 action='store_true')
70 group.add_option('--trunk', 75 group.add_option('--trunk',
71 help='Promote from trunk', 76 help='Promote from trunk',
72 action='store_true') 77 action='store_true')
73 group.add_option('--internal', 78 group.add_option('--internal',
74 help='Promote from trunk to internal', 79 help='Promote from trunk to internal',
75 action='store_true') 80 action='store_true')
76 group.add_option('--integration', 81 group.add_option('--integration',
77 help='Promote from integration', 82 help='Promote from integration',
78 action='store_true') 83 action='store_true')
84 group.add_option('--channel', type='string',
85 help='Promote from this channel',
86 default=None)
79 result.add_option_group(group) 87 result.add_option_group(group)
80 88
81 result.add_option('--gsbucketuri', 89 result.add_option('--gsbucketuri',
82 help='Dart Continuous Google Storage bucket URI.', 90 help='Dart Continuous Google Storage bucket URI.',
83 action='store') 91 action='store')
84 result.add_option('--gsutilloc', 92 result.add_option('--gsutilloc',
85 help='location of gsutil the program', 93 help='location of gsutil the program',
86 action='store') 94 action='store')
87 result.add_option('--dryrun', help='don\'t do anything that would change' 95 result.add_option('--dryrun', help='don\'t do anything that would change'
88 ' Google Storage', 96 ' Google Storage',
(...skipping 16 matching lines...) Expand all
105 parser.print_help() 113 parser.print_help()
106 sys.exit(1) 114 sys.exit(1)
107 115
108 if args[0] == 'promote': 116 if args[0] == 'promote':
109 command = 'promote' 117 command = 'promote'
110 if options.revision is None: 118 if options.revision is None:
111 print 'You must specify a --revision to specify which revision to promote' 119 print 'You must specify a --revision to specify which revision to promote'
112 parser.print_help() 120 parser.print_help()
113 sys.exit(3) 121 sys.exit(3)
114 if not (options.continuous or options.integration or 122 if not (options.continuous or options.integration or
115 options.testing or options.trunk or options.internal): 123 options.testing or options.trunk or options.internal or
116 print 'Specify --continuous, --integration, --testing, or --trunk' 124 options.channel):
125 print ('Specify --continuous, --integration, --testing, --trunk or '
126 '--channel=be/dev/stable')
117 parser.print_help() 127 parser.print_help()
118 sys.exit(4) 128 sys.exit(4)
119 if options.continuous and options.integration: 129 if options.continuous and options.integration:
120 print 'continuous and integration can not be specified at the same time' 130 print 'continuous and integration can not be specified at the same time'
121 parser.print_help() 131 parser.print_help()
122 sys.exit(5) 132 sys.exit(5)
123 if (options.continuous or options.integration) and options.testing: 133 if (options.continuous or options.integration) and options.testing:
124 print """Warning --continuous or --integration and --testing are 134 print """Warning --continuous or --integration and --testing are
125 specified. The --testing flag will take precedence and all data will 135 specified. The --testing flag will take precedence and all data will
126 go to the testing bucket {0}""".format(TESTING) 136 go to the testing bucket {0}""".format(TESTING)
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 if command == 'cleanup': 168 if command == 'cleanup':
159 #if the testing flag is set remove the date from the testing bucket 169 #if the testing flag is set remove the date from the testing bucket
160 if options.testing: 170 if options.testing:
161 bucket = TESTING 171 bucket = TESTING
162 #otherwise use the value passed as --gsbucketuri 172 #otherwise use the value passed as --gsbucketuri
163 else: 173 else:
164 bucket = options.gsbucketuri 174 bucket = options.gsbucketuri
165 version_dirs = _ReadBucket(gsu, '{0}/{1}'.format(bucket, '[0-9]*')) 175 version_dirs = _ReadBucket(gsu, '{0}/{1}'.format(bucket, '[0-9]*'))
166 _RemoveElements(gsu, bucket, version_dirs, options.keepcount) 176 _RemoveElements(gsu, bucket, version_dirs, options.keepcount)
167 elif command == 'promote': 177 elif command == 'promote':
168 _PromoteBuild(options.revision, bucket_from, bucket_to) 178 if options.channel:
169 _UpdateDocs() 179 _PromoteDartArchiveBuild(options.channel, options.revision)
180 else:
181 _PromoteBuild(options.revision, bucket_from, bucket_to)
182 _UpdateDocs()
170 183
171 184
172 def _UpdateDocs(): 185 def _UpdateDocs():
173 try: 186 try:
174 print 'Updating docs' 187 print 'Updating docs'
175 url = "http://api.dartlang.org/docs/releases/latest/?force_reload=true" 188 url = "http://api.dartlang.org/docs/releases/latest/?force_reload=true"
176 f = urllib.urlopen(url) 189 f = urllib.urlopen(url)
177 f.read() 190 f.read()
178 print 'Successfully updated api docs' 191 print 'Successfully updated api docs'
179 except Exception as e: 192 except Exception as e:
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 _Gsutil(['cp', '-r', '-a', 'public-read', src + '*', dest]) 274 _Gsutil(['cp', '-r', '-a', 'public-read', src + '*', dest])
262 275
263 # copy from continuous/1234 to trunk/latest 276 # copy from continuous/1234 to trunk/latest
264 dest = '%s/%s/' % (to_bucket, 'latest') 277 dest = '%s/%s/' % (to_bucket, 'latest')
265 destUpdate = dest + 'eclipse-update/' 278 destUpdate = dest + 'eclipse-update/'
266 print 'copying: %s -> %s' % (src, dest) 279 print 'copying: %s -> %s' % (src, dest)
267 _Gsutil(['cp', '-a', 'public-read', srcVersion, destUpdate + 'features/']) 280 _Gsutil(['cp', '-a', 'public-read', srcVersion, destUpdate + 'features/'])
268 _Gsutil(['cp', '-a', 'public-read', srcVersion, destUpdate + 'plugins/']) 281 _Gsutil(['cp', '-a', 'public-read', srcVersion, destUpdate + 'plugins/'])
269 _Gsutil(['cp', '-r', '-a', 'public-read', src + '*', dest]) 282 _Gsutil(['cp', '-r', '-a', 'public-read', src + '*', dest])
270 283
284 def _PromoteDartArchiveBuild(channel, revision):
285 # These namer objects will be used to create GCS object URIs. For the
286 # structure we use, please see tools/bots/bot_utils.py:GCSNamer
287 raw_namer = bot_utils.GCSNamer(channel, bot_utils.ReleaseType.RAW)
288 signed_namer = bot_utils.GCSNamer(channel, bot_utils.ReleaseType.SIGNED)
289 release_namer = bot_utils.GCSNamer(channel, bot_utils.ReleaseType.RELEASE)
290
291 def promote(to_revision):
292 # Copy VERSION file.
293 from_loc = raw_namer.version_filepath(revision)
294 to_loc = release_namer.version_filepath(to_revision)
295 _Gsutil(['cp', '-a', 'public-read', from_loc, to_loc])
296
297 # Copy sdk directory.
298 from_loc = raw_namer.sdk_directory(revision)
299 to_loc = release_namer.sdk_directory(to_revision)
300 _Gsutil(['-m', 'cp', '-a', 'public-read', '-R', from_loc, to_loc])
301
302 # Copy eclipse update directory.
303 from_loc = raw_namer.editor_eclipse_update_directory(revision)
304 to_loc = release_namer.editor_eclipse_update_directory(to_revision)
305 _Gsutil(['-m', 'cp', '-a', 'public-read', '-R', from_loc, to_loc])
306
307 # Copy api-docs directory.
308 from_loc = raw_namer.apidocs_directory(revision)
309 to_loc = release_namer.apidocs_directory(to_revision)
310 _Gsutil(['-m', 'cp', '-a', 'public-read', '-R', from_loc, to_loc])
311
312 # Copy dartium directory.
313 from_loc = raw_namer.dartium_directory(revision)
314 to_loc = release_namer.dartium_directory(to_revision)
315 _Gsutil(['-m', 'cp', '-a', 'public-read', '-R', from_loc, to_loc])
316
317 # Copy editor zip files.
318 for system in ['windows', 'macos', 'linux']:
319 for arch in ['ia32', 'x64']:
320 from_namer = raw_namer
321 # We have signed versions of the editor for windows and macos.
322 if system == 'windows' or system == 'macos':
323 from_namer = signed_namer
324 from_loc = from_namer.editor_zipfilepath(revision, system, arch)
325 to_loc = release_namer.editor_zipfilepath(to_revision, system, arch)
326 _Gsutil(['cp', '-a', 'public-read', from_loc, to_loc])
327 _Gsutil(['cp', '-a', 'public-read', from_loc + '.md5sum',
328 to_loc + '.md5sum'])
329
330 promote(revision)
331 promote('latest')
271 332
272 def _PrintSeparator(text): 333 def _PrintSeparator(text):
273 print '================================' 334 print '================================'
274 print '== %s' % text 335 print '== %s' % text
275 336
276 337
277 def _PrintFailure(text): 338 def _PrintFailure(text):
278 print '*****************************' 339 print '*****************************'
279 print '** %s' % text 340 print '** %s' % text
280 print '*****************************' 341 print '*****************************'
281 342
282 343
283 def _Gsutil(cmd): 344 def _Gsutil(cmd):
284 gsutilTool = join(DART_PATH, 'third_party', 'gsutil', 'gsutil') 345 gsutilTool = join(DART_PATH, 'third_party', 'gsutil', 'gsutil')
285 return _ExecuteCommand([sys.executable, gsutilTool] + cmd) 346 return _ExecuteCommand([sys.executable, gsutilTool] + cmd)
286 347
287 348
288 def _ExecuteCommand(cmd, directory=None): 349 def _ExecuteCommand(cmd, directory=None):
289 """Execute the given command.""" 350 """Execute the given command."""
290 if directory is not None: 351 if directory is not None:
291 cwd = os.getcwd() 352 cwd = os.getcwd()
292 os.chdir(directory) 353 os.chdir(directory)
293 subprocess.call(cmd, env=os.environ) 354 subprocess.call(cmd, env=os.environ)
294 if directory is not None: 355 if directory is not None:
295 os.chdir(cwd) 356 os.chdir(cwd)
296 357
297 358
298 if __name__ == '__main__': 359 if __name__ == '__main__':
299 sys.exit(main()) 360 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | tools/bots/bot_utils.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698