Add --force-rebuild flag
This commit is contained in:
parent
4498ec109e
commit
e20493f826
@ -57,6 +57,11 @@ def parse_args():
|
||||
action='store_true',
|
||||
help='create remote directories',
|
||||
)
|
||||
parser.add_argument(
|
||||
'--force-rebuild',
|
||||
action='store_true',
|
||||
help='forces rebuild',
|
||||
)
|
||||
parser.add_argument(
|
||||
'--no-tests',
|
||||
action='store_true',
|
||||
@ -86,6 +91,7 @@ def main():
|
||||
config=args.config,
|
||||
tasks=args.tasks,
|
||||
built_images_dir=args.built_images_dir,
|
||||
force_rebuild=args.force_rebuild,
|
||||
)
|
||||
|
||||
if 'build' in stages:
|
||||
|
@ -57,10 +57,13 @@ class CB:
|
||||
data_dir: Optional[PathLike] = None,
|
||||
tasks: Optional[dict[str, List[str]]] = None,
|
||||
built_images_dir: Optional[PathLike] = None,
|
||||
force_rebuild: bool = False,
|
||||
) -> None:
|
||||
self.initialized = False
|
||||
self._save_cwd = os.getcwd()
|
||||
self.parse_config(config)
|
||||
if force_rebuild:
|
||||
self.rebuild_after = datetime.timedelta(0)
|
||||
if tasks is None:
|
||||
self.tasks = {}
|
||||
else:
|
||||
|
@ -37,6 +37,20 @@ class TestRebuild(TestCase):
|
||||
with self.assertRaises(BuildError, msg=msg):
|
||||
self.cb.create_images(no_tests=True)
|
||||
|
||||
@mock.patch('subprocess.call', call.Call(decorators=DS))
|
||||
def test_do_force_rebuild(self):
|
||||
tarball = self.data_dir / 'out/docker_Sisyphus-x86_64.tar.xz'
|
||||
tarball.touch()
|
||||
del self.cb
|
||||
cb = CB(
|
||||
config='tests/test_rebuild.yaml',
|
||||
data_dir=self.data_dir,
|
||||
force_rebuild=True,
|
||||
)
|
||||
msg = 'Do not try to rebuild when force_rebuild'
|
||||
with self.assertRaises(BuildError, msg=msg):
|
||||
cb.create_images(no_tests=True)
|
||||
|
||||
@mock.patch('subprocess.call', call.Call(decorators=DS))
|
||||
def test_dont_rebuild(self):
|
||||
tarball = self.data_dir / 'out/docker_Sisyphus-x86_64.tar.xz'
|
||||
|
Loading…
Reference in New Issue
Block a user