Let the presubmit recipe module skip owners checks when necessary

The circumstances under which this might happen are left up to the
invoking recipe, which in most cases is the chromium presubmit.py.

Bug: 1034114
Change-Id: Ia8db6ab0da04750d6753e6281ef859e19aea4039
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2018224
Commit-Queue: Aaron Gable <agable@chromium.org>
Reviewed-by: Anthony Polito <apolito@google.com>
changes/24/2018224/6
Aaron Gable 5 years ago committed by LUCI CQ
parent ea8b58b970
commit 1a0daf728c

@ -763,12 +763,13 @@ Raises:
Return a presubmit step.
&mdash; **def [execute](/recipes/recipe_modules/presubmit/api.py#77)(self, bot_update_step):**
&mdash; **def [execute](/recipes/recipe_modules/presubmit/api.py#77)(self, bot_update_step, skip_owners):**
Runs presubmit and sets summary markdown if applicable.
Args:
bot_update_step: the StepResult from a previously executed bot_update step.
skip_owners: a boolean indicating whether Owners checks should be skipped.
Returns:
a RawResult object, suitable for being returned from RunSteps.
@ -1050,7 +1051,7 @@ Move things around in a loop!
[DEPS](/recipes/recipe_modules/presubmit/tests/execute.py#10): [gclient](#recipe_modules-gclient), [presubmit](#recipe_modules-presubmit), [recipe\_engine/buildbucket][recipe_engine/recipe_modules/buildbucket], [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/properties][recipe_engine/recipe_modules/properties], [recipe\_engine/runtime][recipe_engine/recipe_modules/runtime]
&mdash; **def [RunSteps](/recipes/recipe_modules/presubmit/tests/execute.py#29)(api, patch_project, patch_repository_url):**
&mdash; **def [RunSteps](/recipes/recipe_modules/presubmit/tests/execute.py#23)(api):**
### *recipes* / [presubmit:tests/prepare](/recipes/recipe_modules/presubmit/tests/prepare.py)
[DEPS](/recipes/recipe_modules/presubmit/tests/prepare.py#9): [gclient](#recipe_modules-gclient), [presubmit](#recipe_modules-presubmit), [recipe\_engine/buildbucket][recipe_engine/recipe_modules/buildbucket], [recipe\_engine/context][recipe_engine/recipe_modules/context], [recipe\_engine/path][recipe_engine/recipe_modules/path], [recipe\_engine/properties][recipe_engine/recipe_modules/properties], [recipe\_engine/runtime][recipe_engine/recipe_modules/runtime]

@ -74,11 +74,12 @@ class PresubmitApi(recipe_api.RecipeApi):
return bot_update_step
def execute(self, bot_update_step):
def execute(self, bot_update_step, skip_owners=False):
"""Runs presubmit and sets summary markdown if applicable.
Args:
bot_update_step: the StepResult from a previously executed bot_update step.
skip_owners: a boolean indicating whether Owners checks should be skipped.
Returns:
a RawResult object, suitable for being returned from RunSteps.
"""
@ -109,6 +110,11 @@ class PresubmitApi(recipe_api.RecipeApi):
'--upstream', upstream, # '' if not in bot_update mode.
])
if skip_owners:
presubmit_args.extend([
'--skip_canned', 'CheckOwners'
])
raw_result = result_pb2.RawResult()
step_json = self(
*presubmit_args,

@ -20,17 +20,12 @@ DEPS = [
]
PROPERTIES = {
'patch_project': recipe_api.Property(None),
'patch_repository_url': recipe_api.Property(None),
}
def RunSteps(api, patch_project, patch_repository_url):
def RunSteps(api):
api.gclient.set_config('infra')
with api.context(cwd=api.path['cache'].join('builder')):
bot_update_step = api.presubmit.prepare()
return api.presubmit.execute(bot_update_step)
skip_owners = api.properties.get('skip_owners', False)
return api.presubmit.execute(bot_update_step, skip_owners)
def GenTests(api):
@ -56,6 +51,17 @@ def GenTests(api):
api.post_process(post_process.DropExpectation)
)
yield (
api.test('skip_owners') +
api.runtime(is_experimental=False, is_luci=True) +
api.buildbucket.try_build(project='infra') +
api.properties(skip_owners=True) +
api.post_process(post_process.StatusSuccess) +
api.post_process(
post_process.StepCommandContains, 'presubmit', ['--skip_canned', 'CheckOwners']) +
api.post_process(post_process.DropExpectation)
)
yield (
api.test('timeout') +
api.runtime(is_experimental=False, is_luci=True) +

Loading…
Cancel
Save