Skip to content

Commit

Permalink
auto-close-issue (#351)
Browse files Browse the repository at this point in the history
* auto-close-issue
* fix doctest
We need to pass -s to pytest.
I've also passed --durations=0 to show test duration for all tests
* Fix path to coverage file
  • Loading branch information
kwk authored Mar 22, 2024
1 parent f4a347c commit 62dee71
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-format-and-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ jobs:
uses: coverallsapp/github-action@v2.2.3
with:
format: python
file: coverage-report/.coverage
file: .coverage
2 changes: 1 addition & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ log_cli: true
log_cli_level: info

; Extra command line options
addopts: --showlocals --doctest-modules
addopts: --showlocals --doctest-modules --durations=0 -s

; Directories to search for tests when no files or directories are given on the
; command line
Expand Down
18 changes: 9 additions & 9 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,18 +174,15 @@ 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.
Example: Check with a not existing copr project
>>> CoprClient().has_all_good_builds(copr_ownername="non-existing-owner", copr_projectname="non-existing-project", required_packages=[], required_chroots=[])
Traceback (most recent call last):
ValueError: copr project non-existing-owner/non-existing-project does not exist
False
"""
logging.info(
f"Checking for all good builds in {copr_ownername}/{copr_projectname}..."
Expand All @@ -193,13 +191,15 @@ def has_all_good_builds(
if not self.project_exists(
copr_ownername=copr_ownername, copr_projectname=copr_projectname
):
raise ValueError(
logging.warning(
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 62dee71

Please sign in to comment.