blob: 1c5c58f246c8c829f2574cc340d669fa20de3581 [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 ChangeListUtilApi(recipe_api.RecipeApi):
"""APIs for interacting with presubmit-kitchen-sink."""
def get_postsubmit_tryjobs(
self,
change_id,
host,
project,
trigger_all_presubmit,
):
"""Given details of a ChangeList patchset, fetch luci config files and
return presubmit builds not triggered by CQ but monitored in postsubmit.
Args:
change_id (str) - https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#change-id
host (str) - The gerrit review host; do not include `https://`. (e.g. fuchsia-review.googlesource.com)
project (str) - The gerrit project this change is against (e.g. infra/infra)
trigger_all_presubmit (bool) - Whether to fetch all builders available in presubmit or only fetch builders with `run-postsubmit-tryjobs-include`.
Returns: seq(string) A list of builder names to be triggered.
"""
cmd = [
self._cl_util_tool,
"run-postsubmit-tryjobs",
"-gerrit-change-id",
change_id,
"-gerrit-host",
host,
"-gerrit-project",
project,
"-f",
"-dry-run",
"-json-output",
self.m.json.output(),
]
if trigger_all_presubmit:
cmd.append("-trigger-all-presubmit")
return self.m.step(
"fetch required postsubmit builders",
cmd,
step_test_data=lambda: self.m.json.test_api.output(
{"builders": ["foo", "bar", "baz"]}
),
).json.output["builders"]
@property
def _cl_util_tool(self):
return self.m.ensure_tool("cl-util", self.resource("tool_manifest.json"))