diff --git a/infra/config/recipes.cfg b/infra/config/recipes.cfg index ede4a1407..2dc1f0913 100644 --- a/infra/config/recipes.cfg +++ b/infra/config/recipes.cfg @@ -4,5 +4,5 @@ deps { project_id: "recipe_engine" url: "https://chromium.googlesource.com/external/github.com/luci/recipes-py.git" branch: "master" - revision: "d5a670b19aba7fb9a7f6430d39dab1d3414b578a" + revision: "57a75df505dfe20cb1aa6b7536231e56267fa2b8" } diff --git a/recipe_modules/bot_update/api.py b/recipe_modules/bot_update/api.py index 8d77cd90d..34414257c 100644 --- a/recipe_modules/bot_update/api.py +++ b/recipe_modules/bot_update/api.py @@ -33,16 +33,17 @@ class BotUpdateApi(recipe_api.RecipeApi): assert isinstance(cmd, (list, tuple)) bot_update_path = self.resource('bot_update.py') kwargs.setdefault('infra_step', True) - kwargs.setdefault('env', {}) - kwargs['env'].setdefault('PATH', '%(PATH)s') - kwargs['env']['PATH'] = self.m.path.pathsep.join([ - kwargs['env']['PATH'], str(self._module.PACKAGE_REPO_ROOT)]) + env = self.m.step.get_from_context('env', {}) + env.setdefault('PATH', '%(PATH)s') + env['PATH'] = self.m.path.pathsep.join([ + env['PATH'], str(self._module.PACKAGE_REPO_ROOT)]) # These are to prevent git from hanging. If the git connection is slower # than 1KB/s for more than 5 minutes then git will kill the connection # and die with an error "error: RPC failed; curl 28 Operation too slow" - kwargs['env']['GIT_HTTP_LOW_SPEED_LIMIT'] = 1000 - kwargs['env']['GIT_HTTP_LOW_SPEED_TIME'] = 300 - return self.m.python(name, bot_update_path, cmd, **kwargs) + env['GIT_HTTP_LOW_SPEED_LIMIT'] = 1000 + env['GIT_HTTP_LOW_SPEED_TIME'] = 300 + with self.m.step.context({'env': env}): + return self.m.python(name, bot_update_path, cmd, **kwargs) @property def last_returned_properties(self): @@ -54,9 +55,10 @@ class BotUpdateApi(recipe_api.RecipeApi): gerrit_no_rebase_patch_ref=False, **kwargs): apply_gerrit_path = self.resource('apply_gerrit.py') kwargs.setdefault('infra_step', True) - kwargs.setdefault('env', {}).setdefault('PATH', '%(PATH)s') - kwargs['env']['PATH'] = self.m.path.pathsep.join([ - kwargs['env']['PATH'], str(self._module.PACKAGE_REPO_ROOT)]) + env = self.m.step.get_from_context('env', {}) + env.setdefault('PATH', '%(PATH)s') + env['PATH'] = self.m.path.pathsep.join([ + env['PATH'], str(self._module.PACKAGE_REPO_ROOT)]) cmd = [ '--gerrit_repo', self._repository, '--gerrit_ref', self._gerrit_ref or '', @@ -66,7 +68,8 @@ class BotUpdateApi(recipe_api.RecipeApi): cmd.append('--gerrit_no_reset') if gerrit_no_rebase_patch_ref: cmd.append('--gerrit_no_rebase_patch_ref') - return self.m.python('apply_gerrit', apply_gerrit_path, cmd, **kwargs) + with self.m.step.context({'env': env}): + return self.m.python('apply_gerrit', apply_gerrit_path, cmd, **kwargs) def ensure_checkout(self, gclient_config=None, suffix=None, patch=True, update_presentation=True, diff --git a/recipe_modules/gclient/api.py b/recipe_modules/gclient/api.py index 51fe621a3..744f95233 100644 --- a/recipe_modules/gclient/api.py +++ b/recipe_modules/gclient/api.py @@ -79,16 +79,18 @@ class GclientApi(recipe_api.RecipeApi): if self.spec_alias: prefix = ('[spec: %s] ' % self.spec_alias) + prefix - kwargs.setdefault('env', {}) - kwargs['env'].setdefault('PATH', '%(PATH)s') - kwargs['env']['PATH'] = self.m.path.pathsep.join([ - kwargs['env']['PATH'], str(self._module.PACKAGE_REPO_ROOT)]) - - return self.m.python(prefix + name, - self.package_repo_resource('gclient.py'), - cmd, - infra_step=infra_step, - **kwargs) + # TODO(phajdan.jr): create a helper for adding to PATH. + env = self.m.step.get_from_context('env', {}) + env.setdefault('PATH', '%(PATH)s') + env['PATH'] = self.m.path.pathsep.join([ + env['PATH'], str(self._module.PACKAGE_REPO_ROOT)]) + + with self.m.step.context({'env': env}): + return self.m.python(prefix + name, + self.package_repo_resource('gclient.py'), + cmd, + infra_step=infra_step, + **kwargs) @property def use_mirror(self): diff --git a/recipe_modules/gerrit/__init__.py b/recipe_modules/gerrit/__init__.py index 12ee27476..864bbbfba 100644 --- a/recipe_modules/gerrit/__init__.py +++ b/recipe_modules/gerrit/__init__.py @@ -3,4 +3,5 @@ DEPS = [ 'recipe_engine/path', 'recipe_engine/python', 'recipe_engine/raw_io', + 'recipe_engine/step', ] diff --git a/recipe_modules/gerrit/api.py b/recipe_modules/gerrit/api.py index 3c63aed95..194f20ac3 100644 --- a/recipe_modules/gerrit/api.py +++ b/recipe_modules/gerrit/api.py @@ -12,16 +12,17 @@ class GerritApi(recipe_api.RecipeApi): assert isinstance(cmd, (list, tuple)) prefix = 'gerrit ' - kwargs.setdefault('env', {}) - kwargs['env'].setdefault('PATH', '%(PATH)s') - kwargs['env']['PATH'] = self.m.path.pathsep.join([ - kwargs['env']['PATH'], str(self._module.PACKAGE_REPO_ROOT)]) - - return self.m.python(prefix + name, - self.package_repo_resource('gerrit_client.py'), - cmd, - infra_step=infra_step, - **kwargs) + env = self.m.step.get_from_context('env', {}) + env.setdefault('PATH', '%(PATH)s') + env['PATH'] = self.m.path.pathsep.join([ + env['PATH'], str(self._module.PACKAGE_REPO_ROOT)]) + + with self.m.step.context({'env': env}): + return self.m.python(prefix + name, + self.package_repo_resource('gerrit_client.py'), + cmd, + infra_step=infra_step, + **kwargs) def create_gerrit_branch(self, host, project, branch, commit, **kwargs): """ diff --git a/recipe_modules/git/api.py b/recipe_modules/git/api.py index 6faf2ba02..76656a3ca 100644 --- a/recipe_modules/git/api.py +++ b/recipe_modules/git/api.py @@ -278,11 +278,11 @@ class GitApi(recipe_api.RecipeApi): name='count-objects before %s' % fetch_step_name, step_test_data=lambda: self.m.raw_io.test_api.stream_output( self.test_api.count_objects_output(1000))) - self('retry', 'fetch', *fetch_args, - name=fetch_step_name, - env=fetch_env, - stderr=fetch_stderr, - can_fail_build=can_fail_build) + with self.m.step.context({'env': fetch_env}): + self('retry', 'fetch', *fetch_args, + name=fetch_step_name, + stderr=fetch_stderr, + can_fail_build=can_fail_build) if display_fetch_size: self.count_objects( name='count-objects after %s' % fetch_step_name, @@ -413,7 +413,7 @@ class GitApi(recipe_api.RecipeApi): upstream (str): to origin/master. kwargs: Forwarded to '__call__'. """ - env = kwargs.pop('env', {}) + env = self.m.step.get_from_context('env', {}) env['PATH'] = self.m.path.pathsep.join([ str(self.package_repo_resource()), '%(PATH)s']) args = ['new-branch', branch] @@ -421,4 +421,5 @@ class GitApi(recipe_api.RecipeApi): args.extend(['--upstream', upstream]) if not name: name = 'git new-branch %s' % branch - return self(*args, name=name, env=env, **kwargs) + with self.m.step.context({'env': env}): + return self(*args, name=name, **kwargs) diff --git a/recipe_modules/presubmit/__init__.py b/recipe_modules/presubmit/__init__.py index 240b08c67..258f3c684 100644 --- a/recipe_modules/presubmit/__init__.py +++ b/recipe_modules/presubmit/__init__.py @@ -1,4 +1,5 @@ DEPS = [ 'recipe_engine/path', 'recipe_engine/python', + 'recipe_engine/step', ] diff --git a/recipe_modules/presubmit/api.py b/recipe_modules/presubmit/api.py index 31fe1d976..760ebefd8 100644 --- a/recipe_modules/presubmit/api.py +++ b/recipe_modules/presubmit/api.py @@ -14,10 +14,11 @@ class PresubmitApi(recipe_api.RecipeApi): name = kwargs.pop('name', 'presubmit') - kwargs.setdefault('env', {}) - kwargs['env'].setdefault('PATH', '%(PATH)s') - kwargs['env']['PATH'] = self.m.path.pathsep.join([ - kwargs['env']['PATH'], str(self._module.PACKAGE_REPO_ROOT)]) + env = self.m.step.get_from_context('env', {}) + env.setdefault('PATH', '%(PATH)s') + env['PATH'] = self.m.path.pathsep.join([ + env['PATH'], str(self._module.PACKAGE_REPO_ROOT)]) - return self.m.python( - name, self.presubmit_support_path, list(args), **kwargs) + with self.m.step.context({'env': env}): + return self.m.python( + name, self.presubmit_support_path, list(args), **kwargs)