Skip to content

Commit dfaf1ed

Browse files
committed
Report cancellation to forge checks
After the build is canceled, report statuse "canceled" to the checks. Signed-off-by: Marek Blaha <mblaha@redhat.com>
1 parent 1d3e5c7 commit dfaf1ed

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

packit_service/worker/helpers/build/koji_build.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,3 +249,9 @@ def cancel_running_builds(self) -> None:
249249
logger.debug(f"Cancelling Koji task {build.task_id}")
250250
koji_helper.cancel_task(int(build.task_id))
251251
build.set_status(BuildStatus.canceled)
252+
self.report_status_to_build_for_chroot(
253+
state=BaseCommitStatus.canceled,
254+
description="Build was canceled.",
255+
url=get_koji_build_info_url(build.id),
256+
chroot=build.target,
257+
)

tests/unit/test_koji_build.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -606,9 +606,9 @@ def test_get_koji_rpm_build_web_url(id_, result):
606606

607607

608608
def test_cancel_running_builds():
609-
build1 = flexmock(task_id="111")
610-
build2 = flexmock(task_id="222")
611-
build3 = flexmock(task_id=None) # no task_id yet
609+
build1 = flexmock(task_id="111", id=1, target="f41")
610+
build2 = flexmock(task_id="222", id=2, target="f42")
611+
build3 = flexmock(task_id=None, id=3, target="rawhide") # no task_id yet
612612

613613
build1.should_receive("set_status").with_args(BuildStatus.canceled).once()
614614
build2.should_receive("set_status").with_args(BuildStatus.canceled).once()
@@ -618,6 +618,7 @@ def test_cancel_running_builds():
618618
flexmock(KojiHelper).should_receive("cancel_task").with_args(222).once()
619619

620620
helper = flexmock(get_running_jobs=lambda: [build1, build2, build3])
621+
helper.should_receive("report_status_to_build_for_chroot").times(3)
621622

622623
# Call the real method with our mock as self
623624
KojiBuildJobHelper.cancel_running_builds(helper)

0 commit comments

Comments
 (0)