def build_targets(self) -> Set[str]: """ Return the targets/chroots to build. (Used when submitting the koji/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_koji_targets(*self.configured_build_targets)
def tests_targets(self) -> Set[str]: """ [not used now] Return the list of targets/chroots used in testing farm. Has to be a sub-set of the `build_targets`. (Used when submitting the koji/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_koji_targets(*self.configured_tests_targets)
def test_get_koji_targets_without_default(self): assert get_koji_targets(default=None) == set()
def test_get_koji_targets(self, name, targets, mock_get_aliases): assert get_koji_targets(name) == targets
def test_preserve_all_koji_targets_together(self): assert set(ALL_KOJI_TARGETS_SNAPSHOT) == get_koji_targets( *ALL_KOJI_TARGETS_SNAPSHOT)
def test_preserve_koji_targets_single(self, target): assert {target} == get_koji_targets(target)
def test_get_koji_targets(name, targets): assert get_koji_targets(name) == targets
def tests_targets_all(self) -> Set[str]: """ [not used now] Return all valid test targets/chroots from config. """ return get_koji_targets(*self.configured_tests_targets)
def build_targets_all(self) -> Set[str]: """ Return all valid Koji targets/chroots from config. """ return get_koji_targets(*self.configured_build_targets)
def koji( config, dist_git_path, dist_git_branch, from_upstream, koji_target, scratch, nowait, release_suffix, default_release_suffix, path_or_url, ): """ Build selected upstream project in Fedora. By default, packit checks out the respective dist-git repository and performs `fedpkg build` for the selected branch. With `--from-upstream`, packit creates a SRPM out of the current checkout and sends it to koji. 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, dist_git_path=dist_git_path, local_project=path_or_url) release_suffix = ChangelogHelper.resolve_release_suffix( api.package_config, release_suffix, default_release_suffix) default_dg_branch = api.dg.local_project.git_project.default_branch dist_git_branch = dist_git_branch or default_dg_branch branches_to_build = get_branches(*dist_git_branch.split(","), default_dg_branch=default_dg_branch) click.echo( f"Building from the following branches: {', '.join(branches_to_build)}" ) if koji_target is None: targets_to_build = {None} else: targets_to_build = get_koji_targets(koji_target) if len(targets_to_build) > 1 and len(branches_to_build) > 1: raise PackitConfigException( "Parameters --dist-git-branch and --koji-target cannot have " "multiple values at the same time.") for target in targets_to_build: for branch in branches_to_build: try: out = api.build( dist_git_branch=branch, scratch=scratch, nowait=nowait, koji_target=target, from_upstream=from_upstream, release_suffix=release_suffix, srpm_path=config.srpm_path, ) except PackitCommandFailedError as ex: logs_stdout = "\n>>> ".join( ex.stdout_output.strip().split("\n")) logs_stderr = "\n!!! ".join( ex.stderr_output.strip().split("\n")) click.echo( f"Build for branch '{branch}' failed. \n" f">>> {logs_stdout}\n" f"!!! {logs_stderr}\n", err=True, ) else: if out: print(ensure_str(out))