Skip to content

Commit

Permalink
[infra] Add handling of signed SDK directories to promote.py
Browse files Browse the repository at this point in the history
Copy the signed SDK directory to release first (if it exists). Then copy
only those unsigned files that have no signed counterparts.

* Add --version alias and remove SVN reference from --revision help.
* Fix --dry-run.
* Add new base_directory to GCS namer.

b/139027087

Change-Id: I4163eb56494bfa92ab1e5686cf089136d63881fe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/115860
Reviewed-by: William Hesse <whesse@google.com>
  • Loading branch information
athomas committed Sep 9, 2019
1 parent ff0fda7 commit e9c3eeb
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 11 deletions.
7 changes: 5 additions & 2 deletions tools/bots/bot_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ def apidocs_zipfilepath(self, revision):

# Functions for querying gs:// directories

def base_directory(self, revision):
return '%s/channels/%s/%s/%s' % (self.bucket, self.channel,
self.release_type, revision)

def sdk_directory(self, revision):
return self._variant_directory('sdk', revision)

Expand All @@ -164,8 +168,7 @@ def misc_directory(self, revision):
return self._variant_directory('misc', revision)

def _variant_directory(self, name, revision):
return '%s/channels/%s/%s/%s/%s' % (self.bucket, self.channel,
self.release_type, revision, name)
return '%s/%s' % (self.base_directory(revision), name)

# Functions for quering filenames

Expand Down
33 changes: 24 additions & 9 deletions tools/promote.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# for details. All rights reserved. Use of this source code is governed by a
# BSD-style license that can be found in the LICENSE file.

# Dart Editor promote tools.
# Dart SDK promote tools.

import imp
import optparse
Expand All @@ -27,18 +27,24 @@ def BuildOptions():
promote - Will promote builds from raw/signed locations to release
locations.
Example: Promote revision r29962 on dev channel:
python editor/build/promote.py promote --channel=dev --revision=29962
Example: Promote version 2.5.0 on the stable channel:
python editor/build/promote.py promote --channel=stable --version=2.5.0
"""

result = optparse.OptionParser(usage=usage)

group = optparse.OptionGroup(result, 'Promote',
'options used to promote code')
group.add_option(
'--revision', help='The svn revision to promote', action='store')
'--revision',
'--version',
help='The version to promote',
action='store')
group.add_option(
'--channel', type='string', help='Channel to promote.', default=None)
'--channel',
type='string',
help='The channel to promote.',
default=None)
group.add_option(
"--dry", help='Dry run', default=False, action="store_true")
result.add_option_group(group)
Expand Down Expand Up @@ -131,11 +137,20 @@ def remove_gs_directory(gs_path):
Gsutil(['-m', 'rm', '-R', '-f', gs_path])
wait_for_delete_to_be_consistent_with_list(gs_path)

# Copy sdk directory.
from_loc = raw_namer.sdk_directory(revision)
# Copy the signed sdk directory.
from_loc = signed_namer.sdk_directory(revision)
to_loc = release_namer.sdk_directory(to_revision)
remove_gs_directory(to_loc)
Gsutil(['-m', 'cp', '-a', 'public-read', '-R', from_loc, to_loc])
has_signed = exists(from_loc)
if has_signed:
Gsutil(['-m', 'cp', '-a', 'public-read', '-R', from_loc, to_loc])
# Because gsutil copies differently to existing directories, we need
# to use the base directory for the next recursive copy.
to_loc = release_namer.base_directory(to_revision)

# Copy the unsigned sdk directory without clobbering signed files.
from_loc = raw_namer.sdk_directory(revision)
Gsutil(['-m', 'cp', '-n', '-a', 'public-read', '-R', from_loc, to_loc])

# Copy api-docs zipfile.
from_loc = raw_namer.apidocs_zipfilepath(revision)
Expand All @@ -162,7 +177,7 @@ def Gsutil(cmd, throw_on_error=True):
command = [sys.executable, gsutilTool] + cmd
if DRY_RUN:
print "DRY runnning: %s" % command
return
return (None, None, 0)
return bot_utils.run(command, throw_on_error=throw_on_error)


Expand Down

0 comments on commit e9c3eeb

Please sign in to comment.