From 38e9b3e83e3ab3c557666894d2526087c70ca26c Mon Sep 17 00:00:00 2001 From: CI Automation Date: Tue, 3 Sep 2024 15:25:57 +0200 Subject: [PATCH] feature(release-controller): Remove empty sections and extra empty lines from published notes --- release-controller/publish_notes.py | 3 + release-controller/test_publish_notes.py | 91 +++++++++++++++++++++++- 2 files changed, 92 insertions(+), 2 deletions(-) diff --git a/release-controller/publish_notes.py b/release-controller/publish_notes.py index dcebe3f14..20dfeb302 100644 --- a/release-controller/publish_notes.py +++ b/release-controller/publish_notes.py @@ -58,6 +58,9 @@ def exclusion_reason(line: str) -> str: changelog += "\n".join(lines) changelog += "\n" + # remove empty sections + changelog = re.sub(r"[^\n]+\n-+\n(?![^-]\*)", "", changelog, flags=re.S) + changelog = re.sub(r"\n{3,}", "\n\n", changelog, flags=re.S) return changelog diff --git a/release-controller/test_publish_notes.py b/release-controller/test_publish_notes.py index e1c98f4f5..ad6e597e3 100644 --- a/release-controller/test_publish_notes.py +++ b/release-controller/test_publish_notes.py @@ -82,8 +82,6 @@ def test_publish_if_ready__ready(mocker): ------------------------------------------- - - ## Excluded Changes ### Excluded by authors @@ -149,6 +147,95 @@ def test_publish_if_ready__ready(mocker): ) +def test_publish_if_ready__remove_empty_sections(mocker): + github_client = Github() + mocker.patch.object(github_client, "get_repo") + repo = github_client.get_repo("dfinity/non-existent-mock") + publish_client = PublishNotesClient(repo) + mocker.patch.object(publish_client, "ensure_published") + + publish_client.publish_if_ready( + """\ +Review checklist +================ + +Please cross\\-out your team once you finished the review + +* ~~@team-consensus~~ +* ~~@team-crypto~~ +* ~~@team-messaging~~ +* ~~@team-networking~~ +* ~~@node-team~~ +* ~~@team-runtime~~ + +Release Notes for [**rc--2024-02-21\\_23-01**](https://github.com/dfinity/ic/tree/rc--2024-02-21_23-01) (2e921c9adfc71f3edc96a9eb5d85fc742e7d8a9f) +================================================================================================================================================= + +Changelog since git revision [8d4b6898d878fa3db4028b316b78b469ed29f293](https://dashboard.internetcomputer.org/release/8d4b6898d878fa3db4028b316b78b469ed29f293) + +Bugfixes: +--------- + +Features: +--------- + +* ~~author: Igor Novg |~~ [5f9e639d1](https://github.com/dfinity/ic/commit/5f9e639d1) ~~Boundary Nodes: remove njs~~ +* ~~author: Igor Novg |~~ [eb7f3dc5c](https://github.com/dfinity/ic/commit/eb7f3dc5c) ~~Boundary Nodes: improve nginx performance~~ +* author: Kami Popi | [26f30f055](https://github.com/dfinity/ic/commit/26f30f055) Consensus: Purge non-finalized blocks and notarizations below the finalized height + +Tests: +------ + +Chores: +------- + +* author: ~~Leo Eich | [b4673936a](https://github.com/dfinity/ic/commit/b4673936a) Consensus(ecdsa):~~ Make key\\_unmasked\\_ref in PreSignatureQuadrupleRef required +* author: Leo Eich | [b733f7043](https://github.com/dfinity/ic/commit/b733f7043) Consensus(ecdsa): Extend Quadruple state machine in preparation for random unmasked kappa +* ~~author: Leo Eich | [6a4d8962c](https://github.com/dfinity/ic/commit/6a4d8962c) Consensus(ecdsa): Make masked kappa config optional~~ +* author: Leo Eich | [e76c5a374](https://github.com/dfinity/ic/commit/e76c5a374) Consensus(ecdsa): Stop relaying tECDSA signature shares + +Something: +---------- +* author: Leo Eich | [2d63da24c](https://github.com/dfinity/ic/commit/2d63da24c) Consensus(ecdsa): ~~Add optional kappa\\_unmasked config to QuadrupleInCreation~~ + +Other: +------ +""", + "2e921c9adfc71f3edc96a9eb5d85fc742e7d8a9f", + ) + + # assert publish_client.ensure_published.call_count == 1 + publish_client.ensure_published.assert_called_once_with( # pylint: disable=no-member + version="2e921c9adfc71f3edc96a9eb5d85fc742e7d8a9f", + changelog="""\ +Release Notes for [**rc--2024-02-21\\_23-01**](https://github.com/dfinity/ic/tree/rc--2024-02-21_23-01) (2e921c9adfc71f3edc96a9eb5d85fc742e7d8a9f) +================================================================================================================================================= + +Changelog since git revision [8d4b6898d878fa3db4028b316b78b469ed29f293](https://dashboard.internetcomputer.org/release/8d4b6898d878fa3db4028b316b78b469ed29f293) + +Features: +--------- + +* [`26f30f055`](https://github.com/dfinity/ic/commit/26f30f055) Consensus: Purge non-finalized blocks and notarizations below the finalized height + +Chores: +------- + +* [`b733f7043`](https://github.com/dfinity/ic/commit/b733f7043) Consensus(ecdsa): Extend Quadruple state machine in preparation for random unmasked kappa +* [`e76c5a374`](https://github.com/dfinity/ic/commit/e76c5a374) Consensus(ecdsa): Stop relaying tECDSA signature shares + +## Excluded Changes + +### Excluded by authors +* [`5f9e639d1`](https://github.com/dfinity/ic/commit/5f9e639d1) Boundary Nodes: remove njs +* [`eb7f3dc5c`](https://github.com/dfinity/ic/commit/eb7f3dc5c) Boundary Nodes: improve nginx performance +* [`b4673936a`](https://github.com/dfinity/ic/commit/b4673936a) Consensus(ecdsa): Make key\\_unmasked\\_ref in PreSignatureQuadrupleRef required +* [`6a4d8962c`](https://github.com/dfinity/ic/commit/6a4d8962c) Consensus(ecdsa): Make masked kappa config optional +* [`2d63da24c`](https://github.com/dfinity/ic/commit/2d63da24c) Consensus(ecdsa): Add optional kappa\\_unmasked config to QuadrupleInCreation +""", + ) + + def test_publish_if_ready__not_ready1(mocker): github_client = Github() mocker.patch.object(github_client, "get_repo")