From 679948e792ee51514d0c2944b575541d6288b71b Mon Sep 17 00:00:00 2001 From: Kurt Himebauch <136133082+xXJSONDeruloXx@users.noreply.github.com> Date: Thu, 8 Oct 2026 00:46:34 -0400 Subject: [PATCH] Include PR descriptions and queue catalog updates (#421) * Include a short PR description in build announcements * Queue catalog refreshes without cancelling publishing runs --- .github/workflows/update-catalog.yml | 1 + tools/release/pr_discord.py | 24 ++++++++++++++++++++++-- tools/tests/test_pr_discord.py | 26 ++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 2 deletions(-) diff --git a/.github/workflows/update-catalog.yml b/.github/workflows/update-catalog.yml index 25b40a399..d3a4075b5 100644 --- a/.github/workflows/update-catalog.yml +++ b/.github/workflows/update-catalog.yml @@ -13,6 +13,7 @@ permissions: concurrency: group: update-app-catalog cancel-in-progress: false + queue: max jobs: catalog: diff --git a/tools/release/pr_discord.py b/tools/release/pr_discord.py index acb5acdb5..6b1b01f4b 100644 --- a/tools/release/pr_discord.py +++ b/tools/release/pr_discord.py @@ -83,9 +83,29 @@ def plain_title(title): return re.sub(r"([\\`*_~|\[\]<>])", r"\\\1", title) -def build_content(repo, number, title, sha, apk, release): +def description_excerpt(body): + body = re.sub(r"", "", body or "", flags=re.DOTALL) + body = re.sub(r"```.*?```", "", body, flags=re.DOTALL) + for paragraph in re.split(r"\n\s*\n", body): + lines = [line.strip() for line in paragraph.splitlines()] + lines = [line for line in lines if line and not re.match(r"^(#{1,6}\s|[-*]\s+\[[ xX]\]|🤖)", line)] + text = " ".join(lines) + if not text or text.strip("*_` :.").lower() in ( + "summary", "description", "checklist", "testing", "n/a", "none", + "please describe your changes here", "describe your changes"): + continue + text = re.sub(r"\[([^\]]+)\]\([^)]+\)", r"\1", text) + if len(text) > 300: + text = text[:297].rsplit(" ", 1)[0] + "..." + return plain_title(text) + return "" + + +def build_content(repo, number, title, sha, apk, release, description=None): + excerpt = description_excerpt(description) return (f"**Signed PR test build** `pr-{number}` · `{sha[:7]}`\n" f"[#{number}](https://github.com/{repo}/pull/{number}): {plain_title(title)}\n" + + (f"\n{excerpt}\n\n" if excerpt else "") + "_Not merged — for testing._\n" f"Download: [standard APK](<{apk}>) · [all variants](<{release}>)") @@ -123,7 +143,7 @@ def sync(mode, repo, number, discord, sha="", apk="", release=""): {"content": retired_content(message["content"], pull.get("merged", False)), "allowed_mentions": {"parse": []}, "flags": 4}) return - content = build_content(repo, number, pull["title"], sha, apk, release) + content = build_content(repo, number, pull["title"], sha, apk, release, pull.get("body")) if len(content) > 1800: raise RuntimeError("Discord announcement is too long") payload = {"content": content, "allowed_mentions": {"parse": []}, "flags": 4} diff --git a/tools/tests/test_pr_discord.py b/tools/tests/test_pr_discord.py index 8de1d1d74..0533e7094 100644 --- a/tools/tests/test_pr_discord.py +++ b/tools/tests/test_pr_discord.py @@ -127,6 +127,32 @@ class PrDiscordTest(unittest.TestCase): self.assertIn(r"\~\~Retired\~\~", content) self.assertLessEqual(len(module.retired_content(content, True)), 2000) + def test_description_uses_first_useful_paragraph(self): + body = "## Summary\n\n\n\nFixes the [Store import](https://example.com).\n\nMore implementation detail." + content = module.build_content("Droid-Deck/DroidDeck", "400", "Store import", "a" * 40, "apk", "release", body) + self.assertIn("\n\nFixes the Store import.\n\n", content) + self.assertNotIn("private template", content) + self.assertNotIn("More implementation", content) + + def test_empty_and_template_descriptions_are_omitted(self): + for body in (None, "", "## Summary\n\n\n\n- [ ] Tests\n- [x] Code review", "N/A"): + self.assertEqual("", module.description_excerpt(body)) + + def test_description_cannot_override_status_or_ping(self): + self.pull["body"] = "~~Closed~~ @everyone\n\n```\nsecret template code\n```" + self.publish() + payload = self.discord.request.call_args.args[2] + self.assertIn(r"\~\~Closed\~\~ @everyone", payload["content"]) + self.assertNotIn("secret template", payload["content"]) + self.assertEqual({"parse": []}, payload["allowed_mentions"]) + + def test_long_description_leaves_room_for_retirement(self): + content = module.build_content("Droid-Deck/DroidDeck", "410", "*" * 300, "a" * 40, + "https://github.com/Droid-Deck/DroidDeck-CI/releases/download/pr-410/build.apk", + "https://github.com/Droid-Deck/DroidDeck-CI/releases/tag/pr-410", "~" * 10000) + self.assertLessEqual(len(content), 1800) + self.assertLessEqual(len(module.retired_content(content, True)), 2000) + original_report = module.report_comment