[release] Add json output to release tools.

This will allow callers (e.g. the infra recipe) to check
which steps have been executed and monitor success/failure.

BUG=chromium:559141
LOG=n
NOTRY=true

Review URL: https://codereview.chromium.org/1463143004

Cr-Commit-Position: refs/heads/master@{#32150}
This commit is contained in:
machenbach 2015-11-20 06:49:29 -08:00 committed by Commit bot
parent 40a501a26a
commit cded3ea64f
3 changed files with 19 additions and 48 deletions

View File

@ -13,31 +13,6 @@ from common_includes import *
import chromium_roll import chromium_roll
class CheckActiveRoll(Step):
MESSAGE = "Check active roll."
@staticmethod
def ContainsChromiumRoll(changes):
for change in changes:
if change["subject"].startswith("Update V8 to"):
return True
return False
def RunStep(self):
params = {
"closed": 3,
"owner": self._options.author,
"limit": 30,
"format": "json",
}
params = urllib.urlencode(params)
search_url = "https://codereview.chromium.org/search"
result = self.ReadURL(search_url, params, wait_plan=[5, 20])
if self.ContainsChromiumRoll(json.loads(result)["results"]):
print "Stop due to existing Chromium roll."
return True
class DetectLastRoll(Step): class DetectLastRoll(Step):
MESSAGE = "Detect commit ID of the last Chromium roll." MESSAGE = "Detect commit ID of the last Chromium roll."
@ -96,6 +71,8 @@ class RollChromium(Step):
args.append("--dry-run") args.append("--dry-run")
if self._options.work_dir: if self._options.work_dir:
args.extend(["--work-dir", self._options.work_dir]) args.extend(["--work-dir", self._options.work_dir])
if self._options.chromium_roll_json_output:
args.extend(["--json-output", self._options.chromium_roll_json_output])
self._side_effect_handler.Call(chromium_roll.ChromiumRoll().Run, args) self._side_effect_handler.Call(chromium_roll.ChromiumRoll().Run, args)
@ -104,6 +81,8 @@ class AutoRoll(ScriptsBase):
parser.add_argument("-c", "--chromium", required=True, parser.add_argument("-c", "--chromium", required=True,
help=("The path to your Chromium src/ " help=("The path to your Chromium src/ "
"directory to automate the V8 roll.")) "directory to automate the V8 roll."))
parser.add_argument("--chromium-roll-json-output",
help="File to write wrapped results summary to.")
parser.add_argument("--max-age", default=3, type=int, parser.add_argument("--max-age", default=3, type=int,
help="Maximum age in days of the latest release.") help="Maximum age in days of the latest release.")
parser.add_argument("--roll", help="Call Chromium roll script.", parser.add_argument("--roll", help="Call Chromium roll script.",
@ -125,7 +104,6 @@ class AutoRoll(ScriptsBase):
def _Steps(self): def _Steps(self):
return [ return [
CheckActiveRoll,
DetectLastRoll, DetectLastRoll,
RollChromium, RollChromium,
] ]

View File

@ -738,7 +738,7 @@ class Step(GitRecipesMixin):
class BootstrapStep(Step): class BootstrapStep(Step):
MESSAGE = "Bootstapping v8 checkout." MESSAGE = "Bootstrapping v8 checkout."
def RunStep(self): def RunStep(self):
if os.path.realpath(self.default_cwd) == os.path.realpath(V8_BASE): if os.path.realpath(self.default_cwd) == os.path.realpath(V8_BASE):
@ -838,6 +838,8 @@ class ScriptsBase(object):
help="The author email used for rietveld.") help="The author email used for rietveld.")
parser.add_argument("--dry-run", default=False, action="store_true", parser.add_argument("--dry-run", default=False, action="store_true",
help="Perform only read-only actions.") help="Perform only read-only actions.")
parser.add_argument("--json-output",
help="File to write results summary to.")
parser.add_argument("-r", "--reviewer", default="", parser.add_argument("-r", "--reviewer", default="",
help="The account name to be used for reviews.") help="The account name to be used for reviews.")
parser.add_argument("--sheriff", default=False, action="store_true", parser.add_argument("--sheriff", default=False, action="store_true",
@ -896,9 +898,18 @@ class ScriptsBase(object):
for (number, step_class) in enumerate([BootstrapStep] + step_classes): for (number, step_class) in enumerate([BootstrapStep] + step_classes):
steps.append(MakeStep(step_class, number, self._state, self._config, steps.append(MakeStep(step_class, number, self._state, self._config,
options, self._side_effect_handler)) options, self._side_effect_handler))
step_summary = []
try:
for step in steps[options.step:]: for step in steps[options.step:]:
if step.Run(): terminate = step.Run()
step_summary.append(step._text)
if terminate:
return 0 return 0
finally:
if options.json_output:
with open(options.json_output, "w") as f:
json.dump({"step_summary": step_summary}, f)
return 0 return 0
def Run(self, args=None): def Run(self, args=None):

View File

@ -1103,18 +1103,6 @@ TBR=g_name@chromium.org,reviewer@chromium.org"""
self.assertEquals("abc123", state["candidate"]) self.assertEquals("abc123", state["candidate"])
def testAutoRollExistingRoll(self):
self.Expect([
URL("https://codereview.chromium.org/search",
"owner=author%40chromium.org&limit=30&closed=3&format=json",
("{\"results\": [{\"subject\": \"different\"},"
"{\"subject\": \"Update V8 to Version...\"}]}")),
])
result = auto_roll.AutoRoll(TEST_CONFIG, self).Run(
AUTO_PUSH_ARGS + ["-c", TEST_CONFIG["CHROMIUM"]])
self.assertEquals(0, result)
# Snippet from the original DEPS file. # Snippet from the original DEPS file.
FAKE_DEPS = """ FAKE_DEPS = """
vars = { vars = {
@ -1131,9 +1119,6 @@ deps = {
TEST_CONFIG["CHROMIUM"] = self.MakeEmptyTempDirectory() TEST_CONFIG["CHROMIUM"] = self.MakeEmptyTempDirectory()
TextToFile(self.FAKE_DEPS, os.path.join(TEST_CONFIG["CHROMIUM"], "DEPS")) TextToFile(self.FAKE_DEPS, os.path.join(TEST_CONFIG["CHROMIUM"], "DEPS"))
self.Expect([ self.Expect([
URL("https://codereview.chromium.org/search",
"owner=author%40chromium.org&limit=30&closed=3&format=json",
("{\"results\": [{\"subject\": \"different\"}]}")),
Cmd("git fetch origin +refs/tags/*:refs/tags/*", ""), Cmd("git fetch origin +refs/tags/*:refs/tags/*", ""),
Cmd("git rev-list --max-age=740800 --tags", Cmd("git rev-list --max-age=740800 --tags",
"bad_tag\nhash_234\nhash_123"), "bad_tag\nhash_234\nhash_123"),
@ -1154,9 +1139,6 @@ deps = {
TextToFile(self.FAKE_DEPS, os.path.join(TEST_CONFIG["CHROMIUM"], "DEPS")) TextToFile(self.FAKE_DEPS, os.path.join(TEST_CONFIG["CHROMIUM"], "DEPS"))
self.Expect([ self.Expect([
URL("https://codereview.chromium.org/search",
"owner=author%40chromium.org&limit=30&closed=3&format=json",
("{\"results\": [{\"subject\": \"different\"}]}")),
Cmd("git fetch origin +refs/tags/*:refs/tags/*", ""), Cmd("git fetch origin +refs/tags/*:refs/tags/*", ""),
Cmd("git rev-list --max-age=740800 --tags", Cmd("git rev-list --max-age=740800 --tags",
"bad_tag\nhash_234\nhash_123"), "bad_tag\nhash_234\nhash_123"),