From 1923d24c4f3cd38740ecfbf240b92d5eb1432e09 Mon Sep 17 00:00:00 2001 From: Yikun Jiang Date: Mon, 10 Apr 2023 17:47:51 +0800 Subject: [PATCH] feat: Add --mulled-conda-image (#867) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch try to add `--mulled-conda-image` to bioconda-utils, after this patch, users can specify customized mulled test image. Such as multi-arch case, users can sepcified multi-arch image. Related: https://github.com/bioconda/bioconda-utils/issues/706 Signed-off-by: Yikun Jiang Co-authored-by: Björn Grüning --- bioconda_utils/build.py | 12 ++++++++---- bioconda_utils/cli.py | 9 +++++++-- bioconda_utils/pkg_test.py | 1 - 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/bioconda_utils/build.py b/bioconda_utils/build.py index e09cf60db8..f3a27c6399 100644 --- a/bioconda_utils/build.py +++ b/bioconda_utils/build.py @@ -50,7 +50,8 @@ def build(recipe: str, pkg_paths: List[str] = None, channels: List[str] = None, docker_builder: docker_utils.RecipeBuilder = None, raise_error: bool = False, - linter=None) -> BuildResult: + linter=None, + mulled_conda_image: str = pkg_test.MULLED_CONDA_IMAGE) -> BuildResult: """ Build a single recipe for a single env @@ -149,7 +150,8 @@ def build(recipe: str, pkg_paths: List[str] = None, mulled_images = [] for pkg_path in pkg_paths: try: - pkg_test.test_package(pkg_path, base_image=base_image) + pkg_test.test_package(pkg_path, base_image=base_image, + conda_image=mulled_conda_image) except sp.CalledProcessError: logger.error('TEST FAILED: %s', recipe) return BuildResult(False, None) @@ -225,7 +227,8 @@ def build_recipes(recipe_folder: str, config_path: str, recipes: List[str], lint_exclude: List[str] = None, n_workers: int = 1, worker_offset: int = 0, - keep_old_work: bool = False): + keep_old_work: bool = False, + mulled_conda_image: str = pkg_test.MULLED_CONDA_IMAGE): """ Build one or many bioconda packages. @@ -343,7 +346,8 @@ def build_recipes(recipe_folder: str, config_path: str, recipes: List[str], mulled_test=mulled_test, channels=config['channels'], docker_builder=docker_builder, - linter=linter) + linter=linter, + mulled_conda_image=mulled_conda_image) if not res.success: failed.append(recipe) diff --git a/bioconda_utils/cli.py b/bioconda_utils/cli.py index cb17c24c78..b74701e4eb 100644 --- a/bioconda_utils/cli.py +++ b/bioconda_utils/cli.py @@ -35,6 +35,7 @@ from . import cran_skeleton from . import update_pinnings from . import graph +from . import pkg_test from .githandler import BiocondaRepo, install_gpg_key logger = logging.getLogger(__name__) @@ -379,6 +380,8 @@ def do_lint(recipe_folder, config, packages="*", cache=None, list_checks=False, help='Build packages in docker container.') @arg('--mulled-test', action='store_true', help="Run a mulled-build test on the built package") @arg('--mulled-upload-target', help="Provide a quay.io target to push mulled docker images to.") +@arg('--mulled-conda-image', help='''Conda Docker image to install the package with during + the mulled based tests.''') @arg('--build_script_template', help='''Filename to optionally replace build script template used by the Docker container. By default use docker_utils.BUILD_SCRIPT_TEMPLATE. Only used if --docker is True.''') @@ -428,7 +431,8 @@ def build(recipe_folder, config, packages="*", git_range=None, testonly=False, force=False, docker=None, mulled_test=False, build_script_template=None, pkg_dir=None, anaconda_upload=False, mulled_upload_target=None, build_image=False, keep_image=False, lint=False, lint_exclude=None, - check_channels=None, n_workers=1, worker_offset=0, keep_old_work=False): + check_channels=None, n_workers=1, worker_offset=0, keep_old_work=False, + mulled_conda_image=pkg_test.MULLED_CONDA_IMAGE): cfg = utils.load_config(config) setup = cfg.get('setup', None) if setup: @@ -476,7 +480,8 @@ def build(recipe_folder, config, packages="*", git_range=None, testonly=False, label=label, n_workers=n_workers, worker_offset=worker_offset, - keep_old_work=keep_old_work) + keep_old_work=keep_old_work, + mulled_conda_image=mulled_conda_image) exit(0 if success else 1) diff --git a/bioconda_utils/pkg_test.py b/bioconda_utils/pkg_test.py index 47736c8f7e..e1e276bf10 100644 --- a/bioconda_utils/pkg_test.py +++ b/bioconda_utils/pkg_test.py @@ -17,7 +17,6 @@ logger = logging.getLogger(__name__) -# TODO: Make this configurable in bioconda_utils.build and bioconda_utils.cli. MULLED_CONDA_IMAGE = "quay.io/bioconda/create-env:latest"