From ff416a73fbe00d95b178829c4a95140f2d998c49 Mon Sep 17 00:00:00 2001 From: Nodir Turakulov Date: Thu, 17 Nov 2016 15:14:39 -0800 Subject: [PATCH] deprecate build path Update recipe modules that use path "build" to either check whether it is defined or fail with an explanation if it is not defined. This CL marks failure code paths as `# pragma: no cover`. This comment will be removed in https://chromium-review.googlesource.com/c/411989/ R=iannucci@chromium.org, martiniss@chromium.org BUG=662586 Change-Id: Ieb7637deefa6e366dfe4c30c7711d60daa06575a Reviewed-on: https://chromium-review.googlesource.com/412225 Commit-Queue: Nodir Turakulov Reviewed-by: Robbie Iannucci --- recipe_modules/bot_update/api.py | 13 +++++++++---- recipe_modules/rietveld/api.py | 17 ++++++++++------- recipe_modules/tryserver/api.py | 10 +++++++++- 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/recipe_modules/bot_update/api.py b/recipe_modules/bot_update/api.py index c2ab39803..706466545 100644 --- a/recipe_modules/bot_update/api.py +++ b/recipe_modules/bot_update/api.py @@ -143,10 +143,15 @@ class BotUpdateApi(recipe_api.RecipeApi): elif patch_oauth2: # TODO(martiniss): remove this hack :(. crbug.com/624212 if use_site_config_creds: - email_file = self.m.path['build'].join( - 'site_config', '.rietveld_client_email') - key_file = self.m.path['build'].join( - 'site_config', '.rietveld_secret_key') + try: + build_path = self.m.path['build'] + except KeyError: # pragma: no cover | TODO(nodir): cover + raise self.m.step.StepFailure( + 'build path is not defined. This is normal for LUCI builds. ' + 'In LUCI, use_site_config_creds parameter of ' + 'bot_update.ensure_checkout is not supported') + email_file = build_path.join('site_config', '.rietveld_client_email') + key_file = build_path.join('site_config', '.rietveld_secret_key') else: #pragma: no cover #TODO(martiniss): make this use path.join, so it works on windows email_file = '/creds/rietveld/client_email' diff --git a/recipe_modules/rietveld/api.py b/recipe_modules/rietveld/api.py index e563b18d6..9d250fe1e 100644 --- a/recipe_modules/rietveld/api.py +++ b/recipe_modules/rietveld/api.py @@ -65,6 +65,12 @@ class RietveldApi(recipe_api.RecipeApi): issue_number = self.m.properties['issue'] if authentication == 'oauth2': + try: + build_path = self.m.path['build'] + except KeyError: # pragma: no cover | TODO(nodir): cover + raise self.m.step.StepFailure( + 'build path is not defined. This is typical for LUCI builds. ' + 'LUCI does not support rietveld.apply_issue; use bot_update instead') step_result = self.m.python( 'apply_issue', self.package_repo_resource('apply_issue.py'), [ @@ -72,13 +78,10 @@ class RietveldApi(recipe_api.RecipeApi): '-i', issue_number, '-p', self.m.properties['patchset'], '-s', rietveld_url, - '-E', self.m.path['build'].join('site_config', - '.rietveld_client_email'), - '-k', self.m.path['build'].join('site_config', - '.rietveld_secret_key') - ], - ) - + '-E', build_path.join('site_config', '.rietveld_client_email'), + '-k', build_path.join('site_config', '.rietveld_secret_key'), + ], + ) else: step_result = self.m.python( 'apply_issue', diff --git a/recipe_modules/tryserver/api.py b/recipe_modules/tryserver/api.py index 1edb1634d..f50f2dfe7 100644 --- a/recipe_modules/tryserver/api.py +++ b/recipe_modules/tryserver/api.py @@ -104,7 +104,15 @@ class TryserverApi(recipe_api.RecipeApi): patch_ref = self.m.properties['patch_ref'] patch_dir = self.m.path.mkdtemp('patch') - git_setup_py = self.m.path['build'].join('scripts', 'slave', 'git_setup.py') + try: + build_path = self.m.path['build'] + except KeyError: # pragma: no cover | TODO(nodir): cover + raise self.m.step.StepFailure( + 'path["build"] is not defined. ' + 'Possibly this is a LUCI build. ' + 'tryserver.apply_from_git is not supported in LUCI builds.') + + git_setup_py = build_path.join('scripts', 'slave', 'git_setup.py') git_setup_args = ['--path', patch_dir, '--url', patch_repo_url] patch_path = patch_dir.join('patch.diff')