Esempio n. 1
0
 def validate(cls, raw_dict: dict) -> None:
     try:
         Draft4Validator(cls.SCHEMA).validate(raw_dict)
     except ValidationError as ex:
         logger.debug(f"{pformat(raw_dict)}")
         raise PackitInvalidConfigException(
             f"Provided configuration is not valid: {ex}.")
Esempio n. 2
0
    def run_copr_build(self,
                       project: str,
                       chroots: List[str],
                       owner: str = None) -> Tuple[int, str]:
        """
        Submit a build to copr build system using an SRPM using the current checkout.

        :param project: name of the copr project to build
                        inside (defaults to something long and ugly)
        :param chroots: a list of COPR chroots (targets) e.g. fedora-rawhide-x86_64
        :param owner: defaults to username from copr config file
        :return: id of the created build and url to its repo
        """
        # get info
        configured_owner = self.copr.config.get("username")
        owner = owner or configured_owner
        try:
            copr_proj = self.copr.project_proxy.get(owner, project)
            # make sure or project has chroots set correctly
            if set(copr_proj.chroot_repos.keys()) != set(chroots):
                logger.info(f"Updating targets on project {owner}/{project}")
                logger.debug(f"old = {set(copr_proj.chroot_repos.keys())}")
                logger.debug(f"new = {set(chroots)}")
                self.copr.project_proxy.edit(owner, project, chroots=chroots)
        except CoprNoResultException:
            if owner == configured_owner:
                logger.info(
                    f"Copr project {owner}/{project} not found. Creating new.")
                self.copr.project_proxy.add(
                    ownername=owner,
                    projectname=project,
                    chroots=chroots,
                    description=(
                        "Continuous builds initiated by packit service.\n"
                        "For more info check out https://packit.dev/"),
                    contact="*****@*****.**",
                )
            else:
                raise PackitInvalidConfigException(
                    f"Copr project {owner}/{project} not found.")
        srpm_path = self.create_srpm(
            srpm_dir=self.up.local_project.working_dir)
        logger.debug(f"owner={owner}, project={project}, path={srpm_path}")
        build = self.copr.build_proxy.create_from_file(owner, project,
                                                       srpm_path)
        return build.id, build.repo_url
Esempio n. 3
0
    def run_copr_build(
        self,
        project: str,
        chroots: List[str],
        owner: str = None,
        description: str = None,
        instructions: str = None,
    ) -> Tuple[int, str]:
        """
        Submit a build to copr build system using an SRPM using the current checkout.

        :param project: name of the copr project to build
                        inside (defaults to something long and ugly)
        :param chroots: a list of COPR chroots (targets) e.g. fedora-rawhide-x86_64
        :param owner: defaults to username from copr config file
        :param description: description of the project
        :param instructions: installation instructions for the project
        :return: id of the created build and url to the build web page
        """
        # get info
        configured_owner = self.copr.config.get("username")
        owner = owner or configured_owner
        try:
            copr_proj = self.copr.project_proxy.get(owner, project)
            # make sure or project has chroots set correctly
            if set(copr_proj.chroot_repos.keys()) != set(chroots):
                logger.info(f"Updating targets on project {owner}/{project}")
                logger.debug(f"old = {set(copr_proj.chroot_repos.keys())}")
                logger.debug(f"new = {set(chroots)}")
                self.copr.project_proxy.edit(
                    owner,
                    project,
                    chroots=chroots,
                    description=description,
                    instructions=instructions,
                )
        except CoprNoResultException:
            if owner == configured_owner:
                logger.info(f"Copr project {owner}/{project} not found. Creating new.")
                self.copr.project_proxy.add(
                    ownername=owner,
                    projectname=project,
                    chroots=chroots,
                    description=(
                        description
                        or "Continuous builds initiated by packit service.\n"
                        "For more info check out https://packit.dev/"
                    ),
                    contact="https://github.com/packit-service/packit/issues",
                    # don't show project on Copr homepage
                    unlisted_on_hp=True,
                    # delete project after the specified period of time
                    delete_after_days=60,
                    instructions=instructions
                    or "You can check out the upstream project"
                    f"{self.upstream_local_project.git_url} to find out how to consume these"
                    "builds. This copr project is created and handled by the packit project"
                    "(https://packit.dev/).",
                )
            else:
                raise PackitInvalidConfigException(
                    f"Copr project {owner}/{project} not found."
                )
        srpm_path = self.create_srpm(srpm_dir=self.up.local_project.working_dir)
        logger.debug(f"owner={owner}, project={project}, path={srpm_path}")
        build = self.copr.build_proxy.create_from_file(owner, project, srpm_path)
        return build.id, self._copr_web_build_url(build)