Skip to content

Commit b58b3b7

Browse files
Check if sync_release PR should warn about koji_build triggering bug (#2550)
Check if `sync_release` PR should warn about `koji_build` triggering bug Related to #2537. Merge after packit/packit#2425. Reviewed-by: Maja Massarini Reviewed-by: Laura Barcziová
2 parents 0f6c6e6 + c35b238 commit b58b3b7

File tree

5 files changed

+26
-1
lines changed

5 files changed

+26
-1
lines changed

packit_service/worker/handlers/distgit.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
from ogr.abstract import PullRequest, AuthMethod
1717
from ogr.services.github import GithubService
18-
from packit.config import JobConfig, JobType, Deployment
18+
from packit.config import JobConfig, JobType, JobConfigTriggerType, Deployment
1919
from packit.config import aliases
2020
from packit.config.package_config import PackageConfig
2121
from packit.exceptions import (
@@ -268,6 +268,20 @@ def sync_branch(
268268
kwargs["tag"] = self.tag
269269
elif version := self.data.event_dict.get("version"):
270270
kwargs["versions"] = [version]
271+
# check if there is a Koji build job that should trigger on PR merge
272+
kwargs["warn_about_koji_build_triggering_bug"] = False
273+
for job in self.package_config.get_job_views():
274+
if job.type != JobType.koji_build:
275+
continue
276+
if job.trigger != JobConfigTriggerType.commit:
277+
continue
278+
if branch not in aliases.get_branches(
279+
*job.dist_git_branches,
280+
default_dg_branch="rawhide",
281+
):
282+
continue
283+
kwargs["warn_about_koji_build_triggering_bug"] = True
284+
break
271285
downstream_pr = self.packit_api.sync_release(**kwargs)
272286
except PackitDownloadFailedException as ex:
273287
# the archive has not been uploaded to PyPI yet

tests/integration/test_new_hotness_update.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ def test_new_hotness_update(new_hotness_update, sync_release_model):
223223
pr_description_footer=DistgitAnnouncement.get_announcement(),
224224
add_new_sources=True,
225225
fast_forward_merge_branches=set(),
226+
warn_about_koji_build_triggering_bug=False,
226227
).and_return(pr).once()
227228
flexmock(PackitAPI).should_receive("clean")
228229

@@ -396,6 +397,7 @@ def test_new_hotness_update_non_git(new_hotness_update, sync_release_model_non_g
396397
pr_description_footer=DistgitAnnouncement.get_announcement(),
397398
add_new_sources=True,
398399
fast_forward_merge_branches=set(),
400+
warn_about_koji_build_triggering_bug=False,
399401
).and_return(pr).once()
400402
flexmock(PackitAPI).should_receive("clean")
401403

tests/integration/test_pr_comment.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2707,6 +2707,7 @@ def _get_project(url, *_, **__):
27072707
pr_description_footer=DistgitAnnouncement.get_announcement(),
27082708
add_new_sources=True,
27092709
fast_forward_merge_branches=set(),
2710+
warn_about_koji_build_triggering_bug=False,
27102711
).and_return(pr).once()
27112712
flexmock(PackitAPI).should_receive("clean")
27122713

@@ -2875,6 +2876,7 @@ def _get_project(url, *_, **__):
28752876
pr_description_footer=DistgitAnnouncement.get_announcement(),
28762877
add_new_sources=True,
28772878
fast_forward_merge_branches=set(),
2879+
warn_about_koji_build_triggering_bug=False,
28782880
).and_return(pr).once()
28792881
flexmock(PackitAPI).should_receive("clean")
28802882

tests/integration/test_release_event.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ def test_dist_git_push_release_handle(
222222
pr_description_footer=DistgitAnnouncement.get_announcement(),
223223
add_new_sources=True,
224224
fast_forward_merge_branches=set(),
225+
warn_about_koji_build_triggering_bug=False,
225226
).and_return(pr).once()
226227
flexmock(PackitAPI).should_receive("clean")
227228

@@ -365,6 +366,7 @@ def test_dist_git_push_release_handle_multiple_branches(
365366
pr_description_footer=DistgitAnnouncement.get_announcement(),
366367
add_new_sources=True,
367368
fast_forward_merge_branches=set(),
369+
warn_about_koji_build_triggering_bug=False,
368370
).and_return(pr).once()
369371

370372
flexmock(ProposeDownstreamJobHelper).should_receive(
@@ -516,6 +518,7 @@ def test_dist_git_push_release_handle_one_failed(
516518
pr_description_footer=DistgitAnnouncement.get_announcement(),
517519
add_new_sources=True,
518520
fast_forward_merge_branches=set(),
521+
warn_about_koji_build_triggering_bug=False,
519522
).and_return(pr).once()
520523
flexmock(ProposeDownstreamJobHelper).should_receive(
521524
"report_status_for_branch"
@@ -540,6 +543,7 @@ def test_dist_git_push_release_handle_one_failed(
540543
pr_description_footer=DistgitAnnouncement.get_announcement(),
541544
add_new_sources=True,
542545
fast_forward_merge_branches=set(),
546+
warn_about_koji_build_triggering_bug=False,
543547
).and_raise(Exception, f"Failed {model.branch}").once()
544548
flexmock(ProposeDownstreamJobHelper).should_receive(
545549
"report_status_for_branch"
@@ -785,6 +789,7 @@ def test_retry_propose_downstream_task(
785789
pr_description_footer=DistgitAnnouncement.get_announcement(),
786790
add_new_sources=True,
787791
fast_forward_merge_branches=set(),
792+
warn_about_koji_build_triggering_bug=False,
788793
).and_raise(
789794
PackitDownloadFailedException, "Failed to download source from example.com"
790795
).once()
@@ -899,6 +904,7 @@ def test_dont_retry_propose_downstream_task(
899904
pr_description_footer=DistgitAnnouncement.get_announcement(),
900905
add_new_sources=True,
901906
fast_forward_merge_branches=set(),
907+
warn_about_koji_build_triggering_bug=False,
902908
).and_raise(
903909
PackitDownloadFailedException, "Failed to download source from example.com"
904910
).once()

tests/unit/test_steve.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ def test_process_message(event, private, enabled_private_namespaces, success):
192192
pr_description_footer=DistgitAnnouncement.get_announcement(),
193193
add_new_sources=True,
194194
fast_forward_merge_branches=set(),
195+
warn_about_koji_build_triggering_bug=False,
195196
).and_return(pr).times(1 if success else 0)
196197
flexmock(shutil).should_receive("rmtree").with_args("")
197198

0 commit comments

Comments
 (0)