Пример #1
0
def test_get_valid_build_targets_get_aliases_call(name, default):
    flexmock(
        packit.config.aliases).should_receive("get_build_targets").with_args(
            *name, **default).and_return(set())
    flexmock(packit.config.aliases.CoprHelper).should_receive(
        "get_available_chroots").and_return(set())
    get_valid_build_targets(*name, **default)
Пример #2
0
def test_get_valid_build_targets(targets, chroots, expected_result):
    flexmock(packit.config.aliases).should_receive(
        "get_build_targets").and_return(targets)
    flexmock(packit.config.aliases.CoprHelper).should_receive(
        "get_available_chroots").and_return(chroots)

    assert get_valid_build_targets() == expected_result
Пример #3
0
    def build_targets(self) -> Set[str]:
        """
        Return the chroots to build.

        (Used when submitting the copr build and as a part of the commit status name.)

        1. If the job is not defined, use the test chroots.
        2. If the job is defined without targets, use "fedora-stable".
        """
        return get_valid_build_targets(*self.configured_build_targets,
                                       default=None)
Пример #4
0
    def tests_targets(self) -> Set[str]:
        """
        Return the list of chroots used in testing farm.
        Has to be a sub-set of the `build_targets`.

        (Used when submitting the copr build and as a part of the commit status name.)

        Return an empty list if there is no job configured.

        If not defined:
        1. use the build_targets if the job si configured
        2. use "fedora-stable" alias otherwise
        """
        return get_valid_build_targets(*self.configured_tests_targets,
                                       default=None)
Пример #5
0
 def tests_targets_all(self) -> Set[str]:
     """
     Return all valid test targets/chroots from config.
     """
     return get_valid_build_targets(*self.configured_tests_targets, default=None)
Пример #6
0
def copr_build(
    config,
    nowait,
    owner,
    project,
    targets,
    description,
    instructions,
    list_on_homepage,
    preserve_project,
    upstream_ref,
    additional_repos,
    request_admin_if_needed,
    path_or_url,
):
    """
    Build selected upstream project in COPR.

    PATH_OR_URL argument is a local path or a URL to the upstream git repository,
    it defaults to the current working directory.
    """
    api = get_packit_api(config=config, local_project=path_or_url)
    if not project:
        logger.debug("COPR project name was not passed via CLI.")

        if isinstance(api.package_config, PackageConfig):
            project = api.package_config.get_copr_build_project_value()

        if project:
            logger.debug(
                "Using a first COPR project found in the job configuration.")
        else:
            logger.debug("COPR project not found in the job configuration. "
                         "Using the default one.")
            sanitized_ref = sanitize_branch_name(path_or_url.ref)
            project = f"packit-cli-{path_or_url.repo_name}-{sanitized_ref}"

    logger.info(f"Using COPR project name = {project}")

    targets_list = targets.split(",")
    for target in targets_list:
        if target in DEPRECATED_TARGET_MAP:
            logger.warning(
                f"Target '{target}' is deprecated. "
                f"Please use '{DEPRECATED_TARGET_MAP[target]}' instead.")
    targets_to_build = get_valid_build_targets(*targets_list,
                                               default="fedora-rawhide-x86_64")

    logger.info(f"Targets to build: {targets_to_build}.")

    additional_repos_list: Optional[List[str]] = (
        additional_repos.split(",") if additional_repos else None)

    build_id, repo_url = api.run_copr_build(
        project=project,
        chroots=list(targets_to_build),
        owner=owner,
        description=description,
        instructions=instructions,
        upstream_ref=upstream_ref,
        list_on_homepage=list_on_homepage,
        preserve_project=preserve_project,
        additional_repos=additional_repos_list,
        request_admin_if_needed=request_admin_if_needed,
    )
    click.echo(f"Build id: {build_id}, repo url: {repo_url}")
    if not nowait:
        api.watch_copr_build(build_id=build_id, timeout=60 * 60 * 2)