Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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 Loading... | |
| 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 Loading... | |
| 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): | |
|
ricow1
2013/10/14 15:39:38
I think it would be really beneficial to actually
kustermann
2013/10/15 08:01:18
Then it should obviously be in bot_utils.py. (Othe
| |
| 285 raw_namer = bot_utils.GCSNamer(channel, bot_utils.ReleaseType.RAW) | |
| 286 signed_namer = bot_utils.GCSNamer(channel, bot_utils.ReleaseType.SIGNED) | |
| 287 release_namer = bot_utils.GCSNamer(channel, bot_utils.ReleaseType.RELEASE) | |
| 288 | |
| 289 def promote(to_revision): | |
| 290 # Copy VERSION file. | |
| 291 from_loc = raw_namer.version_filepath(revision) | |
| 292 to_loc = release_namer.version_filepath(to_revision) | |
| 293 _Gsutil(['cp', '-a', 'public-read', from_loc, to_loc]) | |
| 294 | |
| 295 # Copy sdk directory. | |
| 296 from_loc = raw_namer.sdk_directory(revision) | |
| 297 to_loc = release_namer.sdk_directory(to_revision) | |
| 298 _Gsutil(['-m', 'cp', '-a', 'public-read', '-R', from_loc, to_loc]) | |
| 299 | |
| 300 # Copy eclipse update directory. | |
| 301 from_loc = raw_namer.editor_eclipse_update_directory(revision) | |
| 302 to_loc = release_namer.editor_eclipse_update_directory(to_revision) | |
| 303 _Gsutil(['-m', 'cp', '-a', 'public-read', '-R', from_loc, to_loc]) | |
| 304 | |
| 305 # Copy api-docs directory. | |
| 306 from_loc = raw_namer.apidocs_directory(revision) | |
| 307 to_loc = release_namer.apidocs_directory(to_revision) | |
| 308 _Gsutil(['-m', 'cp', '-a', 'public-read', '-R', from_loc, to_loc]) | |
| 309 | |
| 310 # Copy dartium directory. | |
| 311 from_loc = raw_namer.dartium_directory(revision) | |
| 312 to_loc = release_namer.dartium_directory(to_revision) | |
| 313 _Gsutil(['-m', 'cp', '-a', 'public-read', '-R', from_loc, to_loc]) | |
| 314 | |
| 315 # Copy editor zip files. | |
| 316 for system in ['windows', 'macos', 'linux']: | |
| 317 for arch in ['ia32', 'x64']: | |
| 318 from_namer = raw_namer | |
| 319 # We have signed versions of the editor for windows and macos. | |
| 320 if system == 'windows' or system == 'macos': | |
| 321 from_namer = signed_namer | |
| 322 from_loc = from_namer.editor_zipfilepath(revision, system, arch) | |
| 323 to_loc = release_namer.editor_zipfilepath(to_revision, system, arch) | |
| 324 _Gsutil(['cp', '-a', 'public-read', from_loc, to_loc]) | |
| 325 _Gsutil(['cp', '-a', 'public-read', from_loc + '.md5sum', | |
| 326 to_loc + '.md5sum']) | |
| 327 | |
| 328 promote(revision) | |
| 329 promote('latest') | |
| 271 | 330 |
| 272 def _PrintSeparator(text): | 331 def _PrintSeparator(text): |
| 273 print '================================' | 332 print '================================' |
| 274 print '== %s' % text | 333 print '== %s' % text |
| 275 | 334 |
| 276 | 335 |
| 277 def _PrintFailure(text): | 336 def _PrintFailure(text): |
| 278 print '*****************************' | 337 print '*****************************' |
| 279 print '** %s' % text | 338 print '** %s' % text |
| 280 print '*****************************' | 339 print '*****************************' |
| 281 | 340 |
| 282 | 341 |
| 283 def _Gsutil(cmd): | 342 def _Gsutil(cmd): |
| 284 gsutilTool = join(DART_PATH, 'third_party', 'gsutil', 'gsutil') | 343 gsutilTool = join(DART_PATH, 'third_party', 'gsutil', 'gsutil') |
| 285 return _ExecuteCommand([sys.executable, gsutilTool] + cmd) | 344 return _ExecuteCommand([sys.executable, gsutilTool] + cmd) |
| 286 | 345 |
| 287 | 346 |
| 288 def _ExecuteCommand(cmd, directory=None): | 347 def _ExecuteCommand(cmd, directory=None): |
| 289 """Execute the given command.""" | 348 """Execute the given command.""" |
| 290 if directory is not None: | 349 if directory is not None: |
| 291 cwd = os.getcwd() | 350 cwd = os.getcwd() |
| 292 os.chdir(directory) | 351 os.chdir(directory) |
| 293 subprocess.call(cmd, env=os.environ) | 352 subprocess.call(cmd, env=os.environ) |
| 294 if directory is not None: | 353 if directory is not None: |
| 295 os.chdir(cwd) | 354 os.chdir(cwd) |
| 296 | 355 |
| 297 | 356 |
| 298 if __name__ == '__main__': | 357 if __name__ == '__main__': |
| 299 sys.exit(main()) | 358 sys.exit(main()) |
| OLD | NEW |