From 80bdc6cba3fb8bb130f8e0ce3270ffa53c86f6cb Mon Sep 17 00:00:00 2001 From: BigOrangeQWQ <2284086963@qq.com> Date: Wed, 16 Apr 2025 22:16:02 +0800 Subject: [PATCH 1/4] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=E6=B5=8B=E8=AF=95=E7=BB=93=E6=9E=9C=E7=9A=84=E5=8D=A1?= =?UTF-8?q?=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../github/plugins/publish/constants.py | 4 +++- src/plugins/github/plugins/publish/render.py | 24 +++++++++++++++---- .../publish/templates/comment.md.jinja | 4 ++-- .../config/process/test_config_check.py | 2 +- .../publish/process/test_publish_check.py | 12 +++++----- .../process/test_publish_check_plugin.py | 8 +++++-- .../render/test_publish_render_data.py | 10 ++++---- .../render/test_publish_render_error.py | 14 +++++++++-- 8 files changed, 56 insertions(+), 22 deletions(-) diff --git a/src/plugins/github/plugins/publish/constants.py b/src/plugins/github/plugins/publish/constants.py index d6191964..0876688a 100644 --- a/src/plugins/github/plugins/publish/constants.py +++ b/src/plugins/github/plugins/publish/constants.py @@ -6,7 +6,6 @@ BRANCH_NAME_PREFIX = "publish/issue" - # 基本信息 PROJECT_LINK_PATTERN = re.compile(ISSUE_PATTERN.format("PyPI 项目名")) TAGS_PATTERN = re.compile(ISSUE_PATTERN.format("标签")) @@ -47,6 +46,9 @@ ADAPTER_MODULE_NAME_PATTERN = re.compile(ISSUE_PATTERN.format("适配器 import 包名")) ADAPTER_HOMEPAGE_PATTERN = re.compile(ISSUE_PATTERN.format("适配器项目仓库/主页链接")) +# 评论卡片模板 +COMMENT_CARD_TEMPLATE = """[]({url})""" + # 发布信息项对应的中文名 LOC_NAME_MAP = { "name": "名称", diff --git a/src/plugins/github/plugins/publish/render.py b/src/plugins/github/plugins/publish/render.py index 03ff6cf7..09e29b54 100644 --- a/src/plugins/github/plugins/publish/render.py +++ b/src/plugins/github/plugins/publish/render.py @@ -10,7 +10,7 @@ from src.providers.validation import ValidationDict from src.providers.validation.models import PublishType -from .constants import LOC_NAME_MAP +from .constants import COMMENT_CARD_TEMPLATE, LOC_NAME_MAP def tags_to_str(tags: list[dict[str, str]]) -> str: @@ -98,12 +98,28 @@ async def render_comment(result: ValidationDict, reuse: bool = False) -> str: # 按照 display_keys 顺序展示数据 data = {key: valid_data[key] for key in display_keys if key in valid_data} - # homepage 字段单独处理,提供快捷插件审核入口 - homepage: str | None = data.get("homepage") + card: list[str] = [] + if homepage := data.get("homepage"): + card.append(COMMENT_CARD_TEMPLATE.format( + name="主页", + head="HOMEPAGE", + content=homepage, + color="green", + url=homepage, + )) + if action_url := data.get("action_url"): + card.append(COMMENT_CARD_TEMPLATE.format( + name="测试结果", + head="RESULT", + content="OK" if result.valid else "ERROR", + color="green" if result.valid else "red", + url=action_url, + )) template = env.get_template("comment.md.jinja") return await template.render_async( - homepage=homepage, + card=" ".join(card), + action_url=action_url, reuse=reuse, title=title, valid=result.valid, diff --git a/src/plugins/github/plugins/publish/templates/comment.md.jinja b/src/plugins/github/plugins/publish/templates/comment.md.jinja index 43b49be4..a020e943 100644 --- a/src/plugins/github/plugins/publish/templates/comment.md.jinja +++ b/src/plugins/github/plugins/publish/templates/comment.md.jinja @@ -5,8 +5,8 @@ > {{ title }} -{% if homepage %} -[]({{ homepage }}) +{% if card %} +{{ card }} {% endif -%} diff --git a/tests/plugins/github/config/process/test_config_check.py b/tests/plugins/github/config/process/test_config_check.py index d0d0f57c..77a37dd7 100644 --- a/tests/plugins/github/config/process/test_config_check.py +++ b/tests/plugins/github/config/process/test_config_check.py @@ -137,7 +137,7 @@ async def test_process_config_check( > Plugin: name -[](https://nonebot.dev) +[](https://nonebot.dev) [](https://github.com/owner/repo/actions/runs/123456) **✅ 所有测试通过,一切准备就绪!** diff --git a/tests/plugins/github/publish/process/test_publish_check.py b/tests/plugins/github/publish/process/test_publish_check.py index b101fe97..ffeb745c 100644 --- a/tests/plugins/github/publish/process/test_publish_check.py +++ b/tests/plugins/github/publish/process/test_publish_check.py @@ -91,7 +91,7 @@ async def test_bot_process_publish_check( > Bot: test -[](https://nonebot.dev) +[](https://nonebot.dev) **✅ 所有测试通过,一切准备就绪!** @@ -250,7 +250,7 @@ async def test_adapter_process_publish_check( > Adapter: test -[](https://nonebot.dev) +[](https://nonebot.dev) **✅ 所有测试通过,一切准备就绪!** @@ -428,7 +428,7 @@ async def test_edit_title( > Bot: test1 -[](https://nonebot.dev) +[](https://nonebot.dev) **✅ 所有测试通过,一切准备就绪!** @@ -617,7 +617,7 @@ async def test_edit_title_too_long( > Bot: looooooooooooooooooooooooooooooooooooooooooooooooooooooong -[](https://nonebot.dev) +[](https://nonebot.dev) **⚠️ 在发布检查过程中,我们发现以下问题:** @@ -1108,7 +1108,7 @@ async def test_process_publish_check_ready_for_review( > Bot: test -[](https://nonebot.dev) +[](https://nonebot.dev) **✅ 所有测试通过,一切准备就绪!** @@ -1293,7 +1293,7 @@ async def test_comment_immediate_after_pull_request_closed( > Bot: test -[](https://nonebot.dev) +[](https://nonebot.dev) **✅ 所有测试通过,一切准备就绪!** diff --git a/tests/plugins/github/publish/process/test_publish_check_plugin.py b/tests/plugins/github/publish/process/test_publish_check_plugin.py index 15383eda..00f05d4c 100644 --- a/tests/plugins/github/publish/process/test_publish_check_plugin.py +++ b/tests/plugins/github/publish/process/test_publish_check_plugin.py @@ -192,7 +192,7 @@ async def test_plugin_process_publish_check( > Plugin: name -[](https://nonebot.dev) +[](https://nonebot.dev) [](https://github.com/owner/repo/actions/runs/123456) **✅ 所有测试通过,一切准备就绪!** @@ -454,7 +454,7 @@ async def test_plugin_process_publish_check_re_run( > Plugin: name -[](https://nonebot.dev) +[](https://nonebot.dev) [](https://github.com/owner/repo/actions/runs/123456) **✅ 所有测试通过,一切准备就绪!** @@ -700,6 +700,8 @@ async def test_plugin_process_publish_check_missing_metadata( > Plugin: project_link +[](https://github.com/owner/repo/actions/runs/123456) + **⚠️ 在发布检查过程中,我们发现以下问题:**
⚠️ 无法获取到插件元数据。请确保插件正常加载。
@@ -953,6 +955,8 @@ async def test_skip_plugin_check(
> Plugin: project_link
+[](https://github.com/owner/repo/actions/runs/123456)
+
**⚠️ 在发布检查过程中,我们发现以下问题:**
⚠️ 名称: 无法匹配到数据。请确保填写该数据项。 ⚠️ 描述: 无法匹配到数据。请确保填写该数据项。 ⚠️ 项目仓库/主页链接: 无法匹配到数据。请确保填写该数据项。 ⚠️ 插件类型: 无法匹配到数据。请确保填写该数据项。 ⚠️ 插件支持的适配器: 无法匹配到数据。请确保填写该数据项。 ⚠️ 无法获取到插件元数据。请确保插件正常加载。
diff --git a/tests/plugins/github/publish/render/test_publish_render_data.py b/tests/plugins/github/publish/render/test_publish_render_data.py
index 80ce5e73..aa9d49b5 100644
--- a/tests/plugins/github/publish/render/test_publish_render_data.py
+++ b/tests/plugins/github/publish/render/test_publish_render_data.py
@@ -34,7 +34,7 @@ async def test_render_data_bot(app: App):
> Bot: CoolQBot
-[](https://github.com/he0119/CoolQBot)
+[](https://github.com/he0119/CoolQBot)
**✅ 所有测试通过,一切准备就绪!**
@@ -82,7 +82,7 @@ async def test_render_data_bot(app: App):
> Bot: March7th
-[](https://github.com/Mar-7th/March7th)
+[](https://github.com/Mar-7th/March7th)
**✅ 所有测试通过,一切准备就绪!**
@@ -137,7 +137,7 @@ async def test_render_data_adapter(app: App):
> Adapter: 大别野
-[](https://github.com/CMHopeSunshine/nonebot-adapter-villa)
+[](https://github.com/CMHopeSunshine/nonebot-adapter-villa)
**✅ 所有测试通过,一切准备就绪!**
@@ -196,7 +196,7 @@ async def test_render_data_plugin(app: App, mocker: MockFixture):
> Plugin: 帮助
-[](https://github.com/he0119/nonebot-plugin-treehelp)
+[](https://github.com/he0119/nonebot-plugin-treehelp) [](https://github.com/owner/repo/actions/runs/123456)
**✅ 所有测试通过,一切准备就绪!**
@@ -249,6 +249,8 @@ async def test_render_data_plugin_supported_adapters(app: App, mocker: MockFixtu
> Plugin: 帮助
+[](https://github.com/owner/repo/actions/runs/123456)
+
**✅ 所有测试通过,一切准备就绪!**
diff --git a/tests/plugins/github/publish/render/test_publish_render_error.py b/tests/plugins/github/publish/render/test_publish_render_error.py
index db2fd8c8..3d218fce 100644
--- a/tests/plugins/github/publish/render/test_publish_render_error.py
+++ b/tests/plugins/github/publish/render/test_publish_render_error.py
@@ -231,7 +231,7 @@ async def test_render_error_plugin(app: App, mocker: MockFixture):
> Plugin: 帮助
-[](https://github.com/he0119/nonebot-plugin-treehelp)
+[](https://github.com/he0119/nonebot-plugin-treehelp) [](https://github.com/owner/repo/actions/runs/123456)
**⚠️ 在发布检查过程中,我们发现以下问题:**
@@ -300,7 +300,7 @@ async def test_render_error_plugin_load_test(app: App):
> Plugin: 帮助
-[](https://github.com/he0119/nonebot-plugin-treehelp)
+[](https://github.com/he0119/nonebot-plugin-treehelp)
**⚠️ 在发布检查过程中,我们发现以下问题:**
@@ -359,6 +359,8 @@ async def test_render_error_plugin_metadata(app: App, mocker: MockFixture):
> Plugin: 帮助
+[](https://github.com/owner/repo/actions/runs/123456)
+
**⚠️ 在发布检查过程中,我们发现以下问题:**
⚠️ 插件测试元数据: 无法获取到插件元数据。
@@ -427,6 +429,8 @@ async def test_render_error_tags_invalid(app: App, mocker: MockFixture):
> Plugin: 帮助
+[](https://github.com/owner/repo/actions/runs/123456)
+
**⚠️ 在发布检查过程中,我们发现以下问题:**
⚠️ 第 3 个标签格式错误。请确保标签为字典。 ⚠️ 标签: 格式错误。请确保其为列表。 ⚠️ 标签: 解码失败。请确保其为 JSON 格式。
@@ -496,6 +500,8 @@ async def test_render_type_error(app: App, mocker: MockFixture):
> Plugin: 帮助
+[](https://github.com/owner/repo/actions/runs/123456)
+
**⚠️ 在发布检查过程中,我们发现以下问题:**
⚠️ 插件类型 invalid 不符合规范。请确保插件类型正确,当前仅支持 application 与 library。 ⚠️ 适配器 missing 不存在。请确保适配器模块名称正确。 ⚠️ 插件支持的适配器: 格式错误。请确保其为集合。
@@ -552,6 +558,8 @@ async def test_render_unknown_error(app: App, mocker: MockFixture):
> Plugin: 帮助
+[](https://github.com/owner/repo/actions/runs/123456)
+
**⚠️ 在发布检查过程中,我们发现以下问题:**
⚠️ tests > 2 > test: unknown error
@@ -619,6 +627,8 @@ async def test_render_http_error(app: App, mocker: MockFixture):
> Plugin: 帮助
+[](https://github.com/owner/repo/actions/runs/123456)
+
**⚠️ 在发布检查过程中,我们发现以下问题:**
⚠️ 项目 主页 返回状态码 404。请确保你的项目主页可访问。 ⚠️ 项目 主页 访问出错。错误信息
From 90d2001a24fe45198f5f665a39be6d0545c742a5 Mon Sep 17 00:00:00 2001
From: BigOrangeQWQ <2284086963@qq.com>
Date: Wed, 16 Apr 2025 22:28:38 +0800
Subject: [PATCH 2/4] =?UTF-8?q?fix:=20=E5=88=A0=E5=8E=BB=E6=97=A0=E7=94=A8?=
=?UTF-8?q?=E7=9A=84=E5=8F=98=E9=87=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/plugins/github/plugins/publish/render.py | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/plugins/github/plugins/publish/render.py b/src/plugins/github/plugins/publish/render.py
index 09e29b54..fa8f490e 100644
--- a/src/plugins/github/plugins/publish/render.py
+++ b/src/plugins/github/plugins/publish/render.py
@@ -119,7 +119,6 @@ async def render_comment(result: ValidationDict, reuse: bool = False) -> str:
template = env.get_template("comment.md.jinja")
return await template.render_async(
card=" ".join(card),
- action_url=action_url,
reuse=reuse,
title=title,
valid=result.valid,
From 4345477f842ce1ef5def7a3a5035da30a0ba895d Mon Sep 17 00:00:00 2001
From: "pre-commit-ci[bot]"
<66853113+pre-commit-ci[bot]@users.noreply.github.com>
Date: Wed, 16 Apr 2025 14:32:08 +0000
Subject: [PATCH 3/4] style: auto fix by pre-commit hooks
---
src/plugins/github/plugins/publish/render.py | 32 +++++++++++---------
1 file changed, 18 insertions(+), 14 deletions(-)
diff --git a/src/plugins/github/plugins/publish/render.py b/src/plugins/github/plugins/publish/render.py
index fa8f490e..f1518af8 100644
--- a/src/plugins/github/plugins/publish/render.py
+++ b/src/plugins/github/plugins/publish/render.py
@@ -100,21 +100,25 @@ async def render_comment(result: ValidationDict, reuse: bool = False) -> str:
card: list[str] = []
if homepage := data.get("homepage"):
- card.append(COMMENT_CARD_TEMPLATE.format(
- name="主页",
- head="HOMEPAGE",
- content=homepage,
- color="green",
- url=homepage,
- ))
+ card.append(
+ COMMENT_CARD_TEMPLATE.format(
+ name="主页",
+ head="HOMEPAGE",
+ content=homepage,
+ color="green",
+ url=homepage,
+ )
+ )
if action_url := data.get("action_url"):
- card.append(COMMENT_CARD_TEMPLATE.format(
- name="测试结果",
- head="RESULT",
- content="OK" if result.valid else "ERROR",
- color="green" if result.valid else "red",
- url=action_url,
- ))
+ card.append(
+ COMMENT_CARD_TEMPLATE.format(
+ name="测试结果",
+ head="RESULT",
+ content="OK" if result.valid else "ERROR",
+ color="green" if result.valid else "red",
+ url=action_url,
+ )
+ )
template = env.get_template("comment.md.jinja")
return await template.render_async(
From ceb42dfb16d168d1670de59d118045339e5aaf28 Mon Sep 17 00:00:00 2001
From: BigOrangeQWQ <2284086963@qq.com>
Date: Wed, 16 Apr 2025 22:45:18 +0800
Subject: [PATCH 4/4] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E5=86=85=E5=AE=B9?=
=?UTF-8?q?=E6=98=BE=E7=A4=BA=E7=9A=84=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/plugins/github/plugins/publish/render.py | 2 +-
.../github/config/process/test_config_check.py | 2 +-
.../github/publish/process/test_publish_check.py | 12 ++++++------
.../publish/process/test_publish_check_plugin.py | 4 ++--
.../publish/render/test_publish_render_data.py | 8 ++++----
.../publish/render/test_publish_render_error.py | 4 ++--
6 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/src/plugins/github/plugins/publish/render.py b/src/plugins/github/plugins/publish/render.py
index f1518af8..9abb45a6 100644
--- a/src/plugins/github/plugins/publish/render.py
+++ b/src/plugins/github/plugins/publish/render.py
@@ -104,7 +104,7 @@ async def render_comment(result: ValidationDict, reuse: bool = False) -> str:
COMMENT_CARD_TEMPLATE.format(
name="主页",
head="HOMEPAGE",
- content=homepage,
+ content="200",
color="green",
url=homepage,
)
diff --git a/tests/plugins/github/config/process/test_config_check.py b/tests/plugins/github/config/process/test_config_check.py
index 77a37dd7..c59ba018 100644
--- a/tests/plugins/github/config/process/test_config_check.py
+++ b/tests/plugins/github/config/process/test_config_check.py
@@ -137,7 +137,7 @@ async def test_process_config_check(
> Plugin: name
-[](https://nonebot.dev) [](https://github.com/owner/repo/actions/runs/123456)
+[](https://nonebot.dev) [](https://github.com/owner/repo/actions/runs/123456)
**✅ 所有测试通过,一切准备就绪!**
diff --git a/tests/plugins/github/publish/process/test_publish_check.py b/tests/plugins/github/publish/process/test_publish_check.py
index ffeb745c..b101fe97 100644
--- a/tests/plugins/github/publish/process/test_publish_check.py
+++ b/tests/plugins/github/publish/process/test_publish_check.py
@@ -91,7 +91,7 @@ async def test_bot_process_publish_check(
> Bot: test
-[](https://nonebot.dev)
+[](https://nonebot.dev)
**✅ 所有测试通过,一切准备就绪!**
@@ -250,7 +250,7 @@ async def test_adapter_process_publish_check(
> Adapter: test
-[](https://nonebot.dev)
+[](https://nonebot.dev)
**✅ 所有测试通过,一切准备就绪!**
@@ -428,7 +428,7 @@ async def test_edit_title(
> Bot: test1
-[](https://nonebot.dev)
+[](https://nonebot.dev)
**✅ 所有测试通过,一切准备就绪!**
@@ -617,7 +617,7 @@ async def test_edit_title_too_long(
> Bot: looooooooooooooooooooooooooooooooooooooooooooooooooooooong
-[](https://nonebot.dev)
+[](https://nonebot.dev)
**⚠️ 在发布检查过程中,我们发现以下问题:**
@@ -1108,7 +1108,7 @@ async def test_process_publish_check_ready_for_review(
> Bot: test
-[](https://nonebot.dev)
+[](https://nonebot.dev)
**✅ 所有测试通过,一切准备就绪!**
@@ -1293,7 +1293,7 @@ async def test_comment_immediate_after_pull_request_closed(
> Bot: test
-[](https://nonebot.dev)
+[](https://nonebot.dev)
**✅ 所有测试通过,一切准备就绪!**
diff --git a/tests/plugins/github/publish/process/test_publish_check_plugin.py b/tests/plugins/github/publish/process/test_publish_check_plugin.py
index 00f05d4c..511af134 100644
--- a/tests/plugins/github/publish/process/test_publish_check_plugin.py
+++ b/tests/plugins/github/publish/process/test_publish_check_plugin.py
@@ -192,7 +192,7 @@ async def test_plugin_process_publish_check(
> Plugin: name
-[](https://nonebot.dev) [](https://github.com/owner/repo/actions/runs/123456)
+[](https://nonebot.dev) [](https://github.com/owner/repo/actions/runs/123456)
**✅ 所有测试通过,一切准备就绪!**
@@ -454,7 +454,7 @@ async def test_plugin_process_publish_check_re_run(
> Plugin: name
-[](https://nonebot.dev) [](https://github.com/owner/repo/actions/runs/123456)
+[](https://nonebot.dev) [](https://github.com/owner/repo/actions/runs/123456)
**✅ 所有测试通过,一切准备就绪!**
diff --git a/tests/plugins/github/publish/render/test_publish_render_data.py b/tests/plugins/github/publish/render/test_publish_render_data.py
index aa9d49b5..97e02ec8 100644
--- a/tests/plugins/github/publish/render/test_publish_render_data.py
+++ b/tests/plugins/github/publish/render/test_publish_render_data.py
@@ -34,7 +34,7 @@ async def test_render_data_bot(app: App):
> Bot: CoolQBot
-[](https://github.com/he0119/CoolQBot)
+[](https://github.com/he0119/CoolQBot)
**✅ 所有测试通过,一切准备就绪!**
@@ -82,7 +82,7 @@ async def test_render_data_bot(app: App):
> Bot: March7th
-[](https://github.com/Mar-7th/March7th)
+[](https://github.com/Mar-7th/March7th)
**✅ 所有测试通过,一切准备就绪!**
@@ -137,7 +137,7 @@ async def test_render_data_adapter(app: App):
> Adapter: 大别野
-[](https://github.com/CMHopeSunshine/nonebot-adapter-villa)
+[](https://github.com/CMHopeSunshine/nonebot-adapter-villa)
**✅ 所有测试通过,一切准备就绪!**
@@ -196,7 +196,7 @@ async def test_render_data_plugin(app: App, mocker: MockFixture):
> Plugin: 帮助
-[](https://github.com/he0119/nonebot-plugin-treehelp) [](https://github.com/owner/repo/actions/runs/123456)
+[](https://github.com/he0119/nonebot-plugin-treehelp) [](https://github.com/owner/repo/actions/runs/123456)
**✅ 所有测试通过,一切准备就绪!**
diff --git a/tests/plugins/github/publish/render/test_publish_render_error.py b/tests/plugins/github/publish/render/test_publish_render_error.py
index 3d218fce..6603238e 100644
--- a/tests/plugins/github/publish/render/test_publish_render_error.py
+++ b/tests/plugins/github/publish/render/test_publish_render_error.py
@@ -231,7 +231,7 @@ async def test_render_error_plugin(app: App, mocker: MockFixture):
> Plugin: 帮助
-[](https://github.com/he0119/nonebot-plugin-treehelp) [](https://github.com/owner/repo/actions/runs/123456)
+[](https://github.com/he0119/nonebot-plugin-treehelp) [](https://github.com/owner/repo/actions/runs/123456)
**⚠️ 在发布检查过程中,我们发现以下问题:**
@@ -300,7 +300,7 @@ async def test_render_error_plugin_load_test(app: App):
> Plugin: 帮助
-[](https://github.com/he0119/nonebot-plugin-treehelp)
+[](https://github.com/he0119/nonebot-plugin-treehelp)
**⚠️ 在发布检查过程中,我们发现以下问题:**