diff mbox series

[yocto-autobuilder2,2/2] steps: observer: Add links to ptest logs

Message ID 20251013-contrib-mathieu-bb-log-links-v1-2-79db0af7bdce@bootlin.com
State New
Headers show
Series steps: observer: Extract yocto.io links form logs | expand

Commit Message

Mathieu Dubois-Briand Oct. 13, 2025, 3:07 p.m. UTC
Finding the ptest logs corresponding to a build can be a bit tricky: it
requires to find the correct yocto.io link, then the correct subfolder
corresponding to the builder and the correct ptest image.

Generate this link in the log parser and add it in the links log
section, so users don't have to do all of this by hand.

Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
---
 steps/observer.py | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
diff mbox series

Patch

diff --git a/steps/observer.py b/steps/observer.py
index 555321993836..a89f0c5b1962 100644
--- a/steps/observer.py
+++ b/steps/observer.py
@@ -29,15 +29,19 @@  class SimpleLogObserver(ShellCommand):
 
     def __init__(self, maxsteps=10, *args, **kwargs):
         super().__init__(*args, **kwargs)
+        self.builder = None
         self.warningLines = []
         self.errorLines = []
         self.links = []
+        self.failed_ptests = []
+        self.testResultsLink = None
         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[^/]*/)([^ ']|$)+).*")
+        self.ptest_fails_re = re.compile(r"WARNING: (\S*)-[0-9.]*-r[0-9]* do_testimage:")
 
     def describe(self, done=False):
         return self.description
@@ -48,12 +52,19 @@  class SimpleLogObserver(ShellCommand):
             if line.startswith("WARNING:"):
                 self.warnCount += 1
                 self.warningLines.append(logname + ": " + line)
+                match = self.ptest_fails_re.match(line)
+                if match:
+                    self.failed_ptests.append(match.group(1))
             if line.startswith("ERROR:"):
                 self.errorCount += 1
                 self.errorLines.append(logname + ": " + line)
+            if line.startswith("Builder:"):
+                self.builder = line.split(':')[1].strip()
             url, matched = self.yocto_io_re.subn('https://\\1', line)
             if matched:
                 self.links.append(url)
+                if not self.testResultsLink and url.endswith("/testresults"):
+                    self.testResultsLink = url
 
     @defer.inlineCallbacks
     def finish_logs(self):
@@ -71,6 +82,12 @@  class SimpleLogObserver(ShellCommand):
             links = list(dict.fromkeys(self.links))
             htmlLinks = ['Found links:<ul>']
             htmlLinks.extend([f'<li><a href="{link}">{link}</a></li>' for link in links])
+
+            if self.testResultsLink and self.builder:
+                htmlLinks.extend(['</ul>ptest logs:<ul>'])
+                ptestLinks = [f"{self.testResultsLink}/{self.builder}/{ptest}"
+                              for ptest in self.failed_ptests]
+                htmlLinks.extend([f'<li><a href="{link}">{link}</a></li>' for link in ptestLinks])
             htmlLinks.append('</ul>')
             yield self.addHTMLLog('links', '\n'.join(htmlLinks))