Skip to content

Commit 5285f02

Browse files
committed
Start working on testing
1 parent b2ec4bc commit 5285f02

File tree

2 files changed

+75
-9
lines changed

2 files changed

+75
-9
lines changed

snapshot_manager/snapshot_manager/github_util.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,3 +176,18 @@ def create_labels_for_strategies(self, labels: list[str], **kw_args):
176176

177177
def create_labels_for_archs(self, labels: list[str], **kw_args):
178178
self._create_labels(labels=labels, prefix="arch/", color="C5DEF5", *kw_args)
179+
180+
def create_labels_for_in_testing(self, labels: list[str], **kw_args):
181+
self._create_labels(
182+
labels=labels, prefix="in_testing/", color="C2E0C6", *kw_args
183+
)
184+
185+
def create_labels_for_tested_on(self, labels: list[str], **kw_args):
186+
self._create_labels(
187+
labels=labels, prefix="tested_on/", color="0E8A16", *kw_args
188+
)
189+
190+
def create_labels_for_failed_on(self, labels: list[str], **kw_args):
191+
self._create_labels(
192+
labels=labels, prefix="failed_on/", color="D93F0B", *kw_args
193+
)

snapshot_manager/snapshot_manager/snapshot_manager.py

Lines changed: 60 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ def check_todays_builds(self):
2929
)
3030
return
3131

32+
all_chroots = self.copr.get_copr_chroots()
33+
3234
logging.info("Get build states from copr")
3335
states = self.copr.get_build_states_from_copr_monitor(
3436
copr_ownername=self.config.copr_ownername,
@@ -50,7 +52,7 @@ def check_todays_builds(self):
5052

5153
logging.info("Add a build matrix")
5254
comment_body += build_status.markdown_build_status_matrix(
53-
chroots=self.copr.get_copr_chroots(),
55+
chroots=all_chroots,
5456
packages=self.config.packages,
5557
build_states=states,
5658
)
@@ -88,6 +90,9 @@ def check_todays_builds(self):
8890
self.github.create_labels_for_projects(project_labels)
8991
self.github.create_labels_for_archs(arch_labels)
9092
self.github.create_labels_for_strategies(strategy_labels)
93+
self.github.create_labels_for_in_testing(all_chroots)
94+
self.github.create_labels_for_tested_on(all_chroots)
95+
self.github.create_labels_for_failed_on(all_chroots)
9196

9297
# Remove old labels from issue if they no longer apply. This is greate
9398
# for restarted builds for example to make all builds green and be able
@@ -118,18 +123,64 @@ def check_todays_builds(self):
118123
logging.info(f"Adding label: {label}")
119124
issue.add_to_labels(label)
120125

126+
# TODO(kwk): Once only tested_on/<CHROOT> labels are assigned to the
127+
# issue we can turn this to True.
128+
num_builds_to_succeed = len(
129+
all_chroots
130+
) # The wording is misleading this is the number of chroots that need successful builds
131+
num_tests_to_run = len(all_chroots)
132+
all_tests_succeeded = True
133+
labels_on_issue = [label.name for label in issue.labels]
134+
135+
for chroot in all_chroots:
136+
logging.info(f"Check if all builds in chroot {chroot} have succeeded")
137+
builds_succeeded = self.copr.has_all_good_builds(
138+
copr_ownername=self.config.copr_ownername,
139+
copr_projectname=self.config.copr_projectname,
140+
required_chroots=[chroot],
141+
required_packages=self.config.packages,
142+
states=states,
143+
)
144+
145+
if not builds_succeeded:
146+
all_tests_succeeded = False
147+
continue
148+
149+
num_builds_to_succeed -= 1
150+
151+
logging.info(f"All builds in chroot {chroot} have succeeded!")
152+
if f"in_testing/{chroot}" in labels_on_issue:
153+
logging.info(
154+
f"Chroot {chroot} is currently in testing! Not kicking off new tests."
155+
)
156+
all_tests_succeeded = False
157+
elif f"tested_on/{chroot}" in labels_on_issue:
158+
logging.info(
159+
f"Chroot {chroot} has passed tests testing! Not kicking off new tests."
160+
)
161+
num_tests_to_run -= 1
162+
elif f"failed_on/{chroot}" in labels_on_issue:
163+
logging.info(
164+
f"Chroot {chroot} has unsuccessful tests! Not kicking off new tests."
165+
)
166+
num_tests_to_run -= 1
167+
all_tests_succeeded = False
168+
else:
169+
logging.info(f"Kicking off new tests for chroot {chroot}.")
170+
all_tests_succeeded = False
171+
issue.add_to_labels(f"in_testing/{chroot}")
172+
# TODO(kwk): Add testing-farm code here.
173+
121174
logging.info("Checking if issue can be closed")
122-
all_good = self.copr.has_all_good_builds(
123-
copr_ownername=self.config.copr_ownername,
124-
copr_projectname=self.config.copr_projectname,
125-
required_chroots=self.copr.get_copr_chroots(),
126-
required_packages=self.config.packages,
127-
states=states,
128-
)
129-
if all_good:
175+
building_is_done = num_builds_to_succeed == 0
176+
testing_is_done = num_tests_to_run == 0 and all_tests_succeeded
177+
178+
if building_is_done and testing_is_done:
130179
msg = f"@{self.config.maintainer_handle}, all required packages have been successfully built in all required chroots. We'll close this issue for you now as completed. Congratulations!"
131180
logging.info(msg)
132181
issue.create_comment(body=msg)
133182
issue.edit(state="closed", state_reason="completed")
183+
else:
184+
logging.info("Cannot close issue yet.")
134185

135186
logging.info(f"Updated today's issue: {issue.html_url}")

0 commit comments

Comments
 (0)