From nobody Fri Apr 19 16:53:49 2024 Delivered-To: importer2@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=patchew-devel-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=patchew-devel-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1552326185523961.0632275556151; Mon, 11 Mar 2019 10:43:05 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 38A37307E058; Mon, 11 Mar 2019 17:43:04 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2B1096012C; Mon, 11 Mar 2019 17:43:04 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 1E545181A136; Mon, 11 Mar 2019 17:43:04 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x2BHh3Md024585 for ; Mon, 11 Mar 2019 13:43:03 -0400 Received: by smtp.corp.redhat.com (Postfix) id 39BA91001DC3; Mon, 11 Mar 2019 17:43:03 +0000 (UTC) Received: from donizetti.redhat.com (ovpn-112-64.ams2.redhat.com [10.36.112.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9A67B100194A for ; Mon, 11 Mar 2019 17:43:00 +0000 (UTC) From: Paolo Bonzini To: patchew-devel@redhat.com Date: Mon, 11 Mar 2019 18:42:59 +0100 Message-Id: <20190311174259.16129-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: patchew-devel@redhat.com Subject: [Patchew-devel] [PATCH] testing: add a badge view X-BeenThere: patchew-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Patchew development and discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: patchew-devel-bounces@redhat.com Errors-To: patchew-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Mon, 11 Mar 2019 17:43:04 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Redirect to shields.io using the current set of failing builds to determine whether to return success of failure. Signed-off-by: Paolo Bonzini --- mods/testing.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/mods/testing.py b/mods/testing.py index 650990e..0cea58a 100644 --- a/mods/testing.py +++ b/mods/testing.py @@ -142,6 +142,15 @@ class TestingModule(PatchewModule): if isinstance(obj, Message): obj.set_property("testing.tested-base", self.get_msg_base_tags(obj)) + if isinstance(obj, Project): + # cache the last result so that badges are not affected by= RUNNING state + failures =3D obj.get_property("testing.failures") + if result.status =3D=3D result.SUCCESS and result.name in = failures: + failures.remove(result.name) + po.set_property('testing.failures', list(failures)) + if result.status =3D=3D result.FAILURE and result.name not= in failures: + failures.add(result.name) + po.set_property('testing.failures', list(failures)) =20 if result.name !=3D "git": return @@ -221,6 +230,13 @@ class TestingModule(PatchewModule): self.clear_and_start_testing(obj, request.GET.get("test", "")) return HttpResponseRedirect(request.META.get('HTTP_REFERER')) =20 + def www_view_badge(self, request, project): + po =3D Project.objects.filter(name=3Dproject).first() + if po.get_property('testing.failures'): + return HttpResponseRedirect('https://img.shields.io/badge/patc= hew-failing-critical.png') + else: + return HttpResponseRedirect('https://img.shields.io/badge/patc= hew-passing-success.png') + def www_url_hook(self, urlpatterns): urlpatterns.append(url(r"^testing-reset/(?P.*)/= ", self.www_view_testing_reset, @@ -228,6 +244,8 @@ class TestingModule(PatchewModule): urlpatterns.append(url(r"^logs/(?P.*)/testing.(= ?P.*)/", TestingLogViewer.as_view(), name=3D"testing-log")) + urlpatterns.append(url(r"^(?P[^/]*)/badge.svg$", self.www= _view_badge, + name=3D"testing-badge")) =20 def reverse_testing_log(self, obj, test, request=3DNone, html=3DFalse): if isinstance(obj, Message): --=20 2.20.1 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel