commit:     0d19b4627eba83ffccadc753105b5cbdf53a68e7
Author:     Magnus Granberg <zorry <AT> gentoo <DOT> org>
AuthorDate: Thu Sep  1 14:56:42 2022 +0000
Commit:     Magnus Granberg <zorry <AT> gentoo <DOT> org>
CommitDate: Thu Sep  1 14:56:42 2022 +0000
URL:        
https://gitweb.gentoo.org/proj/tinderbox-cluster.git/commit/?id=0d19b462

Add Bug ID for Irc reporter and nice titel

Signed-off-by: Magnus Granberg <zorry <AT> gentoo.org>

 buildbot_gentoo_ci/config/reporters.py |  7 ++++---
 buildbot_gentoo_ci/steps/bugs.py       | 24 ++++++++++++++++--------
 buildbot_gentoo_ci/steps/logs.py       | 16 ++++++++++++++++
 3 files changed, 36 insertions(+), 11 deletions(-)

diff --git a/buildbot_gentoo_ci/config/reporters.py 
b/buildbot_gentoo_ci/config/reporters.py
index 9832305..bd55037 100644
--- a/buildbot_gentoo_ci/config/reporters.py
+++ b/buildbot_gentoo_ci/config/reporters.py
@@ -8,10 +8,11 @@ from buildbot.reporters.message import MessageFormatter
 
 from buildbot_gentoo_ci.reporters import irc
 irc_template = '''{% set resultsList = ["\x0303SUCCESS", "\x0308WARNINGS", 
"\x0304FAILURE"] %}\
-{{ "\x02" }}{{ build['properties']['cpv'][0] }}{{ "\x02" }} {{ "\x0303" 
}}repo/{{ projects }}:{{ build['properties']['branch'][0] }}{{ "\x03" }} \
+{{ "\x02" }}{{ build['properties']['cpv'][0] }}{{ "\x02" }} {{ "\x0303" 
}}Repo:{{ projects }}:{{ build['properties']['branch'][0] }}{{ "\x03" }} \
 {{ build['properties']['revision'][0]|truncate(10, True) }} {{ "\x0302" }}{{ 
build['properties']['owners'][0][0] }}{{ "\x03" }} \
-{{ build['properties']['event'][0] }} {{ projects }}:{{ 
build['properties']['project_data'][0]['name'] }} \
-{{ "\x02" }}{{ "Build: "}}{{ resultsList[build['results']] }}{{ "\x03" }}{{ 
"\x02" }} {{ "\x0312" }}{{ build_url }}{{ "\x03" }}\
+{{ "\x0306" }}{{ build['properties']['event'][0] }}{{ "\x03" }} {{ projects 
}}:{{ build['properties']['project_data'][0]['name'] }} \
+{{ "\x02" }}{{ "Build: "}}{{ resultsList[build['results']] }}{{ "\x03" }}{{ 
"\x02" }} {{ "\x0312" }}{{ build_url }}{{ "\x03" }} \
+{% if build['properties']['bgo'][0]['match'] is true %}{{ "\x0311" }}Bugid: 
{{build['properties']['bgo'][0]['id']}}{{ "\x03" }}{% endif %}\
 '''
 
 def ircGenerators():

diff --git a/buildbot_gentoo_ci/steps/bugs.py b/buildbot_gentoo_ci/steps/bugs.py
index 27b1388..801fc98 100644
--- a/buildbot_gentoo_ci/steps/bugs.py
+++ b/buildbot_gentoo_ci/steps/bugs.py
@@ -87,20 +87,28 @@ class GetBugs(BuildStep):
         yield log.addStdout('Open Bugs\n')
         match = False
         for bug in buglist:
-            yield log.addStdout('Bug: ' + str(bug['id']) + ' Summary: ' + 
bug['summary'] +'\n')
-            if re.search(self.getProperty('error_dict')['title_issue'][:20], 
bug['summary']):
-                print('Bug found')
-                print(bug)
+            yield log.addStdout(f"Bug: {str(bug['id'])} Summary: 
{bug['summary']}\n")
+            # we splite the lines to lists and try to match the words
+            matches = 0
+            match_search_text = 
list(self.getProperty('error_dict')['title_issue'].split())
+            match_bug_text = list(bug['summary'].split())
+            #FIXME: add check for cp
+            for match_word in match_search_text:
+                if match_word in match_bug_text:
+                    matches = matches + 1
+            if matches >= 10:
+                print(f"Bug: {str(bug['id'])} Summary: {bug['summary']}")
                 match = {}
+                match['match'] = True
                 match['id'] = bug['id']
                 match['summary'] = bug['summary']
+        yield log.addStdout(f"Line to match: 
{self.getProperty('error_dict')['title_issue']}\n")
         if match:
-            yield log.addStdout('Match bug found\n')
-            yield log.addStdout('Bug: ' + str(match['id']) + ' Summary: ' + 
match['summary'] +'\n')
+            yield log.addStdout('Match bug: YES\n')
+            yield log.addStdout(f"Bug: {str(match['id'])} Summary: 
{match['summary']}\n")
             self.setProperty("bgo", match, 'bgo')
             return
-        yield log.addStdout('NO Match bug found\n')
-        self.setProperty("bgo", False, 'bgo')
+        yield log.addStdout('Match bug: NO\n')
 
     @defer.inlineCallbacks
     def run(self):

diff --git a/buildbot_gentoo_ci/steps/logs.py b/buildbot_gentoo_ci/steps/logs.py
index 164bb24..57f9394 100644
--- a/buildbot_gentoo_ci/steps/logs.py
+++ b/buildbot_gentoo_ci/steps/logs.py
@@ -91,6 +91,7 @@ class SetupPropertys(BuildStep):
         else:
             log_cpv = self.getProperty('cpv')
         self.setProperty("log_cpv", log_cpv, 'log_cpv')
+        self.setProperty("bgo", dict( match=False), 'bgo')
         self.descriptionDone = 'Runing log checker on ' + log_cpv
         return SUCCESS
 
@@ -333,6 +334,19 @@ class MakeIssue(BuildStep):
         yield log.addStdout(log_cpv['full_logname'] + '\n')
         yield log.addStdout('world.log' + '\n')
 
+    def getNiceErrorLine(self, line):
+        # strip away hex addresses, loong path names, line and time numbers 
and other stuff
+        # https://github.com/toralf/tinderbox/blob/main/bin/job.sh#L467
+        # FIXME: Add the needed line when needed
+        if re.search(': line', line):
+            line = re.sub(r"\d", "<snip>", line)
+        # Shorten the path
+        if line.startswith('/usr/'):
+            line = line.replace(os.path.split(line.split(' ', 1)[0])[0], 
'/...')
+        if re.search(': \d:\d: ', line):
+            line = re.sub(r":\d:\d: ", ": ", line)
+        return line
+
     def ClassifyIssue(self):
         # get the title for the issue
         text_issue_list = []
@@ -344,8 +358,10 @@ class MakeIssue(BuildStep):
         # add the issue error
         if text_issue_list != []:
             self.error_dict['title_issue'] = text_issue_list[0].replace('*', 
'').strip()
+            self.error_dict['title_issue_nice'] = 
self.getNiceErrorLine(text_issue_list[0].replace('*', '').strip())
         else:
             self.error_dict['title_issue'] = 'title_issue : None'
+            self.error_dict['title_nice'] = 'title_issue : None'
         self.error_dict['title_phase'] = 'failed in '+ self.error_dict['phase']
         #set the error title
         self.error_dict['title'] = self.error_dict['title_phase'] + ' - ' + 
self.error_dict['title_issue']

Reply via email to