2013-11-18 14:10:47 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# Copyright 2013 the V8 project authors. All rights reserved.
|
|
|
|
# Redistribution and use in source and binary forms, with or without
|
|
|
|
# modification, are permitted provided that the following conditions are
|
|
|
|
# met:
|
|
|
|
#
|
|
|
|
# * Redistributions of source code must retain the above copyright
|
|
|
|
# notice, this list of conditions and the following disclaimer.
|
|
|
|
# * Redistributions in binary form must reproduce the above
|
|
|
|
# copyright notice, this list of conditions and the following
|
|
|
|
# disclaimer in the documentation and/or other materials provided
|
|
|
|
# with the distribution.
|
|
|
|
# * Neither the name of Google Inc. nor the names of its
|
|
|
|
# contributors may be used to endorse or promote products derived
|
|
|
|
# from this software without specific prior written permission.
|
|
|
|
#
|
|
|
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
2014-02-26 15:13:31 +00:00
|
|
|
import argparse
|
2014-01-07 15:23:48 +00:00
|
|
|
import json
|
|
|
|
import os
|
2013-11-18 14:10:47 +00:00
|
|
|
import re
|
|
|
|
import sys
|
2014-01-15 15:55:23 +00:00
|
|
|
import urllib
|
2013-11-18 14:10:47 +00:00
|
|
|
|
|
|
|
from common_includes import *
|
2015-02-24 13:03:53 +00:00
|
|
|
import create_release
|
2013-11-18 14:10:47 +00:00
|
|
|
|
2014-03-21 15:04:54 +00:00
|
|
|
|
2013-11-18 14:10:47 +00:00
|
|
|
class Preparation(Step):
|
2013-11-22 09:48:43 +00:00
|
|
|
MESSAGE = "Preparation."
|
2013-11-18 14:10:47 +00:00
|
|
|
|
|
|
|
def RunStep(self):
|
2015-02-27 22:23:25 +00:00
|
|
|
# Fetch unfetched revisions.
|
|
|
|
self.vc.Fetch()
|
2013-11-18 14:10:47 +00:00
|
|
|
|
|
|
|
|
2014-11-26 15:23:35 +00:00
|
|
|
class FetchCandidate(Step):
|
2015-01-28 10:08:53 +00:00
|
|
|
MESSAGE = "Fetching V8 roll ref."
|
2013-11-18 14:10:47 +00:00
|
|
|
|
|
|
|
def RunStep(self):
|
2015-01-28 10:08:53 +00:00
|
|
|
# The roll ref points to the candidate to be rolled.
|
|
|
|
self.Git("fetch origin +refs/heads/roll:refs/heads/roll")
|
|
|
|
self["candidate"] = self.Git("show-ref -s refs/heads/roll").strip()
|
2013-11-18 14:10:47 +00:00
|
|
|
|
|
|
|
|
2015-01-28 10:08:53 +00:00
|
|
|
class LastReleaseBailout(Step):
|
|
|
|
MESSAGE = "Checking last V8 release base."
|
2013-12-11 15:27:38 +00:00
|
|
|
|
|
|
|
def RunStep(self):
|
2015-01-28 10:08:53 +00:00
|
|
|
last_release = self.GetLatestReleaseBase()
|
|
|
|
commits = self.GitLog(
|
|
|
|
format="%H", git_hash="%s..%s" % (last_release, self["candidate"]))
|
2014-03-21 15:04:54 +00:00
|
|
|
|
2015-01-28 10:08:53 +00:00
|
|
|
if not commits:
|
|
|
|
print "Already pushed current candidate %s" % self["candidate"]
|
2014-10-31 13:14:58 +00:00
|
|
|
return True
|
2013-11-18 14:10:47 +00:00
|
|
|
|
|
|
|
|
2015-02-24 13:03:53 +00:00
|
|
|
class CreateRelease(Step):
|
|
|
|
MESSAGE = "Creating release if specified."
|
2013-11-18 14:10:47 +00:00
|
|
|
|
|
|
|
def RunStep(self):
|
2015-02-24 13:03:53 +00:00
|
|
|
print "Creating release for %s." % self["candidate"]
|
2014-03-21 15:04:54 +00:00
|
|
|
|
2014-11-01 21:53:13 +00:00
|
|
|
args = [
|
|
|
|
"--author", self._options.author,
|
|
|
|
"--reviewer", self._options.reviewer,
|
2014-11-26 15:23:35 +00:00
|
|
|
"--revision", self["candidate"],
|
2014-11-01 21:53:13 +00:00
|
|
|
"--force",
|
|
|
|
]
|
|
|
|
|
2014-11-03 09:31:13 +00:00
|
|
|
if self._options.work_dir:
|
|
|
|
args.extend(["--work-dir", self._options.work_dir])
|
2014-11-01 21:53:13 +00:00
|
|
|
|
2014-03-24 15:52:31 +00:00
|
|
|
if self._options.push:
|
2015-01-26 13:29:23 +00:00
|
|
|
self._side_effect_handler.Call(
|
2015-02-24 13:03:53 +00:00
|
|
|
create_release.CreateRelease().Run, args)
|
2014-03-24 15:52:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
class AutoPush(ScriptsBase):
|
2014-03-04 23:27:27 +00:00
|
|
|
def _PrepareOptions(self, parser):
|
|
|
|
parser.add_argument("-p", "--push",
|
2015-02-24 13:03:53 +00:00
|
|
|
help="Create release. Dry run if unspecified.",
|
2014-03-04 23:27:27 +00:00
|
|
|
default=False, action="store_true")
|
|
|
|
|
|
|
|
def _ProcessOptions(self, options):
|
2014-03-12 10:45:23 +00:00
|
|
|
if not options.author or not options.reviewer: # pragma: no cover
|
2014-03-04 23:27:27 +00:00
|
|
|
print "You need to specify author and reviewer."
|
|
|
|
return False
|
|
|
|
options.requires_editor = False
|
|
|
|
return True
|
|
|
|
|
2014-09-23 14:41:36 +00:00
|
|
|
def _Config(self):
|
|
|
|
return {
|
|
|
|
"PERSISTFILE_BASENAME": "/tmp/v8-auto-push-tempfile",
|
|
|
|
}
|
|
|
|
|
2014-03-04 23:27:27 +00:00
|
|
|
def _Steps(self):
|
|
|
|
return [
|
|
|
|
Preparation,
|
2014-11-26 15:23:35 +00:00
|
|
|
FetchCandidate,
|
2015-01-28 10:08:53 +00:00
|
|
|
LastReleaseBailout,
|
2015-02-24 13:03:53 +00:00
|
|
|
CreateRelease,
|
2014-03-04 23:27:27 +00:00
|
|
|
]
|
|
|
|
|
2013-11-18 14:10:47 +00:00
|
|
|
|
2014-03-12 10:45:23 +00:00
|
|
|
if __name__ == "__main__": # pragma: no cover
|
2014-09-23 14:41:36 +00:00
|
|
|
sys.exit(AutoPush().Run())
|