From b95385adfd4aedf4f8cdc8e2342165e1d0544faa Mon Sep 17 00:00:00 2001 From: Alyssa Wilk Date: Tue, 26 Sep 2023 15:20:41 -0400 Subject: [PATCH 1/5] notifier: adding basic oncall notifications Signed-off-by: Alyssa Wilk --- .github/actions/pr_notifier/pr_notifier.py | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/.github/actions/pr_notifier/pr_notifier.py b/.github/actions/pr_notifier/pr_notifier.py index 4366327d28880..832136a4b338b 100644 --- a/.github/actions/pr_notifier/pr_notifier.py +++ b/.github/actions/pr_notifier/pr_notifier.py @@ -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 @@ -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( + "https://calendar.google.com/calendar/ical/d6glc0l5rc3v235q9l2j29dgovh3dn48%40import.calendar.google.com/public/basic.ics" + ) + 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() + return component.get("summary") + e.close() + return "unable to find this week's oncall" + + if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument( From ef9fdba0716d2b983e7b16effd49db4e7b21c808 Mon Sep 17 00:00:00 2001 From: Alyssa Wilk Date: Wed, 27 Sep 2023 08:44:28 -0400 Subject: [PATCH 2/5] in without txt Signed-off-by: Alyssa Wilk --- .github/actions/pr_notifier/requirements.in | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/actions/pr_notifier/requirements.in b/.github/actions/pr_notifier/requirements.in index b27ccacba25ae..e564157d3eeaa 100644 --- a/.github/actions/pr_notifier/requirements.in +++ b/.github/actions/pr_notifier/requirements.in @@ -1,2 +1,4 @@ pygithub slack_sdk +requests +icalendar From 41bc558e53ed7e014af6ed4515840f6314d47930 Mon Sep 17 00:00:00 2001 From: Alyssa Wilk Date: Wed, 27 Sep 2023 08:56:55 -0400 Subject: [PATCH 3/5] hashes! Signed-off-by: Alyssa Wilk --- .github/actions/pr_notifier/requirements.txt | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/.github/actions/pr_notifier/requirements.txt b/.github/actions/pr_notifier/requirements.txt index 4dfea44d18078..789b3ece9e541 100644 --- a/.github/actions/pr_notifier/requirements.txt +++ b/.github/actions/pr_notifier/requirements.txt @@ -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 @@ -203,6 +206,14 @@ 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 @@ -210,11 +221,13 @@ requests==2.31.0 \ 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 From 0b11399573c5ba47af316be896f3a5ede1609b4d Mon Sep 17 00:00:00 2001 From: Alyssa Wilk Date: Mon, 2 Oct 2023 09:11:24 -0400 Subject: [PATCH 4/5] comments Signed-off-by: Alyssa Wilk --- .github/actions/pr_notifier/pr_notifier.py | 14 +++++++------- .github/actions/pr_notifier/requirements.txt | 13 ++++++++----- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/.github/actions/pr_notifier/pr_notifier.py b/.github/actions/pr_notifier/pr_notifier.py index 832136a4b338b..14ddcd0cf1121 100644 --- a/.github/actions/pr_notifier/pr_notifier.py +++ b/.github/actions/pr_notifier/pr_notifier.py @@ -45,6 +45,9 @@ 'soulxu': 'U01GNQ3B8AY', } +# Oncall calendar +CALENDAR = "https://calendar.google.com/calendar/ical/d6glc0l5rc3v235q9l2j29dgovh3dn48%40import.calendar.google.com/public/basic.ics" + # First pass reviewers who are not maintainers should get # notifications but not result in a PR not getting assigned a # maintainer owner. @@ -238,20 +241,17 @@ def post_to_oncall(client, unassigned_prs, out_slo_prs): def parse_calendar(): - e = requests.get( - "https://calendar.google.com/calendar/ical/d6glc0l5rc3v235q9l2j29dgovh3dn48%40import.calendar.google.com/public/basic.ics" - ) - ecal = icalendar.Calendar.from_ical(e.text) + ical = requests.get(CALENDAR) + parsed_calendar = icalendar.Calendar.from_ical(ical.text) + ical.close() now = datetime.datetime.now() sunday = now - datetime.timedelta(days=now.weekday() + 1) - for component in ecal.walk(): + for component in parsed_calendar.walk(): if component.name == "VEVENT": if (sunday.date() == component.decoded("dtstart").date()): - e.close() return component.get("summary") - e.close() return "unable to find this week's oncall" diff --git a/.github/actions/pr_notifier/requirements.txt b/.github/actions/pr_notifier/requirements.txt index 789b3ece9e541..38ff679d66993 100644 --- a/.github/actions/pr_notifier/requirements.txt +++ b/.github/actions/pr_notifier/requirements.txt @@ -1,8 +1,8 @@ # -# This file is autogenerated by pip-compile -# To update, run: +# This file is autogenerated by pip-compile with Python 3.11 +# by the following command: # -# pip-compile --generate-hashes .github/actions/pr_notifier/requirements.txt +# pip-compile --allow-unsafe --generate-hashes requirements.in # certifi==2023.7.22 \ --hash=sha256:539cc1d13202e33ca466e88b2807e29f4c13049d6d87031a3c110744495cb082 \ @@ -170,6 +170,7 @@ deprecated==1.2.13 \ icalendar==5.0.10 \ --hash=sha256:34f0ca020b804758ddf316eb70d1d46f769bce64638d5a080cb65dd46cfee642 \ --hash=sha256:6e392c2f301b6b5f49433e14c905db3de444b12876f3345f1856a75e9cd8be6f + # via -r requirements.in idna==2.10 \ --hash=sha256:b307872f855b18632ce0c21c5e45be78c0ea7ae4c15c828c20788b26921eb3f6 \ --hash=sha256:b97d804b1e9b523befed77c48dacec60e6dcb0b5391d57af6a65a312a90648c0 @@ -217,7 +218,9 @@ pytz==2023.3.post1 \ requests==2.31.0 \ --hash=sha256:58cd2187c01e70e6e26505bca751777aa9f2ee0b7f4300988b709f44e013003f \ --hash=sha256:942c5a758f98d790eaed1a29cb6eefc7ffb0d1cf7af05c3d2791656dbd6ad1e1 - # via pygithub + # via + # -r requirements.in + # pygithub six==1.16.0 \ --hash=sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926 \ --hash=sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254 @@ -227,7 +230,7 @@ six==1.16.0 \ 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 From 636538046d69327d3a684cee40aab6c895d8894a Mon Sep 17 00:00:00 2001 From: Alyssa Wilk Date: Mon, 2 Oct 2023 16:05:24 -0400 Subject: [PATCH 5/5] merge fix Signed-off-by: Alyssa Wilk --- .github/actions/pr_notifier/requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/actions/pr_notifier/requirements.txt b/.github/actions/pr_notifier/requirements.txt index b1a7d04e7c473..cc6a4466bd8b1 100644 --- a/.github/actions/pr_notifier/requirements.txt +++ b/.github/actions/pr_notifier/requirements.txt @@ -210,11 +210,11 @@ pynacl==1.4.0 \ python-dateutil==2.8.2 \ --hash=sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86 \ --hash=sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9 - # via icalendar + # via pygithub pytz==2023.3.post1 \ --hash=sha256:7b4fddbeb94a1eba4b557da24f19fdf9db575192544270a9101d8509f9f43d7b \ --hash=sha256:ce42d816b81b68506614c11e8937d3aa9e41007ceb50bfdcb0749b921bf646c7 - # via pygithub + # via icalendar requests==2.31.0 \ --hash=sha256:58cd2187c01e70e6e26505bca751777aa9f2ee0b7f4300988b709f44e013003f \ --hash=sha256:942c5a758f98d790eaed1a29cb6eefc7ffb0d1cf7af05c3d2791656dbd6ad1e1