diff --git a/snapshot_manager/snapshot_manager/copr_util.py b/snapshot_manager/snapshot_manager/copr_util.py index d86a958a..c78fba7b 100644 --- a/snapshot_manager/snapshot_manager/copr_util.py +++ b/snapshot_manager/snapshot_manager/copr_util.py @@ -165,6 +165,7 @@ def has_all_good_builds( copr_projectname: str, required_packages: list[str], required_chroots: list[str], + states: build_status.BuildStateList | None = None, ) -> bool: """Returns True if the given packages have been built in all chroots in the copr project; otherwise False is returned. @@ -173,9 +174,7 @@ def has_all_good_builds( copr_projectname (str): Copr project name required_packages (list[str]): List of required package names. required_chroots (list[str]): List of required chroot names. - - Raises: - ValueError if copr_ownername/copr_projectname doesn't exist in copr + states (BuildStateList | None): List of states to use if already gathered before. If None, we will get the states for you. Returns: bool: True if the given copr project has successful/forked builds for all the required projects and chroots that we care about. @@ -193,13 +192,15 @@ def has_all_good_builds( if not self.project_exists( copr_ownername=copr_ownername, copr_projectname=copr_projectname ): - raise ValueError( + logging.warn( f"copr project {copr_ownername}/{copr_projectname} does not exist" ) + return False - states = self.get_build_states_from_copr_monitor( - copr_ownername=copr_ownername, copr_projectname=copr_projectname - ) + if states is None: + states = self.get_build_states_from_copr_monitor( + copr_ownername=copr_ownername, copr_projectname=copr_projectname + ) # Lists of (package,chroot) tuples expected: list[tuple[str, str]] = [] diff --git a/snapshot_manager/snapshot_manager/snapshot_manager.py b/snapshot_manager/snapshot_manager/snapshot_manager.py index 41229149..276896e8 100755 --- a/snapshot_manager/snapshot_manager/snapshot_manager.py +++ b/snapshot_manager/snapshot_manager/snapshot_manager.py @@ -112,4 +112,18 @@ def check_todays_builds(self): logging.info(f"Adding label: {label}") issue.add_to_labels(label) + logging.info("Checking if issue can be closed") + all_good = self.copr.has_all_good_builds( + copr_ownername=self.config.copr_ownername, + copr_projectname=self.config.copr_projectname, + required_chroots=self.copr.get_copr_chroots(), + required_packages=self.config.packages, + states=states, + ) + if all_good: + logging.info( + "All required packages have been successfully built in all required chroots. We can can close this issue now." + ) + issue.edit(state="closed", state_reason="completed") + logging.info(f"Updated today's issue: {issue.html_url}")