diff mbox series

[swat-tools] Add a parent build column and filter

Message ID 20250620-parent-build-filter-v1-1-4ddd7b3207c8@bootlin.com
State New
Headers show
Series [swat-tools] Add a parent build column and filter | expand

Commit Message

Antonin Godard June 20, 2025, 9:08 a.m. UTC
To be able to filter failures by parent build number, e.g. filter all
failures for a-full build number xyz, add a --parent-build-filter (-p)
option to swattool. The option can be passed multiple times and can be a
regular expression.

It is also displayed by default in show-pending-failures, after the
column "Build" as "Parent".

Signed-off-by: Antonin Godard <antonin.godard@bootlin.com>
---
 swattool/main.py      | 6 ++++++
 swattool/swatbuild.py | 4 +++-
 2 files changed, 9 insertions(+), 1 deletion(-)


---
base-commit: 8930d3e3f71dc3d2a33e8df5ade430deeeb7019b
change-id: 20250620-parent-build-filter-cd0c6ab8d86d

Best regards,

Comments

Mathieu Dubois-Briand July 8, 2025, 1:44 p.m. UTC | #1
On Fri Jun 20, 2025 at 11:08 AM CEST, Antonin Godard wrote:
> To be able to filter failures by parent build number, e.g. filter all
> failures for a-full build number xyz, add a --parent-build-filter (-p)
> option to swattool. The option can be passed multiple times and can be a
> regular expression.
>
> It is also displayed by default in show-pending-failures, after the
> column "Build" as "Parent".
>
> Signed-off-by: Antonin Godard <antonin.godard@bootlin.com>
> ---

Hi Antonin,

I really like the overall idea, but I believe we should also add a way
to identify the buildbot instance this build number belongs to. As the
build number is not unique across different instances. E.g. You have ids
that can refer either to builds on valkyrie or typhoon.

On the other hand I don't want to end-up with overly complicated ids, nor
overly complicated logic here. Maybe we can just use ids such as vk/1234
or tp/1234 and have a built-in list of known buildbot instances to do
the association.

Tell me if you want to work on it, otherwise I will try to rework a bit
your patch later this week.
Mathieu Dubois-Briand July 8, 2025, 1:47 p.m. UTC | #2
On Fri, 20 Jun 2025 11:08:15 +0200, Antonin Godard wrote:
> To be able to filter failures by parent build number, e.g. filter all
> failures for a-full build number xyz, add a --parent-build-filter (-p)
> option to swattool. The option can be passed multiple times and can be a
> regular expression.
> 
> It is also displayed by default in show-pending-failures, after the
> column "Build" as "Parent".
> 
> [...]

Applied, thanks!

[1/1] Add a parent build column and filter
      (no commit info)

Best regards,
Antonin Godard July 9, 2025, 7:15 a.m. UTC | #3
Hi,

On Tue Jul 8, 2025 at 3:44 PM CEST, Mathieu Dubois-Briand wrote:
> On Fri Jun 20, 2025 at 11:08 AM CEST, Antonin Godard wrote:
>> To be able to filter failures by parent build number, e.g. filter all
>> failures for a-full build number xyz, add a --parent-build-filter (-p)
>> option to swattool. The option can be passed multiple times and can be a
>> regular expression.
>>
>> It is also displayed by default in show-pending-failures, after the
>> column "Build" as "Parent".
>>
>> Signed-off-by: Antonin Godard <antonin.godard@bootlin.com>
>> ---
>
> Hi Antonin,
>
> I really like the overall idea, but I believe we should also add a way
> to identify the buildbot instance this build number belongs to. As the
> build number is not unique across different instances. E.g. You have ids
> that can refer either to builds on valkyrie or typhoon.

Indeed I did not factor that in when writing this!

> On the other hand I don't want to end-up with overly complicated ids, nor
> overly complicated logic here. Maybe we can just use ids such as vk/1234
> or tp/1234 and have a built-in list of known buildbot instances to do
> the association.

Maybe we can default to the currently active buildbot instance (so no vk/ or tp/
prefix, just defaults to valkyrie). The prefix can then be added if needed?

> Tell me if you want to work on it, otherwise I will try to rework a bit
> your patch later this week.

I can try but I can't tell you when I'll have the time, especially this week I'm
pretty busy, so give it a try if you want and CC me in if you want some
feedback. :)

Antonin
diff mbox series

Patch

diff --git a/swattool/main.py b/swattool/main.py
index a101340..7fe312d 100755
--- a/swattool/main.py
+++ b/swattool/main.py
@@ -73,6 +73,7 @@  def parse_filters(kwargs) -> dict[str, Any]:
         completed_before = kwargs['completed_before'].astimezone()
 
     filters = {'build': regex_filter(kwargs['build_filter']),
+               'parent_build_number': regex_filter(kwargs['parent_build_filter']),
                'test': regex_filter(kwargs['test_filter']),
                'ignore-test': regex_filter(kwargs['ignore_test_filter']),
                'status': statuses,
@@ -184,6 +185,8 @@  failures_list_options = [
                  help="Only show some tests"),
     click.option('--build-filter', '-b', multiple=True,
                  help="Only show some builds"),
+    click.option('--parent-build-filter', '-p', multiple=True,
+                 help="Only show some builds with parent build id"),
     click.option('--owner-filter', '-o', multiple=True,
                  help='Only show some owners ("none" for no owner)'),
     click.option('--ignore-test-filter', '-T', multiple=True,
@@ -223,6 +226,8 @@  def _format_pending_failures(builds: list[swatbuild.Build],
                              ) -> tuple[list[list[str]], list[str]]:
     # Generate a list of formatted builds on failures.
     def format_header(field):
+        if field == swatbuild.Field.PARENT_BUILD_NUMBER:
+            return "Parent"
         if field == swatbuild.Field.STATUS:
             return "Sts"
         return str(field)
@@ -284,6 +289,7 @@  def _show_failures(refresh: str, urlopens: set[str], limit: int,
 
     shown_fields_all = [
         swatbuild.Field.BUILD,
+        swatbuild.Field.PARENT_BUILD_NUMBER,
         swatbuild.Field.STATUS,
         swatbuild.Field.TEST,
         swatbuild.Field.OWNER,
diff --git a/swattool/swatbuild.py b/swattool/swatbuild.py
index 3d3c91c..4ccf32f 100644
--- a/swattool/swatbuild.py
+++ b/swattool/swatbuild.py
@@ -102,6 +102,7 @@  class Field(enum.StrEnum):
     USER_NOTES = 'Notes'
     USER_STATUS = 'New Triage'
     TRIAGE = 'Triage'
+    PARENT_BUILD_NUMBER = 'Parent Build Number'
 
 
 class Failure:
@@ -402,7 +403,8 @@  class Build:
         if not all(simple_match(field) for field in simple_filters):
             return False
 
-        regex_filters = [Field.BUILD, Field.OWNER, Field.TEST]
+        regex_filters = [Field.BUILD, Field.OWNER, Field.TEST,
+                         Field.PARENT_BUILD_NUMBER]
         if not all(regex_match(field) for field in regex_filters):
             return False