diff --git a/recipes/README.recipes.md b/recipes/README.recipes.md index 9b2506778..e081c8a5d 100644 --- a/recipes/README.recipes.md +++ b/recipes/README.recipes.md @@ -758,7 +758,7 @@ Raises: — **def [initialize](/recipes/recipe_modules/osx_sdk/api.py#48)(self):** ### *recipe_modules* / [presubmit](/recipes/recipe_modules/presubmit) -[DEPS](/recipes/recipe_modules/presubmit/__init__.py#13): [bot\_update](#recipe_modules-bot_update), [depot\_tools](#recipe_modules-depot_tools), [gclient](#recipe_modules-gclient), [git](#recipe_modules-git), [tryserver](#recipe_modules-tryserver), [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/resultdb][recipe_engine/recipe_modules/resultdb], [recipe\_engine/step][recipe_engine/recipe_modules/step] +[DEPS](/recipes/recipe_modules/presubmit/__init__.py#13): [bot\_update](#recipe_modules-bot_update), [depot\_tools](#recipe_modules-depot_tools), [gclient](#recipe_modules-gclient), [git](#recipe_modules-git), [tryserver](#recipe_modules-tryserver), [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/resultdb][recipe_engine/recipe_modules/resultdb], [recipe\_engine/step][recipe_engine/recipe_modules/step] PYTHON_VERSION_COMPATIBILITY: PY2+3 @@ -768,7 +768,7 @@ PYTHON_VERSION_COMPATIBILITY: PY2+3 Returns a presubmit step. -— **def [execute](/recipes/recipe_modules/presubmit/api.py#120)(self, bot_update_step, skip_owners=False, run_all=False):** +— **def [execute](/recipes/recipe_modules/presubmit/api.py#130)(self, bot_update_step, skip_owners=False, run_all=False):** Runs presubmit and sets summary markdown if applicable. @@ -779,7 +779,7 @@ Args: Returns: a RawResult object, suitable for being returned from RunSteps. -— **def [prepare](/recipes/recipe_modules/presubmit/api.py#68)(self, root_solution_revision=None):** +— **def [prepare](/recipes/recipe_modules/presubmit/api.py#78)(self, root_solution_revision=None):** Sets up a presubmit run. diff --git a/recipes/recipe_modules/presubmit/__init__.py b/recipes/recipe_modules/presubmit/__init__.py index 65a922cf2..aa38d5a45 100644 --- a/recipes/recipe_modules/presubmit/__init__.py +++ b/recipes/recipe_modules/presubmit/__init__.py @@ -15,6 +15,7 @@ DEPS = [ 'depot_tools', 'gclient', 'git', + 'recipe_engine/buildbucket', 'recipe_engine/context', 'recipe_engine/cq', 'recipe_engine/json', diff --git a/recipes/recipe_modules/presubmit/api.py b/recipes/recipe_modules/presubmit/api.py index c8ef47cfd..f9d4d109e 100644 --- a/recipes/recipe_modules/presubmit/api.py +++ b/recipes/recipe_modules/presubmit/api.py @@ -30,7 +30,17 @@ class PresubmitApi(recipe_api.RecipeApi): name = kwargs.pop('name', 'presubmit') with self.m.depot_tools.on_path(): - cmd = ['vpython', self.presubmit_support_path] + exe = 'vpython' + + # Use only vpython3 on bots that don't have vpython2 on the path any + # longer. + # TODO(https://crbug.com/1401307): Switch this to vpython3 premanently + # and remove py3 part below. + experiments = self.m.buildbucket.build.input.experiments + if 'luci.buildbucket.omit_python2' in experiments: + exe = 'vpython3' + + cmd = [exe, self.presubmit_support_path] cmd.extend(args) cmd.extend(['--json_output', self.m.json.output()]) if self.m.resultdb.enabled: diff --git a/recipes/recipe_modules/presubmit/tests/execute.py b/recipes/recipe_modules/presubmit/tests/execute.py index 50627a16d..97c0e7fcc 100644 --- a/recipes/recipe_modules/presubmit/tests/execute.py +++ b/recipes/recipe_modules/presubmit/tests/execute.py @@ -69,6 +69,14 @@ def GenTests(api): ['--skip_canned', 'CheckOwners']) + api.post_process(post_process.DropExpectation)) + yield (api.test('vpython3') + api.runtime(is_experimental=False) + + api.buildbucket.try_build( + project='infra', experiments=['luci.buildbucket.omit_python2']) + + api.post_process(post_process.StepCommandContains, 'presubmit', + ['vpython3']) + + api.post_process(post_process.StatusSuccess) + + api.post_process(post_process.DropExpectation)) + yield ( api.test('timeout') + api.runtime(is_experimental=False) + api.buildbucket.try_build(project='infra') +