From b0024901d3f2f106f380e28e89951e31c1ce4d77 Mon Sep 17 00:00:00 2001 From: Struan Shrimpton Date: Thu, 1 Aug 2024 17:53:27 +0000 Subject: [PATCH] Add support for tagging bot_update step In order to make reproduction steps appear on the bot_update step it needs to have a tag that matches the instruction set on the invocation. Bug: 349529661 Change-Id: Idcf75715ea4a64a5c6d9571f4f5485613864b7da Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5754258 Reviewed-by: Gavin Mak Commit-Queue: Struan Shrimpton --- recipes/README.recipes.md | 9 +++++---- recipes/recipe_modules/bot_update/api.py | 6 ++++++ .../recipe_modules/bot_update/tests/ensure_checkout.py | 1 + 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/recipes/README.recipes.md b/recipes/README.recipes.md index 90e6783ef..c5cc5bc16 100644 --- a/recipes/README.recipes.md +++ b/recipes/README.recipes.md @@ -63,12 +63,12 @@ Recipe module to ensure a checkout is consistent on a bot. Wrapper for easy calling of bot_update. -— **def [deapply\_patch](/recipes/recipe_modules/bot_update/api.py#672)(self, bot_update_result):** +— **def [deapply\_patch](/recipes/recipe_modules/bot_update/api.py#678)(self, bot_update_result):** Deapplies a patch, taking care of DEPS and solution revisions properly. -— **def [ensure\_checkout](/recipes/recipe_modules/bot_update/api.py#191)(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, \*\*kwargs):** +— **def [ensure\_checkout](/recipes/recipe_modules/bot_update/api.py#191)(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, \*\*kwargs):** Args: * gclient_config: The gclient configuration to use when running bot_update. @@ -103,8 +103,9 @@ Args: to each particular build/recipe run. e.g. the recipe might parse a gerrit change's commit message to get this revision override requested by the author. + * step_tags: a dict {tag name: tag value} of tags to add to the step -— **def [get\_project\_revision\_properties](/recipes/recipe_modules/bot_update/api.py#649)(self, project_name, gclient_config=None):** +— **def [get\_project\_revision\_properties](/recipes/recipe_modules/bot_update/api.py#655)(self, project_name, gclient_config=None):** Returns all property names used for storing the checked-out revision of a given project. @@ -120,7 +121,7 @@ Returns (list of str): All properties that'll hold the checked-out revision   **@property**
— **def [last\_returned\_properties](/recipes/recipe_modules/bot_update/api.py#99)(self):** -— **def [resolve\_fixed\_revision](/recipes/recipe_modules/bot_update/api.py#600)(self, bot_update_result, name):** +— **def [resolve\_fixed\_revision](/recipes/recipe_modules/bot_update/api.py#606)(self, bot_update_result, name):** Sets a fixed revision for a single dependency using project revision properties. diff --git a/recipes/recipe_modules/bot_update/api.py b/recipes/recipe_modules/bot_update/api.py index 315ff89c1..ae1d842f2 100644 --- a/recipes/recipe_modules/bot_update/api.py +++ b/recipes/recipe_modules/bot_update/api.py @@ -211,6 +211,7 @@ class BotUpdateApi(recipe_api.RecipeApi): enforce_fetch=False, download_topics=False, recipe_revision_overrides=None, + step_tags=None, **kwargs): """ Args: @@ -246,6 +247,7 @@ class BotUpdateApi(recipe_api.RecipeApi): to each particular build/recipe run. e.g. the recipe might parse a gerrit change's commit message to get this revision override requested by the author. + * step_tags: a dict {tag name: tag value} of tags to add to the step """ assert not (ignore_input_commit and set_output_commit) if assert_one_gerrit_change: @@ -440,6 +442,10 @@ class BotUpdateApi(recipe_api.RecipeApi): finally: step_result = self.m.step.active_result + if step_tags: + for tag, value in step_tags.items(): + step_result.presentation.tags[tag] = value + # The step_result can be missing the json attribute if the build # is shutting down and the bot_update script is not able to finish # writing the json output. diff --git a/recipes/recipe_modules/bot_update/tests/ensure_checkout.py b/recipes/recipe_modules/bot_update/tests/ensure_checkout.py index ba704172d..74a3943d2 100644 --- a/recipes/recipe_modules/bot_update/tests/ensure_checkout.py +++ b/recipes/recipe_modules/bot_update/tests/ensure_checkout.py @@ -17,6 +17,7 @@ def RunSteps(api): api.gclient.set_config('depot_tools') api.bot_update.ensure_checkout() api.bot_update.ensure_checkout(no_fetch_tags=True, enforce_fetch=True) + api.bot_update.ensure_checkout(step_tags={'tag': 'value'}) def GenTests(api):