mods/testing.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
Redirect to shields.io using the current set of failing builds to
determine whether to return success of failure.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
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 = obj.get_property("testing.failures")
+ if result.status == result.SUCCESS and result.name in failures:
+ failures.remove(result.name)
+ po.set_property('testing.failures', list(failures))
+ if result.status == result.FAILURE and result.name not in failures:
+ failures.add(result.name)
+ po.set_property('testing.failures', list(failures))
if result.name != "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'))
+ def www_view_badge(self, request, project):
+ po = Project.objects.filter(name=project).first()
+ if po.get_property('testing.failures'):
+ return HttpResponseRedirect('https://img.shields.io/badge/patchew-failing-critical.png')
+ else:
+ return HttpResponseRedirect('https://img.shields.io/badge/patchew-passing-success.png')
+
def www_url_hook(self, urlpatterns):
urlpatterns.append(url(r"^testing-reset/(?P<project_or_series>.*)/",
self.www_view_testing_reset,
@@ -228,6 +244,8 @@ class TestingModule(PatchewModule):
urlpatterns.append(url(r"^logs/(?P<project_or_series>.*)/testing.(?P<testing_name>.*)/",
TestingLogViewer.as_view(),
name="testing-log"))
+ urlpatterns.append(url(r"^(?P<project>[^/]*)/badge.svg$", self.www_view_badge,
+ name="testing-badge"))
def reverse_testing_log(self, obj, test, request=None, html=False):
if isinstance(obj, Message):
--
2.20.1
_______________________________________________
Patchew-devel mailing list
Patchew-devel@redhat.com
https://www.redhat.com/mailman/listinfo/patchew-devel
> On Mar 12, 2019, at 01:42, Paolo Bonzini <pbonzini@redhat.com> wrote:
>
> Redirect to shields.io using the current set of failing builds to
> determine whether to return success of failure.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> 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 = obj.get_property("testing.failures")
> + if result.status == result.SUCCESS and result.name in failures:
> + failures.remove(result.name)
> + po.set_property('testing.failures', list(failures))
> + if result.status == result.FAILURE and result.name not in failures:
> + failures.add(result.name)
> + po.set_property('testing.failures', list(failures))
>
> if result.name != "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'))
>
> + def www_view_badge(self, request, project):
> + po = Project.objects.filter(name=project).first()
> + if po.get_property('testing.failures'):
> + return HttpResponseRedirect('https://img.shields.io/badge/patchew-failing-critical.png')
> + else:
> + return HttpResponseRedirect('https://img.shields.io/badge/patchew-passing-success.png')
> +
I really like these little badges. Thanks!
Fam
> def www_url_hook(self, urlpatterns):
> urlpatterns.append(url(r"^testing-reset/(?P<project_or_series>.*)/",
> self.www_view_testing_reset,
> @@ -228,6 +244,8 @@ class TestingModule(PatchewModule):
> urlpatterns.append(url(r"^logs/(?P<project_or_series>.*)/testing.(?P<testing_name>.*)/",
> TestingLogViewer.as_view(),
> name="testing-log"))
> + urlpatterns.append(url(r"^(?P<project>[^/]*)/badge.svg$", self.www_view_badge,
> + name="testing-badge"))
>
> def reverse_testing_log(self, obj, test, request=None, html=False):
> if isinstance(obj, Message):
> --
> 2.20.1
>
> _______________________________________________
> Patchew-devel mailing list
> Patchew-devel@redhat.com
> https://www.redhat.com/mailman/listinfo/patchew-devel
_______________________________________________
Patchew-devel mailing list
Patchew-devel@redhat.com
https://www.redhat.com/mailman/listinfo/patchew-devel
© 2016 - 2025 Red Hat, Inc.