mirror of
https://chromium.googlesource.com/chromium/tools/depot_tools.git
synced 2026-01-11 02:31:29 +00:00
Fix docstrings and add support for arbitrary CL try-results
This fixes the copy-paste error with the _from_id and _from_build_number versions of get_build. It also adds support for getting try results from a URL, not just the current checked out version. Bug: None Change-Id: I1e076c5c461c346f5864eda068a6552237f5691f Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6890424 Reviewed-by: Brian Sheedy <bsheedy@chromium.org> Commit-Queue: Struan Shrimpton <sshrimp@google.com> Auto-Submit: Struan Shrimpton <sshrimp@google.com>
This commit is contained in:
committed by
LUCI CQ
parent
e0cc7e0bef
commit
28ecc1b36a
@@ -47,25 +47,8 @@ async def get_build_from_id(
|
|||||||
https://ci.chromium.org/b/<build_id>
|
https://ci.chromium.org/b/<build_id>
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
build_id: The request body for the RPC. All fields should be represented
|
build_id: The BuildBucket build id. This is a unique identifier for the
|
||||||
by strings. Integer fields will be parsed later.
|
build.
|
||||||
https://chromium.googlesource.com/infra/luci/luci-go/+/main/buildbucket/proto/builds_service.proto
|
|
||||||
for more details.
|
|
||||||
|
|
||||||
The request's mask can be set to get more information. By default only
|
|
||||||
high level statuses will be returned. Some useful fields to include in
|
|
||||||
this mask are:
|
|
||||||
status, input, output, id, builder, builder_info, tags, steps, infra
|
|
||||||
Multiple fields in the mask can be included as a comma separated string
|
|
||||||
e.g.
|
|
||||||
The build_number is mutually exclusive with the build_id. To get the
|
|
||||||
build from a build_id, only the build_id is needed. e.g.
|
|
||||||
{
|
|
||||||
"id": "<build id>",
|
|
||||||
"mask": {
|
|
||||||
"fields": "steps,tags"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fields: A list of fields to return. Options are:
|
fields: A list of fields to return. Options are:
|
||||||
status, input, output, id, builder, builder_info, tags, steps, infra
|
status, input, output, id, builder, builder_info, tags, steps, infra
|
||||||
|
|
||||||
@@ -93,27 +76,14 @@ async def get_build_from_build_number(
|
|||||||
|
|
||||||
The url of a build can be deconstructed and used to get more details about
|
The url of a build can be deconstructed and used to get more details about
|
||||||
the build. e.g.
|
the build. e.g.
|
||||||
https://ci.chromium.org/b/<build_id>
|
https://ci.chromium.org/ui/p/<builder_project>/builders/<builder_bucket>/<builder_name>/<build_number>/overview
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
build_id: The request body for the RPC. All fields should be represented
|
build_number: The build number of the builder. This is a consecutive
|
||||||
by strings. Integer fields will be parsed later.
|
value that uniquely identifies the build per builder.
|
||||||
https://chromium.googlesource.com/infra/luci/luci-go/+/main/buildbucket/proto/builds_service.proto
|
builder_name: The name of the builder the build belongs to.
|
||||||
for more details.
|
builder_bucket: The bucket the builder belongs to. e.g. 'try' or 'ci'
|
||||||
|
builder_project: The project the bucket belongs to. e.g. 'chromium'
|
||||||
The request's mask can be set to get more information. By default only
|
|
||||||
high level statuses will be returned. Some useful fields to include in
|
|
||||||
this mask are:
|
|
||||||
status, input, output, id, builder, builder_info, tags, steps, infra
|
|
||||||
Multiple fields in the mask can be included as a comma separated string
|
|
||||||
The build_number is mutually exclusive with the build_id. To get the
|
|
||||||
build from a build_id only the build_id is needed. e.g.
|
|
||||||
{
|
|
||||||
"id": "<build_id>",
|
|
||||||
"mask": {
|
|
||||||
"fields": "steps,tags"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fields: A list of fields to return. Options are:
|
fields: A list of fields to return. Options are:
|
||||||
status, input, output, id, builder, builder_info, tags, steps, infra
|
status, input, output, id, builder, builder_info, tags, steps, infra
|
||||||
|
|
||||||
|
|||||||
@@ -13,14 +13,21 @@ tracer = telemetry.get_tracer(__name__)
|
|||||||
async def try_builder_results(
|
async def try_builder_results(
|
||||||
ctx: fastmcp.Context,
|
ctx: fastmcp.Context,
|
||||||
checkout: str,
|
checkout: str,
|
||||||
|
change_list_issue: int | None = None,
|
||||||
):
|
):
|
||||||
"""Gets the try builder results for the current checked out branch
|
"""Gets the try builder results for the provided change list issue
|
||||||
|
|
||||||
|
The url of a gerrit change can be parsed from a gerrit cl e.g.
|
||||||
|
https://chromium-review.googlesource.com/c/chromium/src/+/<change_list_issue>
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
checkout: Location of the current checkout.
|
checkout: Location of the current checkout.
|
||||||
|
change_list_issue: The change list (CL) issue id. If none is provided,
|
||||||
|
the current branch and its associated CL is used.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
A json list of builds that either ran or are still running on the current
|
A json list of builds that either ran or are still running on the provided
|
||||||
CL
|
CL or current branch.
|
||||||
"""
|
"""
|
||||||
with tracer.start_as_current_span('chromium.mcp.try_builder_results'):
|
with tracer.start_as_current_span('chromium.mcp.try_builder_results'):
|
||||||
command = [
|
command = [
|
||||||
@@ -29,6 +36,8 @@ async def try_builder_results(
|
|||||||
"try-results",
|
"try-results",
|
||||||
"--json=-",
|
"--json=-",
|
||||||
]
|
]
|
||||||
|
if change_list_issue:
|
||||||
|
command.extend(['-i', str(change_list_issue)])
|
||||||
result = subprocess.run(
|
result = subprocess.run(
|
||||||
command,
|
command,
|
||||||
capture_output=True,
|
capture_output=True,
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ class GitClTest(unittest.IsolatedAsyncioTestCase):
|
|||||||
args=[], returncode=0, stdout=expected_output, stderr='')
|
args=[], returncode=0, stdout=expected_output, stderr='')
|
||||||
|
|
||||||
output = await git_cl.try_builder_results(self.mock_context,
|
output = await git_cl.try_builder_results(self.mock_context,
|
||||||
self.checkout)
|
self.checkout, None)
|
||||||
|
|
||||||
self.assertEqual(output, expected_output)
|
self.assertEqual(output, expected_output)
|
||||||
expected_command = ["git", "cl", "try-results", "--json=-"]
|
expected_command = ["git", "cl", "try-results", "--json=-"]
|
||||||
@@ -42,6 +42,26 @@ class GitClTest(unittest.IsolatedAsyncioTestCase):
|
|||||||
text=True,
|
text=True,
|
||||||
cwd=self.checkout)
|
cwd=self.checkout)
|
||||||
|
|
||||||
|
@mock.patch('subprocess.run')
|
||||||
|
async def test_try_builder_results_with_issue_success(
|
||||||
|
self, mock_subprocess_run):
|
||||||
|
expected_output = '{"builds": []}'
|
||||||
|
mock_subprocess_run.return_value = subprocess.CompletedProcess(
|
||||||
|
args=[], returncode=0, stdout=expected_output, stderr='')
|
||||||
|
|
||||||
|
output = await git_cl.try_builder_results(self.mock_context,
|
||||||
|
self.checkout, 1234)
|
||||||
|
|
||||||
|
self.assertEqual(output, expected_output)
|
||||||
|
expected_command = [
|
||||||
|
"git", "cl", "try-results", "--json=-", "-i", "1234"
|
||||||
|
]
|
||||||
|
mock_subprocess_run.assert_called_once_with(expected_command,
|
||||||
|
capture_output=True,
|
||||||
|
check=True,
|
||||||
|
text=True,
|
||||||
|
cwd=self.checkout)
|
||||||
|
|
||||||
@mock.patch('subprocess.run')
|
@mock.patch('subprocess.run')
|
||||||
async def test_get_current_changes_success(self, mock_subprocess_run):
|
async def test_get_current_changes_success(self, mock_subprocess_run):
|
||||||
expected_output = 'diff --git a/file.txt b/file.txt'
|
expected_output = 'diff --git a/file.txt b/file.txt'
|
||||||
|
|||||||
Reference in New Issue
Block a user