Skip to content

Commit 62dee71

Browse files
authored
auto-close-issue (#351)
* 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
1 parent f4a347c commit 62dee71

File tree

4 files changed

+25
-11
lines changed

4 files changed

+25
-11
lines changed

.github/workflows/python-format-and-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ jobs:
2828
uses: coverallsapp/[email protected]
2929
with:
3030
format: python
31-
file: coverage-report/.coverage
31+
file: .coverage

pytest.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ log_cli: true
77
log_cli_level: info
88

99
; Extra command line options
10-
addopts: --showlocals --doctest-modules
10+
addopts: --showlocals --doctest-modules --durations=0 -s
1111

1212
; Directories to search for tests when no files or directories are given on the
1313
; command line

snapshot_manager/snapshot_manager/copr_util.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ def has_all_good_builds(
165165
copr_projectname: str,
166166
required_packages: list[str],
167167
required_chroots: list[str],
168+
states: build_status.BuildStateList | None = None,
168169
) -> bool:
169170
"""Returns True if the given packages have been built in all chroots in the copr project; otherwise False is returned.
170171
@@ -173,18 +174,15 @@ def has_all_good_builds(
173174
copr_projectname (str): Copr project name
174175
required_packages (list[str]): List of required package names.
175176
required_chroots (list[str]): List of required chroot names.
176-
177-
Raises:
178-
ValueError if copr_ownername/copr_projectname doesn't exist in copr
177+
states (BuildStateList | None): List of states to use if already gathered before. If None, we will get the states for you.
179178
180179
Returns:
181180
bool: True if the given copr project has successful/forked builds for all the required projects and chroots that we care about.
182181
183182
Example: Check with a not existing copr project
184183
185184
>>> CoprClient().has_all_good_builds(copr_ownername="non-existing-owner", copr_projectname="non-existing-project", required_packages=[], required_chroots=[])
186-
Traceback (most recent call last):
187-
ValueError: copr project non-existing-owner/non-existing-project does not exist
185+
False
188186
"""
189187
logging.info(
190188
f"Checking for all good builds in {copr_ownername}/{copr_projectname}..."
@@ -193,13 +191,15 @@ def has_all_good_builds(
193191
if not self.project_exists(
194192
copr_ownername=copr_ownername, copr_projectname=copr_projectname
195193
):
196-
raise ValueError(
194+
logging.warning(
197195
f"copr project {copr_ownername}/{copr_projectname} does not exist"
198196
)
197+
return False
199198

200-
states = self.get_build_states_from_copr_monitor(
201-
copr_ownername=copr_ownername, copr_projectname=copr_projectname
202-
)
199+
if states is None:
200+
states = self.get_build_states_from_copr_monitor(
201+
copr_ownername=copr_ownername, copr_projectname=copr_projectname
202+
)
203203

204204
# Lists of (package,chroot) tuples
205205
expected: list[tuple[str, str]] = []

snapshot_manager/snapshot_manager/snapshot_manager.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,4 +112,18 @@ def check_todays_builds(self):
112112
logging.info(f"Adding label: {label}")
113113
issue.add_to_labels(label)
114114

115+
logging.info("Checking if issue can be closed")
116+
all_good = self.copr.has_all_good_builds(
117+
copr_ownername=self.config.copr_ownername,
118+
copr_projectname=self.config.copr_projectname,
119+
required_chroots=self.copr.get_copr_chroots(),
120+
required_packages=self.config.packages,
121+
states=states,
122+
)
123+
if all_good:
124+
logging.info(
125+
"All required packages have been successfully built in all required chroots. We can can close this issue now."
126+
)
127+
issue.edit(state="closed", state_reason="completed")
128+
115129
logging.info(f"Updated today's issue: {issue.html_url}")

0 commit comments

Comments
 (0)