Skip to content

Commit

Permalink
auto-close-issue
Browse files Browse the repository at this point in the history
  • Loading branch information
kwk committed Mar 22, 2024
1 parent f4a347c commit b8c45e1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
15 changes: 8 additions & 7 deletions snapshot_manager/snapshot_manager/copr_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand All @@ -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]] = []
Expand Down
14 changes: 14 additions & 0 deletions snapshot_manager/snapshot_manager/snapshot_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")

0 comments on commit b8c45e1

Please sign in to comment.