Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Have komodo cli remove hidden release dir after rsync #509

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion komodo/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@ def rsync_komodo_to_destination(release_name: str, destination: str) -> None:
shell(f"mv {release_name} .{release_name}")
shell(f"rsync -a .{release_name} {destination}")


def move_old_release_from_release_path_if_exists(release_path: Path) -> None:
if release_path.exists():
shell(f"mv {str(release_path)} " f"{str(release_path)}.delete-{uuid.uuid4()}")
Expand All @@ -248,6 +247,7 @@ def delete_old_previously_moved_releases(prefix_path: Path, release_name: Path)
"rm -rf -- " + " ".join(release_dir_glob),
allow_failure=True,
)
shell(f"rm -rf .{release_name}")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unsure if this is necessary. In actual use we build in a tmpdir that gets deleted once the build has finished.
And I am not sure if this is the correct path to delete from? Apart from in the tests, I do not think that anyone actually build komodo locally.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a test for making sure it is the correct path.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, should we depend on the input directory being tmp/***, or should komodo cleanup after itself regardless?



def apply_fallback_tmpdir_for_pip_if_set(tmp_dir: Optional[str] = None):
Expand Down
27 changes: 24 additions & 3 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ def test_no_overwrite_by_default(tmpdir):
# Try another rerun after we have removed the downloads and remainder from
# failed build above:
shutil.rmtree(tmpdir / "downloads")
shutil.rmtree(tmpdir / ".existing_release")
with pytest.raises(RuntimeError, match="Only bleeding builds can be overwritten"):
cli_main()

Expand All @@ -167,7 +166,6 @@ def test_bleeding_overwrite_by_default(tmpdir):
cli_main()
# Remove non-interesting leftovers from first build:
shutil.rmtree(tmpdir / "downloads")
shutil.rmtree(tmpdir / ".some_bleeding_release")

# Assert that we can overwrite the build inside "some_bleeding_release"
cli_main()
Expand All @@ -191,7 +189,6 @@ def test_overwrite_if_option_is_set(tmpdir):
cli_main()
# Remove non-interesting leftovers from first build:
shutil.rmtree(tmpdir / "downloads")
shutil.rmtree(tmpdir / ".some_release")

# Assert that we can overwrite the build inside "some_release"
cli_main()
Expand Down Expand Up @@ -234,3 +231,27 @@ def count_release_folders_to_be_deleted() -> int:
assert count_release_folders_to_be_deleted() == len(test_dirs)
cli_main()
assert count_release_folders_to_be_deleted() == 0



def test_build_removes_hidden_directory_after_rsync(tmpdir):
sys.argv = [
"kmd",
"--workspace",
str(tmpdir),
os.path.join(_get_test_root(), "data/cli/minimal_release.yml"),
os.path.join(_get_test_root(), "data/cli/minimal_repository.yml"),
"--prefix",
"prefix",
"--release",
"some_bleeding_release",
"--extra-data-dirs", # Required to find test_python_builtin.sh.
os.path.join(_get_test_root(), "data/cli"),
]
cli_main()
# Remove non-interesting leftovers from first build:
assert not (tmpdir / ".some_bleeding_release").isdir()
shutil.rmtree(tmpdir / "downloads")

# Assert that we can overwrite the build inside "some_bleeding_release"
cli_main()
Loading