From 8038dfe3be2580dbff0d8065ea1fb04fbf2720ab Mon Sep 17 00:00:00 2001 From: Sergey Berezin Date: Thu, 27 Jul 2017 21:33:48 -0700 Subject: [PATCH] bot_update recipe: parameterize step name in apply_gerrit_ref Needed for parity with Rietveld two-sided patch application. BUG=628259 R=agable@chromium.org Change-Id: I79221f54e89a9291257a71b70cc52acc51167854 Reviewed-on: https://chromium-review.googlesource.com/591047 Reviewed-by: Aaron Gable Commit-Queue: Sergey Berezin --- recipes/README.recipes.md | 8 ++++---- recipes/recipe_modules/bot_update/api.py | 5 +++-- .../full.expected/apply_gerrit_ref_custom.json | 2 +- recipes/recipe_modules/bot_update/examples/full.py | 13 +++++++++++-- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/recipes/README.recipes.md b/recipes/README.recipes.md index 0daabdab9e..5f60b15a19 100644 --- a/recipes/README.recipes.md +++ b/recipes/README.recipes.md @@ -47,14 +47,14 @@ Recipe module to ensure a checkout is consistent on a bot. Wrapper for easy calling of bot_update. -— **def [apply\_gerrit\_ref](/recipes/recipe_modules/bot_update/api.py#49)(self, root, gerrit_no_reset=False, gerrit_no_rebase_patch_ref=False, gerrit_repo=None, gerrit_ref=None, \*\*kwargs):** +— **def [apply\_gerrit\_ref](/recipes/recipe_modules/bot_update/api.py#49)(self, root, gerrit_no_reset=False, gerrit_no_rebase_patch_ref=False, gerrit_repo=None, gerrit_ref=None, step_name='apply_gerrit', \*\*kwargs):** -— **def [deapply\_patch](/recipes/recipe_modules/bot_update/api.py#428)(self, bot_update_step):** +— **def [deapply\_patch](/recipes/recipe_modules/bot_update/api.py#429)(self, bot_update_step):** Deapplies a patch, taking care of DEPS and solution revisions properly. -— **def [ensure\_checkout](/recipes/recipe_modules/bot_update/api.py#70)(self, gclient_config=None, suffix=None, patch=True, update_presentation=True, patch_root=None, no_shallow=False, with_branch_heads=False, with_tags=False, refs=None, patch_oauth2=False, oauth2_json=False, use_site_config_creds=True, clobber=False, root_solution_revision=None, rietveld=None, issue=None, patchset=None, gerrit_no_reset=False, gerrit_no_rebase_patch_ref=False, disable_syntax_validation=False, \*\*kwargs):** +— **def [ensure\_checkout](/recipes/recipe_modules/bot_update/api.py#71)(self, gclient_config=None, suffix=None, patch=True, update_presentation=True, patch_root=None, no_shallow=False, with_branch_heads=False, with_tags=False, refs=None, patch_oauth2=False, oauth2_json=False, use_site_config_creds=True, clobber=False, root_solution_revision=None, rietveld=None, issue=None, patchset=None, gerrit_no_reset=False, gerrit_no_rebase_patch_ref=False, disable_syntax_validation=False, \*\*kwargs):** Args: use_site_config_creds: If the oauth2 credentials are in the buildbot @@ -71,7 +71,7 @@ Args: Needed as migration paths for recipes dealing with older revisions, such as bisect. -— **def [get\_project\_revision\_properties](/recipes/recipe_modules/bot_update/api.py#405)(self, project_name, gclient_config=None):** +— **def [get\_project\_revision\_properties](/recipes/recipe_modules/bot_update/api.py#406)(self, project_name, gclient_config=None):** Returns all property names used for storing the checked-out revision of a given project. diff --git a/recipes/recipe_modules/bot_update/api.py b/recipes/recipe_modules/bot_update/api.py index 2e9d9e629f..5fae30e5b3 100644 --- a/recipes/recipe_modules/bot_update/api.py +++ b/recipes/recipe_modules/bot_update/api.py @@ -48,7 +48,8 @@ class BotUpdateApi(recipe_api.RecipeApi): # TODO(tandrii): refactor this into tryserver.maybe_apply_patch def apply_gerrit_ref(self, root, gerrit_no_reset=False, gerrit_no_rebase_patch_ref=False, - gerrit_repo=None, gerrit_ref=None, **kwargs): + gerrit_repo=None, gerrit_ref=None, + step_name='apply_gerrit', **kwargs): apply_gerrit_path = self.resource('apply_gerrit.py') kwargs.setdefault('infra_step', True) cmd = [ @@ -65,7 +66,7 @@ class BotUpdateApi(recipe_api.RecipeApi): 'PATH': [self.m.depot_tools.root], } with self.m.context(env_prefixes=env_prefixes): - return self.m.python('apply_gerrit', apply_gerrit_path, cmd, **kwargs) + return self.m.python(step_name, apply_gerrit_path, cmd, **kwargs) def ensure_checkout(self, gclient_config=None, suffix=None, patch=True, update_presentation=True, diff --git a/recipes/recipe_modules/bot_update/examples/full.expected/apply_gerrit_ref_custom.json b/recipes/recipe_modules/bot_update/examples/full.expected/apply_gerrit_ref_custom.json index 1c948dba40..25625d928b 100644 --- a/recipes/recipe_modules/bot_update/examples/full.expected/apply_gerrit_ref_custom.json +++ b/recipes/recipe_modules/bot_update/examples/full.expected/apply_gerrit_ref_custom.json @@ -19,7 +19,7 @@ ] }, "infra_step": true, - "name": "apply_gerrit" + "name": "Custom apply gerrit step" }, { "name": "$result", diff --git a/recipes/recipe_modules/bot_update/examples/full.py b/recipes/recipe_modules/bot_update/examples/full.py index 661bb5e2e2..3b51d5f100 100644 --- a/recipes/recipe_modules/bot_update/examples/full.py +++ b/recipes/recipe_modules/bot_update/examples/full.py @@ -48,12 +48,20 @@ def RunSteps(api): api.properties.get('gerrit_no_rebase_patch_ref')) if api.properties.get('test_apply_gerrit_ref'): + prop2arg = { + 'gerrit_custom_repo': 'gerrit_repo', + 'gerrit_custom_ref': 'gerrit_ref', + 'gerrit_custom_step_name': 'step_name', + } + kwargs = { + prop2arg[p]: api.properties.get(p) + for p in prop2arg if api.properties.get(p) + } api.bot_update.apply_gerrit_ref( root='/tmp/test/root', gerrit_no_reset=gerrit_no_reset, gerrit_no_rebase_patch_ref=gerrit_no_rebase_patch_ref, - gerrit_repo=api.properties.get('gerrit_custom_repo'), - gerrit_ref=api.properties.get('gerrit_custom_ref'), + **kwargs ) else: bot_update_step = api.bot_update.ensure_checkout( @@ -165,6 +173,7 @@ def GenTests(api): gerrit_no_reset=1, gerrit_custom_repo='https://custom/repo', gerrit_custom_ref='refs/changes/custom/1234567/1', + gerrit_custom_step_name='Custom apply gerrit step', test_apply_gerrit_ref=True, ) yield api.test('tryjob_v8') + api.properties(