Skip to content

Commit

Permalink
Merge pull request #455 from TomasTomecek/168
Browse files Browse the repository at this point in the history
enable configuring "Congratulations!" PR comment

Reviewed-by: Tomas Tomecek <tomas@tomecek.net>
             https://github.com/TomasTomecek
  • Loading branch information
softwarefactory-project-zuul[bot] committed Mar 5, 2020
2 parents 129d68e + 8418eeb commit 40297f0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
6 changes: 5 additions & 1 deletion packit_service/worker/handlers/fedmsg_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,11 @@ def run(self):
build_pg.set_status("failure")
return HandlerResults(success=False, details={"msg": failed_msg})

if self.build_job_helper.job_build and not self.was_last_build_successful():
if (
self.build_job_helper.job_build
and not self.was_last_build_successful()
and self.package_config.notifications.pull_request.successful_build
):
msg = (
f"Congratulations! One of the builds has completed. :champagne:\n\n"
"You can install the built RPMs by following these steps:\n\n"
Expand Down
13 changes: 11 additions & 2 deletions tests/integration/test_listen_to_fedmsg.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,12 @@ def pc_tests():
)


def test_copr_build_end(copr_build_end, pc_build, copr_build):
@pytest.mark.parametrize(
"pc_comment_pr_succ,pr_comment_called", ((True, True), (False, False),)
)
def test_copr_build_end(
copr_build_end, pc_build, copr_build, pc_comment_pr_succ, pr_comment_called
):
steve = SteveJobs()
flexmock(SteveJobs, _is_private=False)
flexmock(CoprHelper).should_receive("get_copr_client").and_return(
Expand All @@ -99,11 +104,15 @@ def test_copr_build_end(copr_build_end, pc_build, copr_build):
flexmock(CoprBuildJobHelper).should_receive("copr_build_model").and_return(
flexmock()
)
pc_build.notifications.pull_request.successful_build = pc_comment_pr_succ
flexmock(CoprBuildEvent).should_receive("get_package_config").and_return(pc_build)
flexmock(CoprBuildEndHandler).should_receive(
"was_last_build_successful"
).and_return(False)
flexmock(GithubProject).should_receive("pr_comment")
if pr_comment_called:
flexmock(GithubProject).should_receive("pr_comment")
else:
flexmock(GithubProject).should_receive("pr_comment").never()

flexmock(CoprBuild).should_receive("get_by_build_id").and_return(copr_build)
flexmock(CoprBuild).should_receive("set_status").with_args("success")
Expand Down

0 comments on commit 40297f0

Please sign in to comment.