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

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

Issue 261283002: Add annotated steps script for validating that the version on dev and stable is always increasing w… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 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 | « tools/bots/bot_utils.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
Added: svn:executable
+ *
OLDNEW
(Empty)
1 #!/usr/bin/python
2
3 # Copyright (c) 2014, 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 json
8 import re
9 import sys
10
11 import bot
12 import bot_utils
13
14 utils = bot_utils.GetUtils()
15
16 VERSION_BUILDER = r'version-checker'
17
18 def VersionConfig(name, is_buildbot):
19 version_pattern = re.match(VERSION_BUILDER, name)
20 if not version_pattern:
21 return None
22 # We don't really use this, but we create it anyway to use the standard
23 # bot execution model.
24 return bot.BuildInfo('none', 'none', 'release', 'linux')
25
26 def GetLatestVersionFromGCS(channel):
27 namer = bot_utils.GCSNamer(channel=channel)
28 gsutil = bot_utils.GSUtil()
29 gcs_version_path = namer.version_filepath('latest')
30 print 'Getting latest version from: %s' % gcs_version_path
31 version_json = gsutil.cat(gcs_version_path)
32 version_map = json.loads(version_json)
33 return version_map['version']
34
35 def ValidateChannelVersion(latest_version, channel):
36 repo_version = utils.ReadVersionFile()
37 assert repo_version.channel == channel
38 if channel == bot_utils.Channel.STABLE:
39 assert int(repo_version.prerelease) == 0
40 assert int(repo_version.prerelease_patch) == 0
41
42 version_re = r'(\d+)\.(\d+)\.(\d+)(-dev\.(\d+)\.(\d+))?'
43
44 latest_match = re.match(version_re, latest_version)
45 latest_major = int(latest_match.group(1))
46 latest_minor = int(latest_match.group(2))
47 latest_patch = int(latest_match.group(3))
48 # We don't use these on stable.
49 latest_prerelease = int(latest_match.group(5) or 0)
50 latest_prerelease_patch = int(latest_match.group(6) or 0)
51
52 if latest_major < int(repo_version.major):
53 return True
54 if latest_minor < int(repo_version.minor):
55 return True
56 if latest_patch < int(repo_version.patch):
57 return True
58 if latest_prerelease < int(repo_version.prerelease):
59 return True
60 if latest_prerelease_patch < int(repo_version.prerelease_patch):
61 return True
62 return False
63
64 def VersionSteps(build_info):
65 with bot.BuildStep('Version file sanity checking'):
66 bot_name, _ = bot.GetBotName()
67 channel = bot_utils.GetChannelFromName(bot_name)
68 if channel == bot_utils.Channel.BLEEDING_EDGE:
69 print 'No sanity checking on bleeding edge'
70 else:
71 assert (channel == bot_utils.Channel.STABLE or
72 channel == bot_utils.Channel.DEV)
73 latest_version = GetLatestVersionFromGCS(channel)
74 version = utils.GetVersion()
75 print 'Latests version on GCS: %s' % latest_version
76 print 'Version currently building: %s' % version
77 if not ValidateChannelVersion(latest_version, channel):
78 print "Validation failed"
79 sys.exit(1)
80 if latest_version == version:
81 print 'Version file has not been updated'
82 sys.exit(1)
83 else:
84 print 'Version file changed, sanity checks passed'
85
86 if __name__ == '__main__':
87 # We pass in None for build_step to avoid building.
88 bot.RunBot(VersionConfig, VersionSteps, build_step=None)
OLDNEW
« no previous file with comments | « tools/bots/bot_utils.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698