Пример #1
0
 def test_get_build_targets_invalid_input(self):
     name = "rafhajd"
     with pytest.raises(PackitException) as ex:
         get_build_targets(name)
     err_msg = (f"Cannot get build target from '{name}'"
                f", packit understands values like these: ")
     assert err_msg in str(ex.value)
Пример #2
0
def test_get_build_targets_invalid_input():
    name = "rafhajd"
    with pytest.raises(PackitException) as ex:
        get_build_targets(name)
    err_msg = (
        f"Cannot get build target from '{name}'"
        f", packit understands values like these: '{list(ALIASES.keys())}'.")
    assert str(ex.value) == err_msg
Пример #3
0
def copr_build(
    config,
    nowait,
    owner,
    project,
    targets,
    description,
    instructions,
    upstream_ref,
    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)
    default_project_name = f"packit-cli-{path_or_url.repo_name}-{path_or_url.ref}"

    targets_to_build = get_build_targets(
        *targets.split(","), default="fedora-rawhide-x86_64"
    )

    build_id, repo_url = api.run_copr_build(
        project=project or default_project_name,
        chroots=list(targets_to_build),
        owner=owner,
        description=description,
        instructions=instructions,
        upstream_ref=upstream_ref,
    )
    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)
Пример #4
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_build_targets(*self.configured_build_targets, default=None)
Пример #5
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.")
        project = f"packit-cli-{path_or_url.repo_name}-{path_or_url.ref}"
        if isinstance(api.package_config, PackageConfig):
            project = api.package_config.get_copr_build_project_value()
            logger.info(f"Using COPR project name = {project}")

    targets_to_build = get_build_targets(*targets.split(","),
                                         default="fedora-rawhide-x86_64")

    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)
Пример #6
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_build_targets(*self.configured_tests_targets, default=None)
Пример #7
0
    def tests_chroots(self) -> List[str]:
        """
        Return the list of chroots used in the testing farm.
        Has to be a sub-set of the `build_chroots`.

        Return an empty list if there is no job configured.

        If not defined:
        1. use the build_chroots if the job si configured
        2. use "fedora-stable" alias otherwise
        """
        if not self.job_tests:
            return []

        if not self.job_tests.metadata.targets and self.job_build:
            return self.build_chroots

        configured_targets = self.job_tests.metadata.targets or {"fedora-stable"}
        return list(get_build_targets(*configured_targets))
Пример #8
0
    def build_chroots(self) -> List[str]:
        """
        Return the chroots to build.

        1. If the job is not defined, use the test_chroots.
        2. If the job is defined, but not the targets, use "fedora-stable" alias otherwise.
        """
        if (
            (not self.job_build or not self.job_build.metadata.targets)
            and self.job_tests
            and self.job_tests.metadata.targets
        ):
            return self.tests_chroots

        if self.job_build and self.job_build.metadata.targets:
            raw_targets = self.job_build.metadata.targets
        else:
            raw_targets = {"fedora-stable"}

        return list(get_build_targets(*raw_targets))
    def build_chroots(self) -> List[str]:
        """
        Return the chroots to build.

        1. If the job is not defined, use the test_chroots.
        2. If the job is defined, but not the targets, use "fedora-stable" alias otherwise.
        """
        if ((not self.job_build or "targets" not in self.job_build.metadata)
                and self.job_tests and "targets" in self.job_tests.metadata):
            return self.tests_chroots

        if not self.job_build:
            raw_targets = ["fedora-stable"]
        else:
            raw_targets = self.job_build.metadata.get("targets",
                                                      ["fedora-stable"])
            if isinstance(raw_targets, str):
                raw_targets = [raw_targets]

        return list(get_build_targets(*raw_targets))
Пример #10
0
    def tests_chroots(self) -> List[str]:
        """
        Return the list of chroots used in the testing farm.
        Has to be a sub-set of the `build_chroots`.

        Return an empty list if there is no job configured.

        If not defined:
        1. use the build_chroots if the job si configured
        2. use "fedora-stable" alias otherwise
        """
        if not self.job_tests:
            return []

        if "targets" not in self.job_tests.metadata and self.job_copr_build:
            return self.build_chroots

        configured_targets = self.job_tests.metadata.get(
            "targets", ["fedora-stable"])
        if isinstance(configured_targets, str):
            configured_targets = [configured_targets]

        return list(get_build_targets(*configured_targets))
Пример #11
0
 def test_get_build_targets_from_multiple_values(self, names, versions):
     assert get_build_targets(*names) == versions
Пример #12
0
 def test_get_build_targets_without_default(self):
     assert get_build_targets(default="") == set()
Пример #13
0
 def test_get_build_targets(self, name, targets, mock_get_aliases):
     assert get_build_targets(name) == targets
Пример #14
0
def test_get_build_targets(name, targets):
    assert get_build_targets(name) == targets
Пример #15
0
def test_get_build_targets_without_default():
    assert get_build_targets(default=None) == set()
Пример #16
0
 def build_chroots(self) -> List[str]:
     configured_targets = self.job_copr_build.metadata.get("targets", [])
     return list(get_build_targets(*configured_targets))
Пример #17
0
 def tests_chroots(self) -> List[str]:
     if not self.job_tests:
         return []
     configured_targets = self.job_tests.metadata.get("targets", [])
     return list(get_build_targets(*configured_targets))