From 9255b5fd9279e6a424368837e02899df81d72a62 Mon Sep 17 00:00:00 2001 From: Nikolay Yurin Date: Mon, 31 Jul 2023 18:57:46 -0700 Subject: [PATCH 1/2] src/base: Fix missing arguments for _setup() method Signed-off-by: Nikolay Yurin --- src/base.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/base.py b/src/base.py index 7ad1edf6a..4e3c7119a 100644 --- a/src/base.py +++ b/src/base.py @@ -24,6 +24,7 @@ def __init__(self, configs, args, name): api_token = os.getenv('KCI_API_TOKEN') self._api = kernelci.api.get_api(self._api_config, api_token) self._api_helper = APIHelper(self._api) + self._args = args @property def log(self): @@ -65,7 +66,7 @@ def run(self, args=None): context = None try: - context = self._setup(args) + context = self._setup(args or self._args) status = self._run(context) except KeyboardInterrupt: self.log.info("Stopping.") From 96440ab68558e90d740437a48c6d96a66bff12e9 Mon Sep 17 00:00:00 2001 From: Nikolay Yurin Date: Mon, 31 Jul 2023 18:59:04 -0700 Subject: [PATCH 2/2] src/test_report.py: Include patchwork metadata into reporting Signed-off-by: Nikolay Yurin --- config/reports/test-report.jinja2 | 7 ++++++- src/test_report.py | 32 ++++++++++++++++++++++--------- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/config/reports/test-report.jinja2 b/config/reports/test-report.jinja2 index e897bbfc3..78c82a226 100644 --- a/config/reports/test-report.jinja2 +++ b/config/reports/test-report.jinja2 @@ -9,7 +9,12 @@ Tree: {{ root.revision.tree }} Branch: {{ root.revision.branch }} Describe: {{ root.revision.describe }} URL: {{ root.revision.url }} -SHA1: {{ root.revision.commit }} +Commit: {{ root.revision.commit }} +{%- if patch %} +Patch Title: {{ patch["title"] }} +Patch URL: {{ patch["url"] }} +Patch Hash: {{ patch["hash"] }} +{%- endif %} {%- if groups.items() %} {{ '%-15s %s %-8s %s %-8s %s %-8s'|format( diff --git a/src/test_report.py b/src/test_report.py index c38de2c84..8d1868c25 100755 --- a/src/test_report.py +++ b/src/test_report.py @@ -83,28 +83,42 @@ def _get_results_data(self, root_node): 'groups': groups, } + def _get_patch_data(self, root_node): + root_node_data = root_node.get('data') + if not root_node_data: + return {} + + if patchwork_metadata := root_node_data.get('patchwork'): + if patchwork_metadata["version"] == 1: + patch = patchwork_metadata['payload']['patches'][0] + return { + 'title': "foobar", + 'hash': patch['hash'], + 'url': patch['web_url'], + } + + return {} + def _get_report(self, root_node): template_env = jinja2.Environment( loader=jinja2.FileSystemLoader("./config/reports/") ) template = template_env.get_template("test-report.jinja2") revision = root_node['revision'] + + patch_metadata = self._get_patch_data(root_node) + base_subject= f"[STAGING] {revision['tree']}/{revision['branch']} {revision['describe']}" if root_node['result'] == 'incomplete': - subject = (f"\ -[STAGING] {revision['tree']}/{revision['branch']} {revision['describe']}: \ -Failed to create source tarball for {root_node['name']}") + subject = (f"{base_subject}: Failed to create source tarball for {root_node['name']}") content = template.render( - subject=subject, root=root_node, groups={} + subject=subject, root=root_node, groups={}, patch=patch_metadata, ) else: results = self._get_results_data(root_node) stats = results['stats'] - groups = results['groups'] - subject = (f"\ -[STAGING] {revision['tree']}/{revision['branch']} {revision['describe']}: \ -{stats['total']} runs {stats['failures']} failures") + subject = (f"{base_subject}: {stats['total']} runs {stats['failures']} failures") content = template.render( - subject=subject, root=root_node, groups=groups + subject=subject, root=root_node, groups=results['groups'], patch=patch_metadata, ) return content, subject