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

Optimize disk space usage for planemo test #1378

Merged
merged 6 commits into from
Jul 20, 2023
Merged
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
9 changes: 6 additions & 3 deletions planemo/galaxy/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1230,9 +1230,12 @@ def _install_galaxy(ctx, galaxy_root, env, kwds):

def _install_galaxy_via_download(ctx, galaxy_root, env, kwds):
branch = _galaxy_branch(kwds)
source = _galaxy_source(kwds)
if source.startswith("https://github.com/"):
source = source[len("https://github.com/") :]
untar_to(
"https://codeload.github.com/galaxyproject/galaxy/tar.gz/" + branch,
tar_args=["-xvzf", "-", "galaxy-" + branch],
f"https://codeload.github.com/{source}/tar.gz/{branch}",
tar_args=["--strip-components", "1", "-xvzf", "-", "galaxy-" + branch.replace("/", "-")],
dest_dir=galaxy_root,
)
_install_with_command(ctx, galaxy_root, env, kwds)
Expand All @@ -1241,7 +1244,7 @@ def _install_galaxy_via_download(ctx, galaxy_root, env, kwds):
def _install_galaxy_via_git(ctx, galaxy_root, env, kwds):
gx_repo = _ensure_galaxy_repository_available(ctx, kwds)
branch = _galaxy_branch(kwds)
command = git.command_clone(ctx, gx_repo, galaxy_root, branch=branch)
command = git.command_clone(ctx, gx_repo, galaxy_root, branch=branch, depth=1)
exit_code = shell(command, env=env)
if exit_code != 0:
raise Exception("Failed to clone Galaxy via git")
Expand Down
12 changes: 11 additions & 1 deletion planemo/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import os
import subprocess
import urllib.parse
from typing import (
Dict,
List,
Expand Down Expand Up @@ -87,7 +88,12 @@ def checkout(ctx, remote_repo, local_path, branch=None, remote="origin", from_br


def command_clone(
ctx: "PlanemoCliContext", src: str, dest: str, mirror: bool = False, branch: Optional[str] = None
ctx: "PlanemoCliContext",
src: str,
dest: str,
mirror: bool = False,
branch: Optional[str] = None,
depth: Optional[int] = None,
) -> List[str]:
"""Produce a command-line string to clone a repository.

Expand All @@ -98,6 +104,10 @@ def command_clone(
cmd.append("--mirror")
if branch is not None:
cmd.extend(["--branch", branch])
if depth is not None:
cmd.extend(["--depth", str(depth)])
if urllib.parse.urlparse(src).scheme == "":
src = f"file://{src}"
cmd.extend([src, dest])
return cmd

Expand Down