From ea272af243c72566b02a98426348ad81e43badb1 Mon Sep 17 00:00:00 2001 From: Pablo Galindo Salgado Date: Tue, 29 Oct 2024 17:12:49 +0000 Subject: [PATCH] Add logging to the PR reporter (#549) --- master/custom/pr_reporter.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/master/custom/pr_reporter.py b/master/custom/pr_reporter.py index 61b17a6c6..953d6d438 100644 --- a/master/custom/pr_reporter.py +++ b/master/custom/pr_reporter.py @@ -1,4 +1,5 @@ import re +import logging from twisted.internet import defer from twisted.python import log @@ -62,6 +63,7 @@ class GitHubPullRequestReporter(reporters.GitHubStatusPush): @defer.inlineCallbacks def sendMessage(self, reports): build = reports[0]['builds'][0] + log.msg("Considering reporting build :{}".format(build['buildid']), logLevel=logging.INFO) props = Properties.fromDict(build["properties"]) props.master = self.master @@ -80,6 +82,7 @@ def sendMessage(self, reports): return if state != "failure": + log.msg("Not reporting build {} as it is not a failure".format(build['buildid']), logLevel=logging.INFO) return yield getDetailsForBuild(self.master, build, want_logs=True, want_logs_content=True, want_steps=True) @@ -91,23 +94,28 @@ def sendMessage(self, reports): sourcestamps = build["buildset"].get("sourcestamps") if not (sourcestamps and sourcestamps[0]): + log.msg("Build {} not reported as it doesn't have source stamps".format(build['buildid']), logLevel=logging.INFO) return changes = yield self.master.data.get(("builds", build["buildid"], "changes")) if len(changes) != 1: + log.msg("Build {} not reported as it has more than one change".format(build['buildid']), logLevel=logging.INFO) return change = changes[0] change_comments = change["comments"] if not change_comments: + log.msg("Build {} not reported as no change comments could be found".format(build['buildid']), logLevel=logging.INFO) return # GH-42, gh-42, or #42 m = re.search(r"\((?:GH-|#)(\d+)\)", change_comments, flags=re.IGNORECASE) if m is None: + log.msg("Build {} not reported as the issue could not be identified from the title".format( + build['buildid']), logLevel=logging.INFO) return issue = m.groups()[-1] @@ -128,6 +136,7 @@ def sendMessage(self, reports): ) ) + log.msg("Attempting to issue a PR comment for failed build for build {}".format(build['buildid']), logLevel=logging.INFO) try: repo_user = repoOwner repo_name = repoName