diff --git a/recipes/README.recipes.md b/recipes/README.recipes.md index 5e6c74fdf..b028d4da7 100644 --- a/recipes/README.recipes.md +++ b/recipes/README.recipes.md @@ -20,6 +20,7 @@ **[Recipes](#Recipes)** * [bot_update:examples/full](#recipes-bot_update_examples_full) + * [bot_update:tests/do_not_retry_patch_failures_in_cq](#recipes-bot_update_tests_do_not_retry_patch_failures_in_cq) * [bot_update:tests/ensure_checkout](#recipes-bot_update_tests_ensure_checkout) * [cipd:examples/full](#recipes-cipd_examples_full) * [cipd:examples/platform_suffix](#recipes-cipd_examples_platform_suffix) @@ -46,7 +47,7 @@ ### *recipe_modules* / [bot\_update](/recipes/recipe_modules/bot_update) -[DEPS](/recipes/recipe_modules/bot_update/__init__.py#1): [depot\_tools](#recipe_modules-depot_tools), [gclient](#recipe_modules-gclient), [gerrit](#recipe_modules-gerrit), [gitiles](#recipe_modules-gitiles), [tryserver](#recipe_modules-tryserver), [recipe\_engine/buildbucket][recipe_engine/recipe_modules/buildbucket], [recipe\_engine/commit\_position][recipe_engine/recipe_modules/commit_position], [recipe\_engine/context][recipe_engine/recipe_modules/context], [recipe\_engine/json][recipe_engine/recipe_modules/json], [recipe\_engine/path][recipe_engine/recipe_modules/path], [recipe\_engine/platform][recipe_engine/recipe_modules/platform], [recipe\_engine/properties][recipe_engine/recipe_modules/properties], [recipe\_engine/python][recipe_engine/recipe_modules/python], [recipe\_engine/raw\_io][recipe_engine/recipe_modules/raw_io], [recipe\_engine/runtime][recipe_engine/recipe_modules/runtime], [recipe\_engine/source\_manifest][recipe_engine/recipe_modules/source_manifest], [recipe\_engine/step][recipe_engine/recipe_modules/step] +[DEPS](/recipes/recipe_modules/bot_update/__init__.py#1): [depot\_tools](#recipe_modules-depot_tools), [gclient](#recipe_modules-gclient), [gerrit](#recipe_modules-gerrit), [gitiles](#recipe_modules-gitiles), [tryserver](#recipe_modules-tryserver), [recipe\_engine/buildbucket][recipe_engine/recipe_modules/buildbucket], [recipe\_engine/commit\_position][recipe_engine/recipe_modules/commit_position], [recipe\_engine/context][recipe_engine/recipe_modules/context], [recipe\_engine/cq][recipe_engine/recipe_modules/cq], [recipe\_engine/json][recipe_engine/recipe_modules/json], [recipe\_engine/path][recipe_engine/recipe_modules/path], [recipe\_engine/platform][recipe_engine/recipe_modules/platform], [recipe\_engine/properties][recipe_engine/recipe_modules/properties], [recipe\_engine/python][recipe_engine/recipe_modules/python], [recipe\_engine/raw\_io][recipe_engine/recipe_modules/raw_io], [recipe\_engine/runtime][recipe_engine/recipe_modules/runtime], [recipe\_engine/source\_manifest][recipe_engine/recipe_modules/source_manifest], [recipe\_engine/step][recipe_engine/recipe_modules/step] Recipe module to ensure a checkout is consistent on a bot. @@ -56,7 +57,7 @@ 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#504)(self, bot_update_step):** +— **def [deapply\_patch](/recipes/recipe_modules/bot_update/api.py#505)(self, bot_update_step):** Deapplies a patch, taking care of DEPS and solution revisions properly. @@ -87,7 +88,7 @@ Args: step_test_data: a null function that returns test bot_update.py output. Use test_api.output_json to generate test data. -— **def [get\_project\_revision\_properties](/recipes/recipe_modules/bot_update/api.py#481)(self, project_name, gclient_config=None):** +— **def [get\_project\_revision\_properties](/recipes/recipe_modules/bot_update/api.py#482)(self, project_name, gclient_config=None):** Returns all property names used for storing the checked-out revision of a given project. @@ -105,7 +106,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#36)(self):** -— **def [resolve\_fixed\_revision](/recipes/recipe_modules/bot_update/api.py#431)(self, bot_update_json, name):** +— **def [resolve\_fixed\_revision](/recipes/recipe_modules/bot_update/api.py#432)(self, bot_update_json, name):** Set a fixed revision for a single dependency using project revision properties. @@ -938,6 +939,11 @@ Raises: [DEPS](/recipes/recipe_modules/bot_update/examples/full.py#5): [bot\_update](#recipe_modules-bot_update), [gclient](#recipe_modules-gclient), [gerrit](#recipe_modules-gerrit), [tryserver](#recipe_modules-tryserver), [recipe\_engine/buildbucket][recipe_engine/recipe_modules/buildbucket], [recipe\_engine/json][recipe_engine/recipe_modules/json], [recipe\_engine/path][recipe_engine/recipe_modules/path], [recipe\_engine/platform][recipe_engine/recipe_modules/platform], [recipe\_engine/properties][recipe_engine/recipe_modules/properties], [recipe\_engine/runtime][recipe_engine/recipe_modules/runtime] — **def [RunSteps](/recipes/recipe_modules/bot_update/examples/full.py#22)(api):** +### *recipes* / [bot\_update:tests/do\_not\_retry\_patch\_failures\_in\_cq](/recipes/recipe_modules/bot_update/tests/do_not_retry_patch_failures_in_cq.py) + +[DEPS](/recipes/recipe_modules/bot_update/tests/do_not_retry_patch_failures_in_cq.py#5): [bot\_update](#recipe_modules-bot_update), [gclient](#recipe_modules-gclient), [recipe\_engine/buildbucket][recipe_engine/recipe_modules/buildbucket], [recipe\_engine/cq][recipe_engine/recipe_modules/cq], [recipe\_engine/properties][recipe_engine/recipe_modules/properties], [recipe\_engine/step][recipe_engine/recipe_modules/step] + +— **def [RunSteps](/recipes/recipe_modules/bot_update/tests/do_not_retry_patch_failures_in_cq.py#17)(api):** ### *recipes* / [bot\_update:tests/ensure\_checkout](/recipes/recipe_modules/bot_update/tests/ensure_checkout.py) [DEPS](/recipes/recipe_modules/bot_update/tests/ensure_checkout.py#7): [bot\_update](#recipe_modules-bot_update), [gclient](#recipe_modules-gclient), [recipe\_engine/json][recipe_engine/recipe_modules/json] diff --git a/recipes/recipe_modules/bot_update/__init__.py b/recipes/recipe_modules/bot_update/__init__.py index ca79009e1..7463ec641 100644 --- a/recipes/recipe_modules/bot_update/__init__.py +++ b/recipes/recipe_modules/bot_update/__init__.py @@ -1,21 +1,22 @@ DEPS = [ - 'depot_tools', - 'gclient', - 'gerrit', - 'gitiles', - 'recipe_engine/buildbucket', - 'recipe_engine/context', - 'recipe_engine/commit_position', - 'recipe_engine/json', - 'recipe_engine/path', - 'recipe_engine/platform', - 'recipe_engine/properties', - 'recipe_engine/python', - 'recipe_engine/raw_io', - 'recipe_engine/runtime', - 'recipe_engine/source_manifest', - 'recipe_engine/step', - 'tryserver', + 'depot_tools', + 'gclient', + 'gerrit', + 'gitiles', + 'recipe_engine/buildbucket', + 'recipe_engine/context', + 'recipe_engine/commit_position', + 'recipe_engine/cq', + 'recipe_engine/json', + 'recipe_engine/path', + 'recipe_engine/platform', + 'recipe_engine/properties', + 'recipe_engine/python', + 'recipe_engine/raw_io', + 'recipe_engine/runtime', + 'recipe_engine/source_manifest', + 'recipe_engine/step', + 'tryserver', ] from recipe_engine.recipe_api import Property diff --git a/recipes/recipe_modules/bot_update/api.py b/recipes/recipe_modules/bot_update/api.py index 172bb9513..763ab8033 100644 --- a/recipes/recipe_modules/bot_update/api.py +++ b/recipes/recipe_modules/bot_update/api.py @@ -379,6 +379,7 @@ class BotUpdateApi(recipe_api.RecipeApi): else: # This is actual patch failure. self.m.tryserver.set_patch_failure_tryjob_result() + self.m.cq.set_do_not_retry_build() self.m.python.failing_step( 'Patch failure', 'See attached log. Try rebasing?') except self.m.step.StepFailure as e: diff --git a/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_fail_patch.json b/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_fail_patch.json index d35179c9b..717a3a651 100644 --- a/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_fail_patch.json +++ b/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_fail_patch.json @@ -157,6 +157,13 @@ "@@@STEP_FAILURE@@@" ] }, + { + "cmd": [], + "name": "TRYJOB DO NOT RETRY", + "~followup_annotations": [ + "@@@SET_BUILD_PROPERTY@do_not_retry@true@@@" + ] + }, { "cmd": [ "python", diff --git a/recipes/recipe_modules/bot_update/tests/do_not_retry_patch_failures_in_cq.py b/recipes/recipe_modules/bot_update/tests/do_not_retry_patch_failures_in_cq.py new file mode 100644 index 000000000..bffed2f04 --- /dev/null +++ b/recipes/recipe_modules/bot_update/tests/do_not_retry_patch_failures_in_cq.py @@ -0,0 +1,42 @@ +# Copyright 2020 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +DEPS = [ + 'bot_update', + 'gclient', + 'recipe_engine/buildbucket', + 'recipe_engine/cq', + 'recipe_engine/properties', + 'recipe_engine/step', +] + +from recipe_engine import post_process + + +def RunSteps(api): + src_cfg = api.gclient.make_config() + soln = src_cfg.solutions.add() + soln.name = 'src' + soln.url = 'https://chromium.googlesource.com/chromium/src.git' + try: + bot_update_step = api.bot_update.ensure_checkout( + patch=True, gclient_config=src_cfg) + except api.step.StepFailure: + api.step( + name='cq will not retry this' + if api.cq.do_not_retry_build else 'will retry', + cmd=None) + + +def GenTests(api): + + yield (api.test('works as intended') + api.buildbucket.try_build( + 'chromium/src', + 'try', + 'linux', + git_repo='https://chromium.googlesource.com/chromium/src') + + api.properties(fail_patch='apply') + api.step_data( + 'bot_update', retcode=88) + api.post_check( + lambda check, steps: check('cq will not retry this' in steps)) + + api.post_process(post_process.DropExpectation))