Move create_remote_dirs parameter to sync function
This commit is contained in:
parent
09c061e9b3
commit
fa7bfe1c5a
@ -78,11 +78,7 @@ def main():
|
|||||||
args = parse_args()
|
args = parse_args()
|
||||||
stages = set(args.stages) - set(args.skip_stages)
|
stages = set(args.stages) - set(args.skip_stages)
|
||||||
|
|
||||||
cb = cloud_build.CB(
|
cb = cloud_build.CB(config=args.config, tasks=args.tasks)
|
||||||
config=args.config,
|
|
||||||
tasks=args.tasks,
|
|
||||||
create_remote_dirs=args.create_remote_dirs,
|
|
||||||
)
|
|
||||||
if 'build' in stages:
|
if 'build' in stages:
|
||||||
no_tests = 'test' not in stages
|
no_tests = 'test' not in stages
|
||||||
cb.create_images(no_tests=no_tests)
|
cb.create_images(no_tests=no_tests)
|
||||||
@ -91,7 +87,7 @@ def main():
|
|||||||
if 'sign' in stages:
|
if 'sign' in stages:
|
||||||
cb.sign()
|
cb.sign()
|
||||||
if 'sync' in stages:
|
if 'sync' in stages:
|
||||||
cb.sync()
|
cb.sync(create_remote_dirs=args.create_remote_dirs)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
@ -54,13 +54,11 @@ class CB:
|
|||||||
config: str,
|
config: str,
|
||||||
*,
|
*,
|
||||||
data_dir: Optional[PathLike] = None,
|
data_dir: Optional[PathLike] = None,
|
||||||
create_remote_dirs: bool = False,
|
|
||||||
tasks: Optional[dict[str, List[str]]] = None,
|
tasks: Optional[dict[str, List[str]]] = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
self.initialized = False
|
self.initialized = False
|
||||||
self._save_cwd = os.getcwd()
|
self._save_cwd = os.getcwd()
|
||||||
self.parse_config(config)
|
self.parse_config(config)
|
||||||
self._create_remote_dirs = create_remote_dirs
|
|
||||||
if tasks is None:
|
if tasks is None:
|
||||||
self.tasks = {}
|
self.tasks = {}
|
||||||
else:
|
else:
|
||||||
@ -710,10 +708,10 @@ Dir::Etc::preferencesparts "/var/empty";
|
|||||||
host = remote[:colon]
|
host = remote[:colon]
|
||||||
self.call(['ssh', host, 'kick'])
|
self.call(['ssh', host, 'kick'])
|
||||||
|
|
||||||
def sync(self) -> None:
|
def sync(self, create_remote_dirs: bool = False) -> None:
|
||||||
for branch in self.branches:
|
for branch in self.branches:
|
||||||
remote = self.remote(branch)
|
remote = self.remote(branch)
|
||||||
if self._create_remote_dirs:
|
if create_remote_dirs:
|
||||||
os.makedirs(remote, exist_ok=True)
|
os.makedirs(remote, exist_ok=True)
|
||||||
cmd = [
|
cmd = [
|
||||||
'rsync',
|
'rsync',
|
||||||
|
@ -68,7 +68,6 @@ class TestErrors(TestCase):
|
|||||||
cloud_build = CB(
|
cloud_build = CB(
|
||||||
config='tests/test_try_build_all.yaml',
|
config='tests/test_try_build_all.yaml',
|
||||||
data_dir=self.kwargs['data_dir'],
|
data_dir=self.kwargs['data_dir'],
|
||||||
create_remote_dirs=True,
|
|
||||||
)
|
)
|
||||||
regex = r'build.*:'
|
regex = r'build.*:'
|
||||||
self.assertRaisesRegex(
|
self.assertRaisesRegex(
|
||||||
@ -86,7 +85,6 @@ class TestErrors(TestCase):
|
|||||||
cloud_build = CB(
|
cloud_build = CB(
|
||||||
config='tests/test_try_build_all.yaml',
|
config='tests/test_try_build_all.yaml',
|
||||||
data_dir=self.kwargs['data_dir'],
|
data_dir=self.kwargs['data_dir'],
|
||||||
create_remote_dirs=True,
|
|
||||||
)
|
)
|
||||||
regex = r'build.*:'
|
regex = r'build.*:'
|
||||||
self.assertRaisesRegex(
|
self.assertRaisesRegex(
|
||||||
@ -104,7 +102,6 @@ class TestErrors(TestCase):
|
|||||||
cloud_build = CB(
|
cloud_build = CB(
|
||||||
config='tests/test_not_try_build_all.yaml',
|
config='tests/test_not_try_build_all.yaml',
|
||||||
data_dir=self.kwargs['data_dir'],
|
data_dir=self.kwargs['data_dir'],
|
||||||
create_remote_dirs=True,
|
|
||||||
)
|
)
|
||||||
regex = r'build.*aarch64'
|
regex = r'build.*aarch64'
|
||||||
self.assertRaisesRegex(
|
self.assertRaisesRegex(
|
||||||
|
@ -26,12 +26,11 @@ class TestIntegrationImages(TestCase):
|
|||||||
cloud_build = CB(
|
cloud_build = CB(
|
||||||
config='tests/test_integration_images.yaml',
|
config='tests/test_integration_images.yaml',
|
||||||
data_dir=(cls.work_dir / 'cloud_build').as_posix(),
|
data_dir=(cls.work_dir / 'cloud_build').as_posix(),
|
||||||
create_remote_dirs=True,
|
|
||||||
)
|
)
|
||||||
cloud_build.create_images(no_tests=True)
|
cloud_build.create_images(no_tests=True)
|
||||||
cloud_build.copy_external_files()
|
cloud_build.copy_external_files()
|
||||||
cloud_build.sign()
|
cloud_build.sign()
|
||||||
cloud_build.sync()
|
cloud_build.sync(create_remote_dirs=True)
|
||||||
|
|
||||||
images_dir = cls.work_dir / 'images'
|
images_dir = cls.work_dir / 'images'
|
||||||
cls.images = {}
|
cls.images = {}
|
||||||
|
@ -25,12 +25,11 @@ class TestNoDelete(TestCase):
|
|||||||
cb = CB(
|
cb = CB(
|
||||||
config='tests/test_no_delete_false.yaml',
|
config='tests/test_no_delete_false.yaml',
|
||||||
data_dir=self.data_dir,
|
data_dir=self.data_dir,
|
||||||
create_remote_dirs=True,
|
|
||||||
)
|
)
|
||||||
other_file = self.images_dir / 'other_file.txt'
|
other_file = self.images_dir / 'other_file.txt'
|
||||||
other_file.write_text('Some text')
|
other_file.write_text('Some text')
|
||||||
cb.create_images(no_tests=True)
|
cb.create_images(no_tests=True)
|
||||||
cb.sync()
|
cb.sync(create_remote_dirs=True)
|
||||||
del cb
|
del cb
|
||||||
msg = 'Other files shoud be deleted if not no_delete'
|
msg = 'Other files shoud be deleted if not no_delete'
|
||||||
if other_file.exists():
|
if other_file.exists():
|
||||||
@ -41,12 +40,11 @@ class TestNoDelete(TestCase):
|
|||||||
cb = CB(
|
cb = CB(
|
||||||
config='tests/test_no_delete_true.yaml',
|
config='tests/test_no_delete_true.yaml',
|
||||||
data_dir=self.data_dir,
|
data_dir=self.data_dir,
|
||||||
create_remote_dirs=True,
|
|
||||||
)
|
)
|
||||||
other_file = self.images_dir / 'other_file.txt'
|
other_file = self.images_dir / 'other_file.txt'
|
||||||
other_file.write_text('Some text')
|
other_file.write_text('Some text')
|
||||||
cb.create_images(no_tests=True)
|
cb.create_images(no_tests=True)
|
||||||
cb.sync()
|
cb.sync(create_remote_dirs=True)
|
||||||
del cb
|
del cb
|
||||||
msg = 'Other files shoud not be deleted if no_delete'
|
msg = 'Other files shoud not be deleted if no_delete'
|
||||||
if not other_file.exists():
|
if not other_file.exists():
|
||||||
|
@ -22,7 +22,6 @@ class TestRebuild(TestCase):
|
|||||||
self.cb = CB(
|
self.cb = CB(
|
||||||
config='tests/test_rebuild.yaml',
|
config='tests/test_rebuild.yaml',
|
||||||
data_dir=self.data_dir,
|
data_dir=self.data_dir,
|
||||||
create_remote_dirs=True,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user