From e96a3b56df4ad695d416c2678db3bf56dcfc42ec Mon Sep 17 00:00:00 2001 From: Siddharth Sharma Date: Fri, 28 Apr 2023 10:18:48 -0400 Subject: [PATCH] Comment on pr - restrict to stream assembly (#765) --- doozerlib/cli/__main__.py | 4 ++++ doozerlib/distgit.py | 4 ++-- tests/test_distgit/support.py | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/doozerlib/cli/__main__.py b/doozerlib/cli/__main__.py index 675b0927..96a07e5c 100644 --- a/doozerlib/cli/__main__.py +++ b/doozerlib/cli/__main__.py @@ -806,6 +806,10 @@ def images_build_image(runtime, repo_type, repo, push_to_defaults, push_to, scra 3. You will probably want to use --scratch since it is unlikely you want your custom build tagged. """ + if runtime.assembly != 'stream' and comment_on_pr: + runtime.logger.warning("Commenting on PRs is only supported for stream assembly") + comment_on_pr = False + # Initialize all distgit directories before trying to build. This is to # ensure all build locks are acquired before the builds start and for # clarity in the logs. diff --git a/doozerlib/distgit.py b/doozerlib/distgit.py index 4f06d3a3..cc20ef0a 100644 --- a/doozerlib/distgit.py +++ b/doozerlib/distgit.py @@ -1056,10 +1056,10 @@ def wait(n): comment_on_pr_obj.set_github_client() comment_on_pr_obj.set_pr_from_commit() # Message to be posted to the comment - message = Template("**[ART PR BUILD NOTIFIER]** _(beta)_\n\n" + message = Template("**[ART PR BUILD NOTIFIER]**\n\n" "This PR has been included in build " "[$nvr](https://brewweb.engineering.redhat.com/brew/buildinfo" - "?buildID=$build_id)" + "?buildID=$build_id) " "for distgit *$distgit_name*. \n All builds following this will " "include this PR.") comment_on_pr_obj.post_comment(message.substitute(nvr=build_info["nvr"], diff --git a/tests/test_distgit/support.py b/tests/test_distgit/support.py index e52190d5..f660e02c 100644 --- a/tests/test_distgit/support.py +++ b/tests/test_distgit/support.py @@ -95,8 +95,10 @@ def setUp(self): Define and provide mock logging for test/response """ self.stream = io.StringIO() - logging.basicConfig(level=logging.DEBUG, stream=self.stream) + self.handler = logging.StreamHandler(self.stream) self.logger = logging.getLogger() + self.logger.setLevel(logging.DEBUG) + self.logger.addHandler(self.handler) self.logs_dir = tempfile.mkdtemp() self.md = MockMetadata(MockRuntime(self.logger))