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

notifier: adding basic oncall notifications #29820

Merged
merged 6 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
25 changes: 25 additions & 0 deletions .github/actions/pr_notifier/pr_notifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
import os
import sys

import requests
import github
import icalendar
from slack_sdk import WebClient
from slack_sdk.errors import SlackApiError

Expand Down Expand Up @@ -226,10 +228,33 @@ def post_to_oncall(client, unassigned_prs, out_slo_prs):
text=(
"*Untriaged Issues* (please tag and cc area experts)\n<%s|%s>" %
(issue_link, issue_link)))
# On Monday, post the new oncall.
if datetime.date.today().weekday() == 0:
oncall = parse_calendar()
client.chat_postMessage(channel='#envoy-maintainer-oncall', text=(oncall))
client.chat_postMessage(channel='#general', text=(oncall))
except SlackApiError as e:
print("Unexpected error %s", e.response["error"])


def parse_calendar():
e = requests.get(
phlax marked this conversation as resolved.
Show resolved Hide resolved
"https://calendar.google.com/calendar/ical/d6glc0l5rc3v235q9l2j29dgovh3dn48%40import.calendar.google.com/public/basic.ics"
phlax marked this conversation as resolved.
Show resolved Hide resolved
)
ecal = icalendar.Calendar.from_ical(e.text)

now = datetime.datetime.now()
sunday = now - datetime.timedelta(days=now.weekday() + 1)

for component in ecal.walk():
if component.name == "VEVENT":
if (sunday.date() == component.decoded("dtstart").date()):
e.close()
phlax marked this conversation as resolved.
Show resolved Hide resolved
return component.get("summary")
e.close()
return "unable to find this week's oncall"


if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument(
Expand Down
2 changes: 2 additions & 0 deletions .github/actions/pr_notifier/requirements.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
pygithub
slack_sdk
requests
icalendar
17 changes: 15 additions & 2 deletions .github/actions/pr_notifier/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ deprecated==1.2.13 \
--hash=sha256:43ac5335da90c31c24ba028af536a91d41d53f9e6901ddb021bcc572ce44e38d \
--hash=sha256:64756e3e14c8c5eea9795d93c524551432a0be75629f8f29e67ab8caf076c76d
# via pygithub
icalendar==5.0.10 \
--hash=sha256:34f0ca020b804758ddf316eb70d1d46f769bce64638d5a080cb65dd46cfee642 \
--hash=sha256:6e392c2f301b6b5f49433e14c905db3de444b12876f3345f1856a75e9cd8be6f
idna==2.10 \
--hash=sha256:b307872f855b18632ce0c21c5e45be78c0ea7ae4c15c828c20788b26921eb3f6 \
--hash=sha256:b97d804b1e9b523befed77c48dacec60e6dcb0b5391d57af6a65a312a90648c0
Expand Down Expand Up @@ -203,18 +206,28 @@ pynacl==1.4.0 \
--hash=sha256:ea6841bc3a76fa4942ce00f3bda7d436fda21e2d91602b9e21b7ca9ecab8f3ff \
--hash=sha256:f8851ab9041756003119368c1e6cd0b9c631f46d686b3904b18c0139f4419f80
# via pygithub
python-dateutil==2.8.2 \
--hash=sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86 \
--hash=sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9
# via icalendar
pytz==2023.3.post1 \
--hash=sha256:7b4fddbeb94a1eba4b557da24f19fdf9db575192544270a9101d8509f9f43d7b \
--hash=sha256:ce42d816b81b68506614c11e8937d3aa9e41007ceb50bfdcb0749b921bf646c7
# via icalendar
requests==2.31.0 \
--hash=sha256:58cd2187c01e70e6e26505bca751777aa9f2ee0b7f4300988b709f44e013003f \
--hash=sha256:942c5a758f98d790eaed1a29cb6eefc7ffb0d1cf7af05c3d2791656dbd6ad1e1
# via pygithub
six==1.16.0 \
--hash=sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926 \
--hash=sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254
# via pynacl
# via
# pynacl
# python-dateutil
slack-sdk==3.22.0 \
--hash=sha256:6eacce0fa4f8cfb4d84eac0d7d7e1b1926040a2df654ae86b94179bdf2bc4d8c \
--hash=sha256:f102a4902115dff3b97c3e8883ad4e22d54732221886fc5ef29bfc290f063b4a
# via -r requirements.in
# via -r requirements.in
urllib3==1.26.6 \
--hash=sha256:39fb8672126159acb139a7718dd10806104dec1e2f0f6c88aab05d17df10c8d4 \
--hash=sha256:f57b4c16c62fa2760b7e3d97c35b255512fb6b59a259730f36ba32ce9f8e342f
Expand Down
Loading