Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

omap notification subscription #579

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion kcidb/monitor/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,14 @@
LOGGER = logging.getLogger(__name__)


# pylint: disable=too-many-instance-attributes
class NotificationMessage:
"""
Message for a notification about a report object state.
"""
# It's OK pylint: disable=too-many-arguments
def __init__(self, to, subject, body, cc=None, bcc=None, id="", due=None):
def __init__(self, to, subject, body, cc=None, bcc=None, id="", due=None,
context=None):
"""
Initialize a notification message.

Expand Down Expand Up @@ -100,6 +102,7 @@ def __init__(self, to, subject, body, cc=None, bcc=None, id="", due=None):
self.bcc = bcc
self.id = id
self.due = due
self.context = context


class Notification:
Expand Down Expand Up @@ -180,6 +183,8 @@ def render(self):
ctx = {
self.obj.get_type().name: self.obj,
}
if self.message.context:
ctx.update(self.message.context)
subject = TEMPLATE_ENV.from_string(self.message.subject).render(ctx)
subject_extra_characters = \
len(subject) - NOTIFICATION_MESSAGE_SUBJECT_MAX_LEN
Expand Down
38 changes: 38 additions & 0 deletions kcidb/monitor/subscriptions/linux_omap.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
"""Linux omap subscription"""
from datetime import (timezone, datetime, timedelta)

from kcidb.monitor.output import NotificationMessage as Message


def match_revision(revision):
"""Match revisions of omap tree"""
# Repo we're interested in
repo_url = "https://git.kernel.org/pub/scm/linux/kernel/git/tmlind/" \
"linux-omap.git"

# If the revision is not from omap repo,
# or there are no finished builds

if repo_url not in revision.repo_branch_checkouts:
return ()

if revision.builds_valid is None:
return ()

# If the revision is not from 'maestro' or 'broonie' origin
if not {c.origin for c in revision.checkouts} & {'maestro', 'broonie'}:
return ()

# Send notification 3 hours after a revision is created/updated
return (Message(
subject='KernelCI report for omap: '
'{% include "stable_revision_summary.txt.j2" %}',
to=["Kevin Hilman <[email protected]>"],
cc=["KernelCI Results Staging <[email protected]>",
"Jeny Sadadia <[email protected]>",
"Gustavo Padovan <[email protected]>",
"Helen Mae Koike Fornazier <[email protected]>"],
body='{% include "stable_rc_revision_description.txt.j2" %}',
due=datetime.now(timezone.utc) + timedelta(hours=3),
context={'main_repo_url': repo_url}
),)
3 changes: 2 additions & 1 deletion kcidb/monitor/subscriptions/linux_stable_rc.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ def match_revision(revision):
"Shreeya Patel <[email protected]>"],
body='{% include "stable_rc_revision_description.txt.j2" %}',
cc=["KernelCI Results Staging <[email protected]>"],
due=datetime.now(timezone.utc) + timedelta(hours=3)
due=datetime.now(timezone.utc) + timedelta(hours=3),
context={'main_repo_url': repo_url}
),)
7 changes: 2 additions & 5 deletions kcidb/templates/stable_rc_revision_description.txt.j2
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,12 @@ REVISION
{% if revision.git_commit_hash %}
{{- " hash: " + revision.git_commit_hash }}
{% endif %}
{# The stable-rc repo's URL #}
{% set stable_rc_repo = 'https://git.kernel.org/pub/scm/linux/' +
'kernel/git/stable/linux-stable-rc.git' %}
{# List of other repo's URLs #}
{% set other_repos = revision.repo_branch_checkouts.keys() |
reject('==', stable_rc_repo) | reject("none") | list %}
reject('==', main_repo_url) | reject("none") | list %}
Checked out from
{{- "\n " +
(([stable_rc_repo] + (revision.repo_branch_checkouts[stable_rc_repo] | list)) |
(([main_repo_url] + (revision.repo_branch_checkouts[main_repo_url] | list)) |
reject("none") | join(" ")) }}
{% if other_repos %}
Also checked out from
Expand Down
Loading