steps: observer: Extract yocto.io links form logs

Add a new log section on build steps, with yocto.io links found on
stdio.

Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Mathieu Dubois-Briand 2025-10-13 17:07:54 +02:00 committed by Richard Purdie
parent 0dc19a8f0b
commit 0b67c49848

View File

@ -2,6 +2,8 @@
# SPDX-License-Identifier: GPL-2.0-only
#
import re
from twisted.internet import defer
from twisted.python import log
@ -29,11 +31,13 @@ class SimpleLogObserver(ShellCommand):
super().__init__(*args, **kwargs)
self.warningLines = []
self.errorLines = []
self.links = []
if "description" in kwargs:
self.description = kwargs["description"]
else:
self.description = "run-config"
self.addLogObserver('stdio', logobserver.LineConsumerLogObserver(partial(self.logConsumer, 'stdio')))
self.yocto_io_re = re.compile(".*/([^/]*yocto.io/pub/(non-release|repro-fail[^/]*/)([^ ']|$)+).*")
def describe(self, done=False):
return self.description
@ -47,6 +51,9 @@ class SimpleLogObserver(ShellCommand):
if line.startswith("ERROR:"):
self.errorCount += 1
self.errorLines.append(logname + ": " + line)
url, matched = self.yocto_io_re.subn('https://\\1', line)
if matched:
self.links.append(url)
@defer.inlineCallbacks
def finish_logs(self):
@ -59,6 +66,13 @@ class SimpleLogObserver(ShellCommand):
yield self.addCompleteLog('warnings', '\n'.join(self.warningLines) + '\n')
if self.errorLines:
yield self.addCompleteLog('errors', '\n'.join(self.errorLines) + '\n')
if self.links:
# Remove duplicates but preserve order
links = list(dict.fromkeys(self.links))
htmlLinks = ['Found links:<ul>']
htmlLinks.extend([f'<li><a href="{link}">{link}</a></li>' for link in links])
htmlLinks.append('</ul>')
yield self.addHTMLLog('links', '\n'.join(htmlLinks))
warnings_stat = self.getStatistic('warnings', 0)
self.setStatistic('warnings', warnings_stat + self.warnCount)