Use new path module attributes

Bug: 329113288
Change-Id: Ib762c83c7558cd522e6bd3f78e2d38684ce82a76
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5444201
Commit-Queue: Robbie Iannucci <iannucci@chromium.org>
Reviewed-by: Robbie Iannucci <iannucci@chromium.org>
changes/01/5444201/3
Rob Mohr 1 year ago committed by LUCI CQ
parent a7c97f7871
commit 2f8f787dec

@ -72,7 +72,7 @@ class BotUpdateApi(recipe_api.RecipeApi):
def _get_bot_update_env(self):
# TODO(gavinmak): Use mkdtemp when crbug.com/1457059 is fixed.
self._trace_dir = self.m.path['cleanup']
self._trace_dir = self.m.path.cleanup_dir
# If a Git HTTP request is constantly below GIT_HTTP_LOW_SPEED_LIMIT
# bytes/second for GIT_HTTP_LOW_SPEED_TIME seconds then such request will be
@ -218,7 +218,7 @@ class BotUpdateApi(recipe_api.RecipeApi):
['--patch_root', patch_root],
['--revision_mapping_file', self.m.json.input(reverse_rev_map)],
['--git-cache-dir', cfg.cache_dir],
['--cleanup-dir', self.m.path['cleanup'].join('bot_update')],
['--cleanup-dir', self.m.path.cleanup_dir.join('bot_update')],
# Hookups to JSON output back into recipes.
['--output_json', self.m.json.output()],
@ -488,8 +488,8 @@ class BotUpdateApi(recipe_api.RecipeApi):
and 'checkout' not in self.m.path
and 'root' in result):
co_root = result['root']
cwd = self.m.context.cwd or self.m.path['start_dir']
self.m.path['checkout'] = cwd.join(*co_root.split(self.m.path.sep))
cwd = self.m.context.cwd or self.m.path.start_dir
self.m.path.checkout_dir = cwd.join(*co_root.split(self.m.path.sep))
return step_result

@ -28,7 +28,7 @@ def RunSteps(api):
api.gclient.use_mirror = True
commit = api.buildbucket.build.input.gitiles_commit
src_cfg = api.gclient.make_config(CACHE_DIR=api.path['cache'].join('git'))
src_cfg = api.gclient.make_config(CACHE_DIR=api.path.cache_dir.join('git'))
soln = src_cfg.solutions.add()
soln.name = 'src'
soln.url = 'https://chromium.googlesource.com/chromium/src.git'

@ -127,7 +127,7 @@ class GclientApi(recipe_api.RecipeApi):
def get_config_defaults(self):
return {
'USE_MIRROR': self.use_mirror,
'CACHE_DIR': self.m.path['cache'].join('git'),
'CACHE_DIR': self.m.path.cache_dir.join('git'),
}
@staticmethod
@ -271,9 +271,9 @@ class GclientApi(recipe_api.RecipeApi):
name = 'recurse (git config %s)' % var
self(name, ['recurse', 'git', 'config', var, val], **kwargs)
finally:
cwd = self.m.context.cwd or self.m.path['start_dir']
cwd = self.m.context.cwd or self.m.path.start_dir
if 'checkout' not in self.m.path:
self.m.path['checkout'] = cwd.join(
self.m.path.checkout_dir = cwd.join(
*cfg.solutions[0].name.split(self.m.path.sep))
return sync_step
@ -281,14 +281,14 @@ class GclientApi(recipe_api.RecipeApi):
def runhooks(self, args=None, name='runhooks', **kwargs):
args = args or []
assert isinstance(args, (list, tuple))
with self.m.context(cwd=(self.m.context.cwd or self.m.path['checkout'])):
with self.m.context(cwd=(self.m.context.cwd or self.m.path.checkout_dir)):
return self(name, ['runhooks'] + list(args), infra_step=False, **kwargs)
def break_locks(self):
"""Remove all index.lock files. If a previous run of git crashed, bot was
reset, etc... we might end up with leftover index.lock files.
"""
cmd = ['python3', '-u', self.resource('cleanup.py'), self.m.path['start_dir']]
cmd = ['python3', '-u', self.resource('cleanup.py'), self.m.path.start_dir]
return self.m.step('cleanup index.lock', cmd)
def get_gerrit_patch_root(self, gclient_config=None):

@ -91,7 +91,7 @@ def RunSteps(api):
for config_name in TEST_CONFIGS:
api.gclient.make_config(config_name)
src_cfg = api.gclient.make_config(CACHE_DIR=api.path['cache'].join('git'))
src_cfg = api.gclient.make_config(CACHE_DIR=api.path.cache_dir.join('git'))
soln = src_cfg.solutions.add()
soln.name = 'src'
soln.url = 'https://chromium.googlesource.com/chromium/src.git'
@ -109,7 +109,7 @@ def RunSteps(api):
bl_cfg.revisions['src/third_party/angle'] = 'refs/heads/lkgr'
bl_cfg.got_revision_mapping['src/blatley'] = 'got_blatley_revision'
with api.context(cwd=api.path['start_dir'].join('src', 'third_party')):
with api.context(cwd=api.path.start_dir.join('src', 'third_party')):
api.gclient.checkout(
gclient_config=bl_cfg)

@ -19,7 +19,7 @@ DEPS = [
]
def RunSteps(api):
src_cfg = api.gclient.make_config(CACHE_DIR=api.path['cache'].join('git'))
src_cfg = api.gclient.make_config(CACHE_DIR=api.path.cache_dir.join('git'))
soln = src_cfg.solutions.add()
soln.name = 'src'
@ -33,7 +33,7 @@ def RunSteps(api):
})
api.gclient.c = src_cfg
affected_files = api.gclient.diff_deps(api.path['cache'])
affected_files = api.gclient.diff_deps(api.path.cache_dir)
api.assertions.assertEqual(
affected_files,

@ -18,7 +18,7 @@ DEPS = [
def RunSteps(api):
src_cfg = api.gclient.make_config(CACHE_DIR=api.path['cache'].join('git'))
src_cfg = api.gclient.make_config(CACHE_DIR=api.path.cache_dir.join('git'))
soln = src_cfg.solutions.add()
soln.name = 'src'
soln.url = 'https://chromium.googlesource.com/chromium/src.git'

@ -13,7 +13,7 @@ DEPS = [
]
def RunSteps(api):
src_cfg = api.gclient.make_config(CACHE_DIR=api.path['cache'].join('git'))
src_cfg = api.gclient.make_config(CACHE_DIR=api.path.cache_dir.join('git'))
api.gclient.sync(src_cfg)
def GenTests(api):

@ -21,7 +21,7 @@ class GitApi(recipe_api.RecipeApi):
options = kwargs.pop('git_config_options', {})
for k, v in sorted(options.items()):
git_cmd.extend(['-c', '%s=%s' % (k, v)])
with self.m.context(cwd=(self.m.context.cwd or self.m.path['checkout'])):
with self.m.context(cwd=(self.m.context.cwd or self.m.path.checkout_dir)):
return self.m.step(name, git_cmd + list(args), infra_step=infra_step,
**kwargs)
@ -178,10 +178,10 @@ class GitApi(recipe_api.RecipeApi):
# ex: ssh://host:repo/foobar/.git
dir_path = dir_path or dir_path.rsplit('/', 1)[-1]
dir_path = self.m.path['start_dir'].join(dir_path)
dir_path = self.m.path.start_dir.join(dir_path)
if 'checkout' not in self.m.path:
self.m.path['checkout'] = dir_path
self.m.path.checkout_dir = dir_path
git_setup_args = ['--path', dir_path, '--url', url]
@ -203,12 +203,12 @@ class GitApi(recipe_api.RecipeApi):
if use_git_cache:
with self.m.context(env={'PATH': path}):
self('cache', 'populate', '-c',
self.m.path['cache'].join('git'), url,
self.m.path.cache_dir.join('git'), url,
name='populate cache',
raise_on_failure=raise_on_failure)
dir_cmd = self(
'cache', 'exists', '--quiet',
'--cache-dir', self.m.path['cache'].join('git'), url,
'--cache-dir', self.m.path.cache_dir.join('git'), url,
raise_on_failure=raise_on_failure,
stdout=self.m.raw_io.output(),
step_test_data=lambda:

@ -24,7 +24,7 @@ def RunSteps(api):
# useful for debugging git access issues that are reproducible only on bots.
curl_trace_file = None
if api.properties.get('use_curl_trace'):
curl_trace_file = api.path['start_dir'].join('curl_trace.log')
curl_trace_file = api.path.start_dir.join('curl_trace.log')
submodule_update_force = api.properties.get('submodule_update_force', False)
submodule_update_recursive = api.properties.get('submodule_update_recursive',
@ -68,7 +68,7 @@ def RunSteps(api):
# If you need to run more arbitrary git commands, you can use api.git itself,
# which behaves like api.step(), but automatically sets the name of the step.
with api.context(cwd=api.path['checkout']):
with api.context(cwd=api.path.checkout_dir):
api.git('status')
api.git('status', name='git status can_fail_build', raise_on_failure=True)
@ -86,7 +86,7 @@ def RunSteps(api):
api.git.new_branch('track_current', upstream_current=True)
# You can use api.git.rebase to rebase the current branch onto another one
api.git.rebase(name_prefix='my repo', branch='origin/main',
dir_path=api.path['checkout'],
dir_path=api.path.checkout_dir,
remote_name=api.properties.get('remote_name'))
if api.properties.get('cat_file', None):
@ -98,7 +98,7 @@ def RunSteps(api):
# Bundle the repository.
api.git.bundle_create(
api.path['start_dir'].join('all.bundle'))
api.path.start_dir.join('all.bundle'))
def GenTests(api):

@ -16,7 +16,7 @@ DEPS = [
def RunSteps(api):
# Set the checkout_dir because the `git` module implicitly uses this.
api.path.checkout_dir = api.path['cache'].join('builder')
api.path.checkout_dir = api.path.cache_dir.join('builder')
numbers = api.git.number(
commitrefs=api.properties.get('commitrefs'),

@ -30,10 +30,10 @@ def RunSteps(api):
data = api.gitiles.download_file(url, 'NONEXISTENT', attempts=1,
accept_statuses=[404])
api.gitiles.download_archive(url, api.path['start_dir'].join('archive'))
api.gitiles.download_archive(url, api.path.start_dir.join('archive'))
try:
api.gitiles.download_archive(url, api.path['start_dir'].join('archive2'))
api.gitiles.download_archive(url, api.path.start_dir.join('archive2'))
assert False # pragma: no cover
except api.step.StepFailure as ex:
assert '/root' in ex.gitiles_skipped_files

@ -12,7 +12,7 @@ DEPS = [
def RunSteps(api):
"""Move things around in a loop!"""
local_file = api.path['tmp_base'].join('boom')
local_file = api.path.tmp_base_dir.join('boom')
bucket = 'example'
cloud_file = 'some/random/path/to/boom'
@ -40,13 +40,13 @@ def RunSteps(api):
# Upload directory contents.
api.gsutil.upload(
api.path['tmp_base'],
api.path.tmp_base_dir,
bucket,
'some/random/path',
args=['-r'],
name='upload -r')
api.gsutil.upload(
api.path['tmp_base'],
api.path.tmp_base_dir,
bucket,
'some/other/random/path',
args=['--recursive'],
@ -75,7 +75,7 @@ def RunSteps(api):
pass
new_cloud_file = 'staging/to/boom'
new_local_file = api.path['tmp_base'].join('erang')
new_local_file = api.path.tmp_base_dir.join('erang')
api.gsutil.download(bucket, new_cloud_file, new_local_file)
private_key_file = 'path/to/key'

@ -125,7 +125,7 @@ class OSXSDKApi(recipe_api.RecipeApi):
"""Ensures the mac_toolchain tool and OS X SDK packages are installed.
Returns Path to the installed sdk app bundle."""
cache_dir = self.m.path['cache'].join('osx_sdk')
cache_dir = self.m.path.cache_dir.join('osx_sdk')
ef = self.m.cipd.EnsureFile()
ef.add_package(self._tool_pkg, self._tool_ver)

@ -95,7 +95,7 @@ class PresubmitApi(recipe_api.RecipeApi):
infra_step=False)
if self._runhooks:
with self.m.context(cwd=self.m.path['checkout']):
with self.m.context(cwd=self.m.path.checkout_dir):
self.m.gclient.runhooks()
return bot_update_step

@ -24,7 +24,7 @@ DEPS = [
def RunSteps(api):
api.gclient.set_config('infra')
with api.context(cwd=api.path['cache'].join('builder')):
with api.context(cwd=api.path.cache_dir.join('builder')):
bot_update_step = api.presubmit.prepare()
skip_owners = api.properties.get('skip_owners', False)
run_all = api.properties.get('run_all', False)

@ -27,7 +27,7 @@ PROPERTIES = {
def RunSteps(api, patch_project, patch_repository_url):
api.gclient.set_config('infra')
with api.context(cwd=api.path['cache'].join('builder')):
with api.context(cwd=api.path.cache_dir.join('builder')):
bot_update_step = api.presubmit.prepare()

@ -244,7 +244,7 @@ class TryserverApi(recipe_api.RecipeApi):
Returned paths will be relative to to api.path['root'].
"""
cwd = self.m.context.cwd or self.m.path['start_dir'].join(patch_root)
cwd = self.m.context.cwd or self.m.path.start_dir.join(patch_root)
with self.m.context(cwd=cwd):
step_result = self.m.git(
'-c', 'core.quotePath=false', 'diff', '--cached', '--name-only',

@ -20,7 +20,7 @@ from PB.go.chromium.org.luci.buildbucket.proto.common import GerritChange
def RunSteps(api):
api.path['checkout'] = api.path['start_dir']
api.path.checkout_dir = api.path.start_dir
if api.properties.get('patch_text'):
api.step('patch_text test', [
'echo', str(api.tryserver.get_footers(api.properties['patch_text']))])

@ -53,7 +53,7 @@ class WindowsSDKApi(recipe_api.RecipeApi):
"""
if enabled:
sdk_dir = self._ensure_sdk(
path or self.m.path['cache'].join('windows_sdk'),
path or self.m.path.cache_dir.join('windows_sdk'),
version or self._sdk_properties['version'])
try:
with self.m.context(**self._sdk_env(sdk_dir, target_arch)):

Loading…
Cancel
Save