Skip to content

Commit

Permalink
More changes to typing.g
Browse files Browse the repository at this point in the history
  • Loading branch information
DFINITYManu committed Jan 16, 2025
2 parents cc4bee7 + 42ea67d commit ab6617f
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 23 deletions.
29 changes: 11 additions & 18 deletions release-controller/reconciler.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,14 @@ def version_package_checksum(version: str) -> str:
f"https://download.dfinity.systems/ic/{version}/guest-os/update-img/SHA256SUMS"
)
response = requests.get(hashurl, timeout=10)
checksum = [
line
for line in response.content.decode("utf-8").splitlines()
if line.strip().endswith("update-img.tar.zst")
][0].split(" ")[0]
checksum = typing.cast(
str,
[
line
for line in response.content.decode("utf-8").splitlines()
if line.strip().endswith("update-img.tar.zst")
][0].split(" ")[0],
)

for u in version_package_urls(version):
LOGGER.getChild("version_package_checksum").debug("fetching package %s", u)
Expand All @@ -190,16 +193,6 @@ class ReplicaVersionProposalProvider(typing.Protocol):
def replica_version_proposals(self) -> dict[str, int]: ...


class SlackAnnouncerProtocol(typing.Protocol):
def announce_release(
self,
slack_url: 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 @@ -215,7 +208,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: list[str] | None = None,
):
"""Create a new reconciler."""
Expand Down Expand Up @@ -481,7 +474,7 @@ def main() -> None:
)
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 Down Expand Up @@ -512,7 +505,7 @@ def main() -> None:
dre.get_past_election_proposals(),
)
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
36 changes: 31 additions & 5 deletions release-controller/slack_announce.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,40 @@
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,
slack_url: 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 +52,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
6 changes: 6 additions & 0 deletions release-index.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
releases:
# NOTE: Make sure to mark security hotfixes with the `security_fix: true` flag.
- rc_name: rc--2025-01-16_16-18
versions:
# Qualification pipeline:
# https://github.com/dfinity/ic/actions/runs/12813102877
- name: base
version: 233c1ee2ef68c1c8800b8151b2b9f38e17b8440a
- rc_name: rc--2025-01-09_03-19
versions:
# Qualification pipeline:
Expand Down

0 comments on commit ab6617f

Please sign in to comment.