From: Michael Tremer Date: Fri, 12 May 2023 20:33:17 +0000 (+0000) Subject: builds: Send an email if test builds fail X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=36edcaae6a35df4f08a466f1fceb61947c380a36;p=pbs.git builds: Send an email if test builds fail Signed-off-by: Michael Tremer --- diff --git a/Makefile.am b/Makefile.am index a851be67..4a5bea45 100644 --- a/Makefile.am +++ b/Makefile.am @@ -196,7 +196,8 @@ 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 \ - src/templates/builds/messages/finished.txt + src/templates/builds/messages/finished.txt \ + src/templates/builds/messages/test-builds-failed.txt templates_builds_messagesdir = $(templates_buildsdir)/messages diff --git a/src/buildservice/builds.py b/src/buildservice/builds.py index e4f0bf2d..256234fd 100644 --- a/src/buildservice/builds.py +++ b/src/buildservice/builds.py @@ -1002,6 +1002,15 @@ class Build(base.DataObject): test_builds = lazy_property(get_test_builds, set_test_builds) + async def _test_builds_finished(self, success): + """ + Called when all test builds have finished + """ + # Send an email on fail + if not success: + self._send_email("builds/messages/test-builds-failed.txt", + build=self, test_builds=self.test_builds) + class Groups(base.Object): """ @@ -1229,7 +1238,9 @@ class Group(base.DataObject): # Mark as finished self._set_attribute_now("finished_at") - # XXX call the build that that has created this group for test builds + # Call the build that has created this test group + if self.tested_build: + await self.tested_build._test_builds_finished(success=not self.has_failed()) async def failed(self): """ diff --git a/src/templates/builds/messages/test-builds-failed.txt b/src/templates/builds/messages/test-builds-failed.txt new file mode 100644 index 00000000..72414eae --- /dev/null +++ b/src/templates/builds/messages/test-builds-failed.txt @@ -0,0 +1,21 @@ +To: {{ recipient.email_to }} +Subject: [{{ build }}] {{ _("Test Builds Failed") }} +Message-Id: +In-Reply-To: +References: + +{{ _("Hello %s,") % recipient }} + +{{ _("This is an automated email to let you know that the automated test build for your build has failed:", + "This is an automated email to let you know that the automated test builds for your build have failed:", + len(test_builds)) }} + + /builds/{{ build.uuid }} + +{{ _("Test Builds") }}: + +{% for t in test_builds %} + * {% if t.is_successful() %}SUCCESS{% elif t.has_failed() %}FAILED {% end %} {{ t }}{% end %} + +{{ _("Sincerely,") }} +-{{ _("The Pakfire Build Service") }}