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

Side by Side Diff: tools/bots/dart_sdk.py

Issue 1138703003: Add an annotated steps for driving our sdk and api archiving. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 7 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 | « client/tools/buildbot_annotated_steps.py ('k') | tools/create_editor.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 #
3 # Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
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.
6
7 import os.path
8 import shutil
9 import sys
10
11 import bot
12 import bot_utils
13
14 utils = bot_utils.GetUtils()
15
16 BUILD_OS = utils.GuessOS()
17
18 (bot_name, _) = bot.GetBotName()
19 CHANNEL = bot_utils.GetChannelFromName(bot_name)
20
21 def BuildSDK():
22 with bot.BuildStep('Build SDK'):
23 Run([sys.executable, './tools/build.py', '--mode=release',
24 '--arch=ia32,x64', 'create_sdk'])
25
26 def BuildAPIDocs():
27 with bot.BuildStep('Build API docs'):
28 Run([sys.executable, './tools/build.py', '--mode=release',
29 '--arch=ia32', 'api_docs'])
30 Run([sys.executable, './tools/build.py', '--mode=release',
ricow1 2015/05/11 13:06:47 I don't know why we need this, but it was in the o
31 '--arch=ia32', 'dartdocgen'])
32
33 def CreateUploadSDKZips():
34 with bot.BuildStep('Create and upload sdk zips'):
35 sdk32_path = os.path.join(bot_utils.DART_DIR,
36 utils.GetBuildRoot(BUILD_OS, 'release', 'ia32'),
37 'dart-sdk')
38 sdk64_path = os.path.join(bot_utils.DART_DIR,
39 utils.GetBuildRoot(BUILD_OS, 'release', 'x64'),
40 'dart-sdk')
41
42 sdk32_zip = os.path.join(bot_utils.DART_DIR,
43 utils.GetBuildRoot(BUILD_OS, 'release', 'ia32'),
44 'dartsdk-%s-32.zip' % BUILD_OS)
45 sdk64_zip = os.path.join(bot_utils.DART_DIR,
46 utils.GetBuildRoot(BUILD_OS, 'release', 'x64'),
47 'dartsdk-%s-64.zip' % BUILD_OS)
48 FileDelete(sdk32_zip)
49 FileDelete(sdk64_zip)
50 CreateZip(sdk32_path, sdk32_zip)
51 CreateZip(sdk64_path, sdk64_zip)
52 DartArchiveUploadSDKs(BUILD_OS, sdk32_zip, sdk64_zip)
53
54 def DartArchiveUploadSDKs(system, sdk32_zip, sdk64_zip):
55 namer = bot_utils.GCSNamer(CHANNEL, bot_utils.ReleaseType.RAW)
56 revision = utils.GetSVNRevision()
57 for revision in [revision, 'latest']:
58 path32 = namer.sdk_zipfilepath(revision, system, 'ia32', 'release')
59 path64 = namer.sdk_zipfilepath(revision, system, 'x64', 'release')
60 DartArchiveFile(sdk32_zip, path32, checksum_files=True)
61 DartArchiveFile(sdk64_zip, path64, checksum_files=True)
62
63 def CreateUploadSDK():
64 BuildSDK()
65 CreateUploadSDKZips()
66
67 def CreateUploadAPIDocs():
68 api_path = os.path.join(bot_utils.DART_DIR,
69 utils.GetBuildRoot(BUILD_OS, 'release', 'ia32'),
70 'api_docs')
71 api_zip = os.path.join(bot_utils.DART_DIR,
72 utils.GetBuildRoot(BUILD_OS, 'release', 'ia32'),
73 'dart-api-docs.zip')
74 shutil.rmtree(api_path, ignore_errors=True)
75 FileDelete(api_zip)
76 BuildAPIDocs()
77 UploadApiDocs(api_path)
78 CreateZip(api_path, api_zip)
79 DartArchiveUploadAPIDocs(api_zip)
80
81 def DartArchiveUploadAPIDocs(api_zip):
82 namer = bot_utils.GCSNamer(CHANNEL, bot_utils.ReleaseType.RAW)
83 revision = utils.GetSVNRevision()
84 for revision in [revision, 'latest']:
85 destination = (namer.apidocs_directory(revision) + '/' +
86 namer.apidocs_zipfilename())
87 DartArchiveFile(api_zip, destination, checksum_files=False)
88
89 def UploadApiDocs(dir_name):
90 apidocs_namer = bot_utils.GCSNamerApiDocs(CHANNEL)
91 revision = utils.GetSVNRevision()
92 apidocs_destination_gcsdir = apidocs_namer.docs_dirpath(revision)
93 apidocs_destination_latestfile = apidocs_namer.docs_latestpath(revision)
94
95 # Return early if the documents have already been uploaded.
96 # (This can happen if a build was forced, or a commit had no changes in the
97 # dart repository (e.g. DEPS file update).)
98 if GsutilExists(apidocs_destination_gcsdir):
99 print ("Not uploading api docs, since %s is already present."
100 % apidocs_destination_gcsdir)
101 return
102
103 # Upload everything inside the built apidocs directory.
104 gsutil = bot_utils.GSUtil()
105 gsutil.upload(dir_name, apidocs_destination_gcsdir, recursive=True,
106 public=True)
107
108 # Update latest.txt to contain the newest revision.
109 with utils.TempDir('latest_file') as temp_dir:
110 latest_file = join(temp_dir, 'latest.txt')
111 with open(latest_file, 'w') as f:
112 f.write('%s' % revision)
113 DartArchiveFile(latest_file, apidocs_destination_latestfile)
114
115 def GsutilExists(gsu_path):
116 # This is a little hackish, but it is basically a one off doing very
117 # specialized check that we don't use elsewhere.
118 gsutilTool = os.path.join(bot_utils.DART_DIR,
119 'third_party', 'gsutil', 'gsutil')
120 (_, stderr, returncode) = bot_utils.run(
121 [gsutilTool, 'ls', gsu_path],
122 throw_on_error=False)
123 # If the returncode is nonzero and we can find a specific error message,
124 # we know there are no objects with a prefix of [gsu_path].
125 missing = (returncode and 'CommandException: No such object' in stderr)
126 # Either the returncode has to be zero or the object must be missing,
127 # otherwise throw an exception.
128 if not missing and returncode:
129 raise Exception("Failed to determine whether %s exists" % gsu_path)
130 return not missing
131
132
133 def CreateZip(directory, target_file):
134 if 'win' in BUILD_OS:
135 CreateZipWindows(directory, target_file)
136 else:
137 CreateZipPosix(directory, target_file)
138
139 def CreateZipPosix(directory, target_file):
140 with utils.ChangedWorkingDirectory(os.path.dirname(directory)):
141 command = ['zip', '-yrq9', target_file, os.path.basename(directory)]
142 Run(command)
143
144 def CreateZipWindows(directory, target_file):
145 with utils.ChangedWorkingDirectory(os.path.dirname(directory)):
146 zip_win = os.path.join(bot_utils.DART_DIR, 'third_party', '7zip', '7za')
147 command = [zip_win, 'a', '-tzip', target_file, os.path.basename(directory)]
148 Run(command)
149
150 def FileDelete(f):
151 if os.path.exists(f):
152 os.remove(f)
153
154 def DartArchiveFile(local_path, remote_path, checksum_files=False):
155 gsutil = bot_utils.GSUtil()
156 gsutil.upload(local_path, remote_path, public=True)
157 if checksum_files:
158 # 'local_path' may have a different filename than 'remote_path'. So we need
159 # to make sure the *.md5sum file contains the correct name.
160 assert '/' in remote_path and not remote_path.endswith('/')
161
162 mangled_filename = remote_path[remote_path.rfind('/') + 1:]
163 local_md5sum = bot_utils.CreateMD5ChecksumFile(local_path,
164 mangled_filename)
165 gsutil.upload(local_md5sum, remote_path + '.md5sum', public=True)
166 local_sha256 = bot_utils.CreateSha256ChecksumFile(local_path,
167 mangled_filename)
168 gsutil.upload(local_sha256, remote_path + '.sha256sum', public=True)
169
170 def Run(command):
171 print "Running %s" % ' '.join(command)
172 return bot.RunProcess(command)
173
174 if __name__ == '__main__':
175 CreateUploadSDK()
176 CreateUploadAPIDocs()
OLDNEW
« no previous file with comments | « client/tools/buildbot_annotated_steps.py ('k') | tools/create_editor.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698