blob: 30845acd95b760768506da17e5b60924bf782bf9 [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 AutogardenerApi(recipe_api.RecipeApi):
"""APIs for interacting with the automatic gardener."""
def find_culprits(self, build_ids):
"""Given IDs of failed buildbucket builds, run culprit analysis.
Args:
build_ids (seq of int): List of failing build IDs.
Returns: A markdown-formatting string containing a ranking of potential
culprit changes.
"""
cmd = [
self._autogardener_tool,
"culprit",
"-json-output",
self.m.json.output(),
]
cmd.extend(build_ids)
return self.m.step(
"find culprits",
cmd,
step_test_data=lambda: self.m.json.test_api.output(
{"markdown_output": "1. foo\n2. bar"}
),
).json.output["markdown_output"]
@property
def _autogardener_tool(self):
return self.m.ensure_tool("autogardener", self.resource("tool_manifest.json"))