Skip to content

Commit

Permalink
fix: creating missing class and implementing expected features (#1215)
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolaMilosa authored Jan 16, 2025
1 parent 96c0a73 commit 42ea67d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 14 deletions.
12 changes: 3 additions & 9 deletions release-controller/reconciler.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,12 +266,6 @@ class ReplicaVersionProposalProvider(typing.Protocol):
def replica_version_proposals(self) -> dict[str, int]: ...


class SlackAnnouncerProtocol(typing.Protocol):
def announce_release(
self, webhook: str, version_name: str, google_doc_url: str, tag_all_teams: bool
) -> None: ...


class Reconciler:
"""Reconcile the state of the network with the release index, and create a forum post if needed."""

Expand All @@ -287,7 +281,7 @@ def __init__(
active_version_provider: ActiveVersionProvider,
replica_version_proposal_provider: ReplicaVersionProposalProvider,
dre: dre_cli.DRECli,
slack_announcer: SlackAnnouncerProtocol,
slack_announcer: slack_announce.SlackAnnouncerProtocol,
ignore_releases=None,
):
"""Create a new reconciler."""
Expand Down Expand Up @@ -549,7 +543,7 @@ def main():
)
ic_repo = (
GitRepo(
f"https://oauth2:{os.environ["GITHUB_TOKEN"]}@github.com/dfinity/ic.git",
f"https://oauth2:{os.environ['GITHUB_TOKEN']}@github.com/dfinity/ic.git",
main_branch="master",
)
if not dry_run
Expand All @@ -574,7 +568,7 @@ def main():
else dryrun.DRECli()
)
slack_announcer = (
slack_announce.announce_release if not dry_run else dryrun.MockSlackAnnouncer()
slack_announce.SlackAnnouncer() if not dry_run else dryrun.MockSlackAnnouncer()
)

reconciler = Reconciler(
Expand Down
32 changes: 27 additions & 5 deletions release-controller/slack_announce.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,36 @@
from dotenv import load_dotenv
from slack_sdk.http_retry.handler import RetryHandler
from slack_sdk.webhook import WebhookClient
import typing

from release_notes import RELEASE_NOTES_REVIEWERS


def announce_release(slack_url, version_name, google_doc_url, tag_all_teams):
slack = WebhookClient(url=slack_url, retry_handlers=[RetryHandler(max_retry_count=2)])
class SlackAnnouncerProtocol(typing.Protocol):
def announce_release(
self, webhook: str, version_name: str, google_doc_url: str, tag_all_teams: bool
) -> None: ...


class SlackAnnouncer(SlackAnnouncerProtocol):
def announce_release(
self, webhook: str, version_name: str, google_doc_url: str, tag_all_teams: bool
) -> None:
announce_release_on_slack(webhook, version_name, google_doc_url, tag_all_teams)


def announce_release_on_slack(slack_url, version_name, google_doc_url, tag_all_teams):
slack = WebhookClient(
url=slack_url, retry_handlers=[RetryHandler(max_retry_count=2)]
)
notify_line = (
" ".join([f"<!subteam^{t.slack_id}>" for t in RELEASE_NOTES_REVIEWERS if t.send_announcement])
" ".join(
[
f"<!subteam^{t.slack_id}>"
for t in RELEASE_NOTES_REVIEWERS
if t.send_announcement
]
)
if tag_all_teams
else "everyone"
)
Expand All @@ -26,13 +48,13 @@ def announce_release(slack_url, version_name, google_doc_url, tag_all_teams):
def main():
load_dotenv()

announce_release(
announce_release_on_slack(
os.environ["SLACK_WEBHOOK_URL"],
"release-2024-03-06_23-01-base",
"https://docs.google.com/document/d/1gCPmYxoq9_IccdChRzjoblAggTOdZ_IfTMukRbODO1I/edit#heading=h.7dcpz3fj7xrh",
True,
)
announce_release(
announce_release_on_slack(
os.environ["SLACK_WEBHOOK_URL"],
"release-2024-03-06_23-01-p2p",
"https://docs.google.com/document/d/1gCPmYxoq9_IccdChRzjoblAggTOdZ_IfTMukRbODO1I/edit#heading=h.7dcpz3fj7xrh",
Expand Down

0 comments on commit 42ea67d

Please sign in to comment.