From: Michael Tremer Date: Wed, 3 May 2023 18:14:17 +0000 (+0000) Subject: builds: Show any created test builds X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=548cc46a7b06e12ff9dba983e60e424ef45f66b7;p=pbs.git builds: Show any created test builds Signed-off-by: Michael Tremer --- diff --git a/Makefile.am b/Makefile.am index 23593c5c..0e90e1a4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -184,6 +184,13 @@ dist_templates_builds_DATA = \ templates_buildsdir = $(templatesdir)/builds +templates_builds_groupsdir = $(templates_buildsdir)/groups + +dist_templates_builds_groups_modules_DATA = \ + src/templates/builds/groups/modules/list.html + +templates_builds_groups_modulesdir = $(templates_builds_groupsdir)/modules + dist_templates_builds_messages_DATA = \ src/templates/builds/messages/comment.txt \ src/templates/builds/messages/failed.txt \ diff --git a/src/buildservice/builds.py b/src/buildservice/builds.py index e0b5cd07..3f687901 100644 --- a/src/buildservice/builds.py +++ b/src/buildservice/builds.py @@ -679,6 +679,18 @@ class Build(base.DataObject): return False + def has_failed(self): + """ + Returns True if this build has failed + """ + return self.has_finished() and self.data.failed + + def is_successful(self): + """ + Returns True if this build was successful + """ + return self.has_finished() and not self.data.failed + def _send_email(self, *args, exclude=None, **kwargs): """ Convenience function which sends an email to everybody who would care @@ -1032,6 +1044,9 @@ class Group(base.DataObject): def __iter__(self): return iter(self.builds) + def __len__(self): + return len(self.builds) + # UUID @property @@ -1062,6 +1077,20 @@ class Group(base.DataObject): return list(builds) + @property + def successful_builds(self): + """ + Returns all successful builds in this group + """ + return [b for b in self.builds if b.is_successful()] + + @property + def failed_builds(self): + """ + Returns all failed builds in this group + """ + return [b for b in self.builds if b.has_failed()] + # Delete async def delete(self, user=None): @@ -1079,6 +1108,26 @@ class Group(base.DataObject): def deleted_at(self): return self.data.deleted_at + # Functions to find out whether this was all successful/failed + + def has_failed(self): + """ + Returns True if at least one job has failed + """ + return any((b.has_failed() for b in self.builds)) + + def is_successful(self): + """ + Returns True if all jobs have been successful + """ + return all((b.is_successful() for b in self.builds)) + + def has_finished(self): + """ + Returns True if all builds have finished + """ + return all((b.has_finished() for b in self.builds)) + class Comments(base.Object): def _get_comments(self, query, *args): diff --git a/src/templates/builds/groups/modules/list.html b/src/templates/builds/groups/modules/list.html new file mode 100644 index 00000000..9f14c7fb --- /dev/null +++ b/src/templates/builds/groups/modules/list.html @@ -0,0 +1,61 @@ + diff --git a/src/templates/builds/show.html b/src/templates/builds/show.html index 8e685610..2cacd711 100644 --- a/src/templates/builds/show.html +++ b/src/templates/builds/show.html @@ -223,6 +223,14 @@ {% end %} + {% if build.test_builds %} +
+
{{ _("Test Builds")}}
+ + {% module BuildGroupList(build.test_builds, limit=8) %} +
+ {% end %} + {# Log #}
{{ _("Log") }}
diff --git a/src/web/__init__.py b/src/web/__init__.py index ada33433..54241034 100644 --- a/src/web/__init__.py +++ b/src/web/__init__.py @@ -46,6 +46,9 @@ class Application(tornado.web.Application): # Builds "BuildsList" : builds.ListModule, + # BuildGroups + "BuildGroupList" : builds.GroupListModule, + # Builders "BuilderStats" : builders.StatsModule, diff --git a/src/web/builds.py b/src/web/builds.py index ff1694d8..a9e81ded 100644 --- a/src/web/builds.py +++ b/src/web/builds.py @@ -161,3 +161,9 @@ class CommentHandler(base.BaseHandler): class ListModule(ui_modules.UIModule): def render(self, builds): return self.render_string("builds/modules/list.html", builds=builds) + + +class GroupListModule(ui_modules.UIModule): + def render(self, group, limit=None): + return self.render_string("builds/groups/modules/list.html", + group=group, limit=limit)