blob: 0c7dc797ca23f4a3201658d93d72a5f3c85f44b7 [file] [log] [blame]
# Copyright 2022 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
from recipe_engine import recipe_api
class BuilderOracleApi(recipe_api.RecipeApi):
"""APIs for interacting with Builder Oracle."""
def simulate(self, config_pairs):
"""Given paths to directories containing generated lucicfg files,
simulate and alerting on the impact of the proposed changes.
Args:
config_pairs ([]<str,str>) an array of string tuples representing
paths to pairs of config directories. Each tuple is made of two
config directory paths. ex: (baseline/fuchsia, proposed/fuchsia)
The first path should always be the baseline and the second
should be the proposed changes.
Returns: JSON structured output with the following fields:
"cl_comment" (string) The comment to write on the CL. If this
is empty, we won't write a comment as the change are either
nonexistant or deemed acceptable.
"""
cmd = [
self._builder_oracle_tool,
"simulate",
"-json-output",
self.m.json.output(),
]
for pair in config_pairs:
cmd.append("-config")
cmd.append("%s,%s" % (pair[0], pair[1]))
return self.m.step(
"simulate proposed builder changes",
cmd,
step_test_data=lambda: self.m.json.test_api.output(
{"cl_comment": "Warning...\nBuilder Oracle found..."}
),
).json.output
@property
def _builder_oracle_tool(self):
return self.m.ensure_tool("builder_oracle", self.resource("tool_manifest.json"))