diff --git a/recipe_modules/gclient/api.py b/recipe_modules/gclient/api.py index ecd0d94ff..df921691f 100644 --- a/recipe_modules/gclient/api.py +++ b/recipe_modules/gclient/api.py @@ -117,7 +117,7 @@ class GclientApi(recipe_api.RecipeApi): def get_config_defaults(self): return { 'USE_MIRROR': self.use_mirror, - 'CACHE_DIR': self.m.path['git_cache'], + 'CACHE_DIR': self.m.infra_paths.default_git_cache_dir, } @staticmethod diff --git a/recipe_modules/git/api.py b/recipe_modules/git/api.py index 9f2b5843f..8c48e5edb 100644 --- a/recipe_modules/git/api.py +++ b/recipe_modules/git/api.py @@ -215,13 +215,15 @@ class GitApi(recipe_api.RecipeApi): if use_git_cache: with self.m.step.context({'env': {'PATH': path}}): - self('retry', 'cache', 'populate', '-c', self.m.path['git_cache'], url, + self('retry', 'cache', 'populate', '-c', + self.m.infra_paths.default_git_cache_dir, url, + name='populate cache', can_fail_build=can_fail_build, cwd=dir_path) dir_cmd = self( 'cache', 'exists', '--quiet', - '--cache-dir', self.m.path['git_cache'], url, + '--cache-dir', self.m.infra_paths.default_git_cache_dir, url, can_fail_build=can_fail_build, stdout=self.m.raw_io.output(), step_test_data=lambda: diff --git a/recipe_modules/infra_paths/api.py b/recipe_modules/infra_paths/api.py index cad3f28b4..e6272c807 100644 --- a/recipe_modules/infra_paths/api.py +++ b/recipe_modules/infra_paths/api.py @@ -6,7 +6,23 @@ from recipe_engine import recipe_api class InfraPathsApi(recipe_api.RecipeApi): + """infra_paths module is glue for design mistakes. It will be removed.""" + def initialize(self): # TODO(phajdan.jr): remove dupes from the engine and delete infra_ prefix. self.m.path.set_config( 'infra_' + self.m.properties.get('path_config', 'buildbot')) + + @property + def default_git_cache_dir(self): + """Returns the location of the default git cache directory. + + This property should be used instead of using path['git_cache'] directly. + + It returns git_cache path if it is defined (Buildbot world), otherwise + uses the more generic [CACHE]/git path (LUCI world). + """ + try: + return self.m.path['git_cache'] + except KeyError: # pragma: no cover | TODO(nodir): cover + return self.m.path['cache'].join('git') diff --git a/recipe_modules/infra_paths/example.expected/basic.json b/recipe_modules/infra_paths/example.expected/basic.json index 75aa33833..02ec764ee 100644 --- a/recipe_modules/infra_paths/example.expected/basic.json +++ b/recipe_modules/infra_paths/example.expected/basic.json @@ -3,7 +3,9 @@ "cmd": [], "name": "show cache path", "~followup_annotations": [ - "@@@STEP_TEXT@[CACHE]@@@" + "@@@STEP_LOG_LINE@result@[CACHE]@@@", + "@@@STEP_LOG_LINE@result@[GIT_CACHE]@@@", + "@@@STEP_LOG_END@result@@@" ] }, { diff --git a/recipe_modules/infra_paths/example.expected/paths_buildbot_linux.json b/recipe_modules/infra_paths/example.expected/paths_buildbot_linux.json index 75aa33833..02ec764ee 100644 --- a/recipe_modules/infra_paths/example.expected/paths_buildbot_linux.json +++ b/recipe_modules/infra_paths/example.expected/paths_buildbot_linux.json @@ -3,7 +3,9 @@ "cmd": [], "name": "show cache path", "~followup_annotations": [ - "@@@STEP_TEXT@[CACHE]@@@" + "@@@STEP_LOG_LINE@result@[CACHE]@@@", + "@@@STEP_LOG_LINE@result@[GIT_CACHE]@@@", + "@@@STEP_LOG_END@result@@@" ] }, { diff --git a/recipe_modules/infra_paths/example.expected/paths_buildbot_mac.json b/recipe_modules/infra_paths/example.expected/paths_buildbot_mac.json index 75aa33833..02ec764ee 100644 --- a/recipe_modules/infra_paths/example.expected/paths_buildbot_mac.json +++ b/recipe_modules/infra_paths/example.expected/paths_buildbot_mac.json @@ -3,7 +3,9 @@ "cmd": [], "name": "show cache path", "~followup_annotations": [ - "@@@STEP_TEXT@[CACHE]@@@" + "@@@STEP_LOG_LINE@result@[CACHE]@@@", + "@@@STEP_LOG_LINE@result@[GIT_CACHE]@@@", + "@@@STEP_LOG_END@result@@@" ] }, { diff --git a/recipe_modules/infra_paths/example.expected/paths_buildbot_win.json b/recipe_modules/infra_paths/example.expected/paths_buildbot_win.json index 75aa33833..02ec764ee 100644 --- a/recipe_modules/infra_paths/example.expected/paths_buildbot_win.json +++ b/recipe_modules/infra_paths/example.expected/paths_buildbot_win.json @@ -3,7 +3,9 @@ "cmd": [], "name": "show cache path", "~followup_annotations": [ - "@@@STEP_TEXT@[CACHE]@@@" + "@@@STEP_LOG_LINE@result@[CACHE]@@@", + "@@@STEP_LOG_LINE@result@[GIT_CACHE]@@@", + "@@@STEP_LOG_END@result@@@" ] }, { diff --git a/recipe_modules/infra_paths/example.expected/paths_kitchen_linux.json b/recipe_modules/infra_paths/example.expected/paths_kitchen_linux.json index 75aa33833..02ec764ee 100644 --- a/recipe_modules/infra_paths/example.expected/paths_kitchen_linux.json +++ b/recipe_modules/infra_paths/example.expected/paths_kitchen_linux.json @@ -3,7 +3,9 @@ "cmd": [], "name": "show cache path", "~followup_annotations": [ - "@@@STEP_TEXT@[CACHE]@@@" + "@@@STEP_LOG_LINE@result@[CACHE]@@@", + "@@@STEP_LOG_LINE@result@[GIT_CACHE]@@@", + "@@@STEP_LOG_END@result@@@" ] }, { diff --git a/recipe_modules/infra_paths/example.expected/paths_kitchen_mac.json b/recipe_modules/infra_paths/example.expected/paths_kitchen_mac.json index 75aa33833..02ec764ee 100644 --- a/recipe_modules/infra_paths/example.expected/paths_kitchen_mac.json +++ b/recipe_modules/infra_paths/example.expected/paths_kitchen_mac.json @@ -3,7 +3,9 @@ "cmd": [], "name": "show cache path", "~followup_annotations": [ - "@@@STEP_TEXT@[CACHE]@@@" + "@@@STEP_LOG_LINE@result@[CACHE]@@@", + "@@@STEP_LOG_LINE@result@[GIT_CACHE]@@@", + "@@@STEP_LOG_END@result@@@" ] }, { diff --git a/recipe_modules/infra_paths/example.expected/paths_kitchen_win.json b/recipe_modules/infra_paths/example.expected/paths_kitchen_win.json index 75aa33833..02ec764ee 100644 --- a/recipe_modules/infra_paths/example.expected/paths_kitchen_win.json +++ b/recipe_modules/infra_paths/example.expected/paths_kitchen_win.json @@ -3,7 +3,9 @@ "cmd": [], "name": "show cache path", "~followup_annotations": [ - "@@@STEP_TEXT@[CACHE]@@@" + "@@@STEP_LOG_LINE@result@[CACHE]@@@", + "@@@STEP_LOG_LINE@result@[GIT_CACHE]@@@", + "@@@STEP_LOG_END@result@@@" ] }, { diff --git a/recipe_modules/infra_paths/example.expected/paths_swarmbucket_linux.json b/recipe_modules/infra_paths/example.expected/paths_swarmbucket_linux.json index 75aa33833..02ec764ee 100644 --- a/recipe_modules/infra_paths/example.expected/paths_swarmbucket_linux.json +++ b/recipe_modules/infra_paths/example.expected/paths_swarmbucket_linux.json @@ -3,7 +3,9 @@ "cmd": [], "name": "show cache path", "~followup_annotations": [ - "@@@STEP_TEXT@[CACHE]@@@" + "@@@STEP_LOG_LINE@result@[CACHE]@@@", + "@@@STEP_LOG_LINE@result@[GIT_CACHE]@@@", + "@@@STEP_LOG_END@result@@@" ] }, { diff --git a/recipe_modules/infra_paths/example.expected/paths_swarmbucket_mac.json b/recipe_modules/infra_paths/example.expected/paths_swarmbucket_mac.json index 75aa33833..02ec764ee 100644 --- a/recipe_modules/infra_paths/example.expected/paths_swarmbucket_mac.json +++ b/recipe_modules/infra_paths/example.expected/paths_swarmbucket_mac.json @@ -3,7 +3,9 @@ "cmd": [], "name": "show cache path", "~followup_annotations": [ - "@@@STEP_TEXT@[CACHE]@@@" + "@@@STEP_LOG_LINE@result@[CACHE]@@@", + "@@@STEP_LOG_LINE@result@[GIT_CACHE]@@@", + "@@@STEP_LOG_END@result@@@" ] }, { diff --git a/recipe_modules/infra_paths/example.expected/paths_swarmbucket_win.json b/recipe_modules/infra_paths/example.expected/paths_swarmbucket_win.json index 75aa33833..02ec764ee 100644 --- a/recipe_modules/infra_paths/example.expected/paths_swarmbucket_win.json +++ b/recipe_modules/infra_paths/example.expected/paths_swarmbucket_win.json @@ -3,7 +3,9 @@ "cmd": [], "name": "show cache path", "~followup_annotations": [ - "@@@STEP_TEXT@[CACHE]@@@" + "@@@STEP_LOG_LINE@result@[CACHE]@@@", + "@@@STEP_LOG_LINE@result@[GIT_CACHE]@@@", + "@@@STEP_LOG_END@result@@@" ] }, { diff --git a/recipe_modules/infra_paths/example.py b/recipe_modules/infra_paths/example.py index 2cca4c791..6679aad5d 100644 --- a/recipe_modules/infra_paths/example.py +++ b/recipe_modules/infra_paths/example.py @@ -2,6 +2,8 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +import json + DEPS = [ 'infra_paths', 'recipe_engine/path', @@ -13,7 +15,10 @@ DEPS = [ def RunSteps(api): api.step('show cache path', []) - api.step.active_result.presentation.step_text = str(api.path['cache']) + api.step.active_result.presentation.logs['result'] = [ + str(api.path['cache']), + str(api.infra_paths.default_git_cache_dir), + ] def GenTests(api):