Update bot_update to provide manifest information for source check

This updates _EnabledTurboCiCheckHandler.set_result so that it adds a
BotUpdateResults when finalizing the associated source check. This
result provides information about all of the unpatched revisions that
were checked out.

Bug: b:443496677
Change-Id: I5ea0f798ef720e02fa130ec108a44d273187d964
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7227736
Reviewed-by: Robbie Iannucci <iannucci@google.com>
Commit-Queue: Garrett Beaty <gbeaty@google.com>
This commit is contained in:
Garrett Beaty
2025-12-04 12:11:32 -08:00
committed by LUCI CQ
parent 8239385e8c
commit f525e4eb3c
3 changed files with 90 additions and 11 deletions

View File

@@ -59,18 +59,18 @@
Recipe module to ensure a checkout is consistent on a bot.
#### **class [BotUpdateApi](/recipes/recipe_modules/bot_update/api.py#266)([RecipeApi][recipe_engine/wkt/RecipeApi]):**
#### **class [BotUpdateApi](/recipes/recipe_modules/bot_update/api.py#277)([RecipeApi][recipe_engine/wkt/RecipeApi]):**
&mdash; **def [\_\_call\_\_](/recipes/recipe_modules/bot_update/api.py#275)(self, name, cmd, \*\*kwargs):**
&mdash; **def [\_\_call\_\_](/recipes/recipe_modules/bot_update/api.py#286)(self, name, cmd, \*\*kwargs):**
Wrapper for easy calling of bot_update.
&mdash; **def [deapply\_patch](/recipes/recipe_modules/bot_update/api.py#904)(self, bot_update_result):**
&mdash; **def [deapply\_patch](/recipes/recipe_modules/bot_update/api.py#915)(self, bot_update_result):**
Deapplies a patch, taking care of DEPS and solution revisions properly.
&mdash; **def [ensure\_checkout](/recipes/recipe_modules/bot_update/api.py#390)(self, gclient_config=None, \*, suffix=None, patch=True, update_presentation=True, patch_root=None, with_branch_heads=False, with_tags=False, no_fetch_tags=False, refs=None, clobber=False, root_solution_revision=None, gerrit_no_reset=False, gerrit_no_rebase_patch_ref=False, assert_one_gerrit_change=True, patch_refs=None, ignore_input_commit=False, add_blamelists=False, set_output_commit=False, step_test_data=None, enforce_fetch=False, download_topics=False, recipe_revision_overrides=None, step_tags=None, clean_ignored=False, turboci_check_id: str='', \*\*kwargs):**
&mdash; **def [ensure\_checkout](/recipes/recipe_modules/bot_update/api.py#401)(self, gclient_config=None, \*, suffix=None, patch=True, update_presentation=True, patch_root=None, with_branch_heads=False, with_tags=False, no_fetch_tags=False, refs=None, clobber=False, root_solution_revision=None, gerrit_no_reset=False, gerrit_no_rebase_patch_ref=False, assert_one_gerrit_change=True, patch_refs=None, ignore_input_commit=False, add_blamelists=False, set_output_commit=False, step_test_data=None, enforce_fetch=False, download_topics=False, recipe_revision_overrides=None, step_tags=None, clean_ignored=False, turboci_check_id: str='', \*\*kwargs):**
Args:
* gclient_config: The gclient configuration to use when running bot_update.
@@ -113,7 +113,7 @@ Args:
if a non-empty value is provided and the gclient config doesn't have
exactly 1 solution.
&mdash; **def [get\_project\_revision\_properties](/recipes/recipe_modules/bot_update/api.py#881)(self, project_name, gclient_config=None):**
&mdash; **def [get\_project\_revision\_properties](/recipes/recipe_modules/bot_update/api.py#892)(self, project_name, gclient_config=None):**
Returns all property names used for storing the checked-out revision of
a given project.
@@ -127,14 +127,14 @@ Args:
Returns (list of str): All properties that'll hold the checked-out revision
of the given project. An empty list if no such properties exist.
&emsp; **@property**<br>&mdash; **def [last\_returned\_properties](/recipes/recipe_modules/bot_update/api.py#294)(self):**
&emsp; **@property**<br>&mdash; **def [last\_returned\_properties](/recipes/recipe_modules/bot_update/api.py#305)(self):**
&mdash; **def [resolve\_fixed\_revision](/recipes/recipe_modules/bot_update/api.py#832)(self, bot_update_result, name):**
&mdash; **def [resolve\_fixed\_revision](/recipes/recipe_modules/bot_update/api.py#843)(self, bot_update_result, name):**
Sets a fixed revision for a single dependency using project revision
properties.
&mdash; **def [step\_name](/recipes/recipe_modules/bot_update/api.py#921)(self, patch, suffix):**
&mdash; **def [step\_name](/recipes/recipe_modules/bot_update/api.py#932)(self, patch, suffix):**
### *recipe_modules* / [depot\_tools](/recipes/recipe_modules/depot_tools)
[DEPS](/recipes/recipe_modules/depot_tools/__init__.py#6): [recipe\_engine/cipd][recipe_engine/recipe_modules/cipd], [recipe\_engine/context][recipe_engine/recipe_modules/context], [recipe\_engine/platform][recipe_engine/recipe_modules/platform], [recipe\_engine/runtime][recipe_engine/recipe_modules/runtime]
@@ -1125,10 +1125,10 @@ Raises:
&mdash; **def [RunSteps](/recipes/recipe_modules/bot_update/tests/ensure_checkout_return_custom_result.py#25)(api, expected_checkout_dir, expected_source_root_name, expected_patch_root_name):**
### *recipes* / [bot\_update:tests/ensure\_checkout\_turboci\_checks](/recipes/recipe_modules/bot_update/tests/ensure_checkout_turboci_checks.py)
[DEPS](/recipes/recipe_modules/bot_update/tests/ensure_checkout_turboci_checks.py#16): [bot\_update](#recipe_modules-bot_update), [gclient](#recipe_modules-gclient), [recipe\_engine/assertions][recipe_engine/recipe_modules/assertions], [recipe\_engine/buildbucket][recipe_engine/recipe_modules/buildbucket], [recipe\_engine/path][recipe_engine/recipe_modules/path], [recipe\_engine/properties][recipe_engine/recipe_modules/properties]
[DEPS](/recipes/recipe_modules/bot_update/tests/ensure_checkout_turboci_checks.py#18): [bot\_update](#recipe_modules-bot_update), [gclient](#recipe_modules-gclient), [recipe\_engine/assertions][recipe_engine/recipe_modules/assertions], [recipe\_engine/buildbucket][recipe_engine/recipe_modules/buildbucket], [recipe\_engine/path][recipe_engine/recipe_modules/path], [recipe\_engine/properties][recipe_engine/recipe_modules/properties]
&mdash; **def [RunSteps](/recipes/recipe_modules/bot_update/tests/ensure_checkout_turboci_checks.py#34)(api, turboci_check_id: (str | None), bar_revision: str):**
&mdash; **def [RunSteps](/recipes/recipe_modules/bot_update/tests/ensure_checkout_turboci_checks.py#36)(api, turboci_check_id: (str | None), bar_revision: str):**
### *recipes* / [depot\_tools:examples/full](/recipes/recipe_modules/depot_tools/examples/full.py)
[DEPS](/recipes/recipe_modules/depot_tools/examples/full.py#6): [depot\_tools](#recipe_modules-depot_tools), [recipe\_engine/path][recipe_engine/recipe_modules/path], [recipe\_engine/platform][recipe_engine/recipe_modules/platform], [recipe\_engine/runtime][recipe_engine/recipe_modules/runtime], [recipe\_engine/step][recipe_engine/recipe_modules/step]

View File

@@ -13,6 +13,8 @@ from recipe_engine import recipe_api, turboci
from recipe_engine.config_types import Path
from PB.go.chromium.org.luci.buildbucket.proto import common as common_pb2
from PB.turboci.data.chrome.depot_tools.v1.bot_update_results import (
BotUpdateResults)
from PB.turboci.data.gerrit.v1.gob_source_check_options import (
GobSourceCheckOptions)
from PB.turboci.data.gerrit.v1.gob_source_check_results import (
@@ -253,13 +255,22 @@ class _EnabledTurboCiCheckHandler(_TurboCICheckHandler):
# last_modification_time, submitted_time, current_revision, revisions,
# owner, reviewers, labels, messages, change_id, topic, is_owner_bot?
)
bot_update_check_results = BotUpdateResults()
for path, manifest_commit in result.manifest.items():
host, project = self._api.m.gitiles.parse_repo_url(
manifest_commit['repository'])
commit = bot_update_check_results.manifest[path]
commit.host = host.removesuffix('.googlesource.com')
commit.project = project
commit.id = manifest_commit['revision']
# TODO: crbug.com/443496677 - Add a result type to expose the bot_update
# manifest
turboci.write_nodes(
turboci.reason('bot_update completed'),
turboci.check(
self._check_id,
results=[gob_source_check_results],
results=[gob_source_check_results, bot_update_check_results],
state='CHECK_STATE_FINAL',
))

View File

@@ -8,6 +8,8 @@ from PB.turboci.graph.orchestrator.v1.check_kind import CheckKind
from PB.turboci.graph.orchestrator.v1.check_state import CheckState
from PB.turboci.graph.orchestrator.v1.graph_view import GraphView
from PB.turboci.data.gerrit.v1.gerrit_change_info import GerritChangeInfo
from PB.turboci.data.chrome.depot_tools.v1.bot_update_results import (
BotUpdateResults)
from PB.turboci.data.gerrit.v1.gob_source_check_options import (
GobSourceCheckOptions)
from PB.turboci.data.gerrit.v1.gob_source_check_results import (
@@ -111,6 +113,27 @@ def GenTests(api):
]
assert_(gob_source_check_results == expected_gob_source_check_results)
bot_update_check_results = turboci.get_results(BotUpdateResults, check_view)
expected_bot_update_check_results = [
BotUpdateResults(
manifest={
'bar':
BotUpdateResults.GitCommit(
host='fake-host',
project='bar',
id='b' * 40,
),
'foo':
BotUpdateResults.GitCommit(
host='fake-host',
project='foo',
id='a' * 40,
),
}),
]
assert_(bot_update_check_results == expected_bot_update_check_results)
yield api.test(
'check-ci',
api.properties(
@@ -163,6 +186,26 @@ def GenTests(api):
]
assert_(gob_source_check_results == expected_gob_source_check_results)
bot_update_check_results = turboci.get_results(BotUpdateResults, check_view)
expected_bot_update_check_results = [
BotUpdateResults(
manifest={
'bar':
BotUpdateResults.GitCommit(
host='fake-host',
project='bar',
id='b' * 40,
),
'foo':
BotUpdateResults.GitCommit(
host='fake-host',
project='foo',
id='a' * 40,
),
}),
]
assert_(bot_update_check_results == expected_bot_update_check_results)
yield api.test(
'check-ci-revision-only',
api.properties(
@@ -174,6 +217,7 @@ def GenTests(api):
git_ref=None,
revision='a' * 40,
),
api.bot_update.revisions({'bar': 'b' * 40}),
api.bot_update.repo_urls({
'foo': f'{_FOO_REPO_URL}.git',
'bar': f'{_BAR_REPO_URL}.git',
@@ -233,6 +277,26 @@ def GenTests(api):
]
assert_(gob_source_check_results == expected_gob_source_check_results)
bot_update_check_results = turboci.get_results(BotUpdateResults, check_view)
expected_bot_update_check_results = [
BotUpdateResults(
manifest={
'bar':
BotUpdateResults.GitCommit(
host='fake-host',
project='bar',
id='b' * 40,
),
'foo':
BotUpdateResults.GitCommit(
host='fake-host',
project='foo',
id='a' * 40,
),
}),
]
assert_(bot_update_check_results == expected_bot_update_check_results)
yield api.test(
'check-try',
api.properties(
@@ -244,6 +308,10 @@ def GenTests(api):
change_number=123456,
patch_set=7,
),
api.bot_update.revisions({
'foo': 'a' * 40,
'bar': 'b' * 40,
}),
api.bot_update.repo_urls({
'foo': f'{_FOO_REPO_URL}.git',
'bar': f'{_BAR_REPO_URL}.git',