From 32d0001a24c47e13b735d4929792d680c8d17cf0 Mon Sep 17 00:00:00 2001
From: BigOrangeQWQ <2284086963@qq.com>
Date: Thu, 12 Jun 2025 22:33:19 +0800
Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=8E=86=E5=8F=B2?=
=?UTF-8?q?=E4=BF=A1=E6=81=AF=E7=9A=84=E6=B8=B2=E6=9F=93=E5=92=8C=E6=AD=A3?=
=?UTF-8?q?=E5=88=99=E5=8C=B9=E9=85=8D=E7=9A=84=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../github/plugins/publish/__init__.py | 2 +
.../github/plugins/publish/constants.py | 2 +-
.../publish/templates/comment.md.jinja | 2 +-
.../config/process/test_config_check.py | 2 +-
.../process/test_publish_check_plugin.py | 8 +--
.../process/test_publish_pull_request.py | 2 +-
.../publish/render/test_publish_render.py | 2 +-
.../render/test_publish_render_data.py | 4 +-
.../render/test_publish_render_error.py | 12 ++--
.../publish/utils/test_history_workflow.py | 58 +++++++++++++++++--
.../utils/test_trigger_registry_update.py | 4 +-
11 files changed, 73 insertions(+), 25 deletions(-)
diff --git a/src/plugins/github/plugins/publish/__init__.py b/src/plugins/github/plugins/publish/__init__.py
index f2453342..d9960123 100644
--- a/src/plugins/github/plugins/publish/__init__.py
+++ b/src/plugins/github/plugins/publish/__init__.py
@@ -160,8 +160,10 @@ async def handle_pull_request_and_update_issue(
self_comment = await handler.get_self_comment(handler.issue_number)
history: list[tuple[bool, str, datetime]] = []
+
if self_comment and self_comment.body:
history = await get_history_workflow_from_comment(self_comment.body)
+ logger.debug(f"获取到 {len(history)} 条历史工作流")
# 渲染评论信息
comment = await render_comment(validation, True, history)
diff --git a/src/plugins/github/plugins/publish/constants.py b/src/plugins/github/plugins/publish/constants.py
index c8b57bb1..9209047a 100644
--- a/src/plugins/github/plugins/publish/constants.py
+++ b/src/plugins/github/plugins/publish/constants.py
@@ -48,7 +48,7 @@
WORKFLOW_HISTORY_PATTERN = re.compile(
- r'
(⚠️|✅)\s*([^<]+?CST)。'
+ r'(⚠️|✅)\s*([^<]+?CST)'
)
WORKFLOW_HISTORY_TEMPLATE = """{status} {time}。"""
diff --git a/src/plugins/github/plugins/publish/templates/comment.md.jinja b/src/plugins/github/plugins/publish/templates/comment.md.jinja
index acb68b0e..496fd694 100644
--- a/src/plugins/github/plugins/publish/templates/comment.md.jinja
+++ b/src/plugins/github/plugins/publish/templates/comment.md.jinja
@@ -36,7 +36,7 @@
历史测试
{%- for status, action_url, time in history%}
-{{"✅" if status else "⚠️"}} {{time|format_datetime}}
+{{"✅" if status else "⚠️"}} {{time|format_datetime}}
{%- endfor %}
diff --git a/tests/plugins/github/config/process/test_config_check.py b/tests/plugins/github/config/process/test_config_check.py
index f8f37d9c..eb1b9d4b 100644
--- a/tests/plugins/github/config/process/test_config_check.py
+++ b/tests/plugins/github/config/process/test_config_check.py
@@ -147,7 +147,7 @@ async def test_process_config_check(
历史测试
-✅ 2023-08-23 09:22:14 CST
+✅ 2023-08-23 09:22:14 CST
---
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 14c04041..98e1d0d4 100644
--- a/tests/plugins/github/publish/process/test_publish_check_plugin.py
+++ b/tests/plugins/github/publish/process/test_publish_check_plugin.py
@@ -203,7 +203,7 @@ async def test_plugin_process_publish_check(
历史测试
-✅ 2023-08-23 09:22:14 CST
+✅ 2023-08-23 09:22:14 CST
---
@@ -469,7 +469,7 @@ async def test_plugin_process_publish_check_re_run(
历史测试
-✅ 2023-08-23 09:22:14 CST
+✅ 2023-08-23 09:22:14 CST
---
@@ -720,7 +720,7 @@ async def test_plugin_process_publish_check_missing_metadata(
历史测试
-⚠️ 2023-08-23 09:22:14 CST
+⚠️ 2023-08-23 09:22:14 CST
---
@@ -979,7 +979,7 @@ async def test_skip_plugin_check(
历史测试
-⚠️ 2023-08-23 09:22:14 CST
+⚠️ 2023-08-23 09:22:14 CST
---
diff --git a/tests/plugins/github/publish/process/test_publish_pull_request.py b/tests/plugins/github/publish/process/test_publish_pull_request.py
index c549313a..4f17a566 100644
--- a/tests/plugins/github/publish/process/test_publish_pull_request.py
+++ b/tests/plugins/github/publish/process/test_publish_pull_request.py
@@ -35,7 +35,7 @@ async def test_process_pull_request(
mock_comment_bot.body = """
\n历史测试
-⚠️ 2025-03-28 02:21:18 CST。✅ 2025-03-28 02:21:18 CST。✅ 2025-03-28 02:22:18 CST。⚠️ 2025-03-28 02:22:18 CST。
+⚠️ 2025-03-28 02:21:18 CST✅ 2025-03-28 02:21:18 CST✅ 2025-03-28 02:22:18 CST⚠️ 2025-03-28 02:22:18 CST
diff --git a/tests/plugins/github/publish/render/test_publish_render.py b/tests/plugins/github/publish/render/test_publish_render.py
index ff82c282..ec7ff58b 100644
--- a/tests/plugins/github/publish/render/test_publish_render.py
+++ b/tests/plugins/github/publish/render/test_publish_render.py
@@ -167,7 +167,7 @@ async def test_render_history(app: App):
历史测试
-✅ 2023-08-23 09:22:14 CST✅ 2020-10-10 12:00:18 CST⚠️ 2020-10-09 12:00:18 CST✅ 2020-10-08 12:00:18 CST⚠️ 2020-10-07 12:00:18 CST✅ 2020-10-06 12:00:18 CST⚠️ 2020-10-05 12:00:18 CST✅ 2020-10-04 12:00:18 CST✅ 2020-10-03 12:00:18 CST⚠️ 2020-10-02 12:00:18 CST
+✅ 2023-08-23 09:22:14 CST✅ 2020-10-10 12:00:18 CST⚠️ 2020-10-09 12:00:18 CST✅ 2020-10-08 12:00:18 CST⚠️ 2020-10-07 12:00:18 CST✅ 2020-10-06 12:00:18 CST⚠️ 2020-10-05 12:00:18 CST✅ 2020-10-04 12:00:18 CST✅ 2020-10-03 12:00:18 CST⚠️ 2020-10-02 12:00:18 CST
---
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 edd981ce..65581f93 100644
--- a/tests/plugins/github/publish/render/test_publish_render_data.py
+++ b/tests/plugins/github/publish/render/test_publish_render_data.py
@@ -207,7 +207,7 @@ async def test_render_data_plugin(app: App, mocker: MockFixture):
历史测试
-✅ 2023-08-23 09:22:14 CST
+✅ 2023-08-23 09:22:14 CST
---
@@ -264,7 +264,7 @@ async def test_render_data_plugin_supported_adapters(app: App, mocker: MockFixtu
历史测试
-✅ 2023-08-23 09:22:14 CST
+✅ 2023-08-23 09:22:14 CST
---
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 90fc6429..d78ed6c1 100644
--- a/tests/plugins/github/publish/render/test_publish_render_error.py
+++ b/tests/plugins/github/publish/render/test_publish_render_error.py
@@ -243,7 +243,7 @@ async def test_render_error_plugin(app: App, mocker: MockFixture):
历史测试
-⚠️ 2023-08-23 09:22:14 CST
+⚠️ 2023-08-23 09:22:14 CST
---
@@ -375,7 +375,7 @@ async def test_render_error_plugin_metadata(app: App, mocker: MockFixture):
历史测试
-⚠️ 2023-08-23 09:22:14 CST
+⚠️ 2023-08-23 09:22:14 CST
---
@@ -449,7 +449,7 @@ async def test_render_error_tags_invalid(app: App, mocker: MockFixture):
历史测试
-⚠️ 2023-08-23 09:22:14 CST
+⚠️ 2023-08-23 09:22:14 CST
---
@@ -524,7 +524,7 @@ async def test_render_type_error(app: App, mocker: MockFixture):
历史测试
-⚠️ 2023-08-23 09:22:14 CST
+⚠️ 2023-08-23 09:22:14 CST
---
@@ -586,7 +586,7 @@ async def test_render_unknown_error(app: App, mocker: MockFixture):
历史测试
-⚠️ 2023-08-23 09:22:14 CST
+⚠️ 2023-08-23 09:22:14 CST
---
@@ -659,7 +659,7 @@ async def test_render_http_error(app: App, mocker: MockFixture):
历史测试
-⚠️ 2023-08-23 09:22:14 CST
+⚠️ 2023-08-23 09:22:14 CST
---
diff --git a/tests/plugins/github/publish/utils/test_history_workflow.py b/tests/plugins/github/publish/utils/test_history_workflow.py
index e6a6c12b..c51d09f8 100644
--- a/tests/plugins/github/publish/utils/test_history_workflow.py
+++ b/tests/plugins/github/publish/utils/test_history_workflow.py
@@ -24,7 +24,7 @@ async def test_history_workflow(app: App):
历史测试
-⚠️ 2025-03-28 02:21:18 CST。✅ 2025-03-28 02:21:18 CST。✅ 2025-03-28 02:22:18 CST。⚠️ 2025-03-28 02:22:18 CST。
+⚠️ 2025-03-28 02:21:18 CST✅ 2025-03-28 02:21:18 CST✅ 2025-03-28 02:22:18 CST。⚠️ 2025-03-28 02:22:18 CST
@@ -54,11 +54,6 @@ async def test_history_workflow(app: App):
"https://github.com/nonebot/nonebot2/actions/runs/14156878699",
"2025-03-28 02:21:18 CST",
),
- (
- True,
- "https://github.com/nonebot/nonebot2/actions/runs/14156878699",
- "2025-03-28 02:22:18 CST",
- ),
(
False,
"https://github.com/nonebot/nonebot2/actions/runs/14156878699",
@@ -66,3 +61,54 @@ async def test_history_workflow(app: App):
),
]
)
+
+
+async def test_history_workflow_2(app: App):
+ from src.plugins.github.plugins.publish.utils import (
+ get_history_workflow_from_comment,
+ )
+ from src.providers.constants import TIME_ZONE
+
+ CONTENT = """
+# 📃 商店发布检查结果
+
+> Plugin: 明日方舟干员插件
+
+[](https://github.com/xingzhiyou/nonebot-plugin-ark-roulette) [](https://github.com/nonebot/noneflow-test/actions/runs/15612654853)
+
+**✅ 所有测试通过,一切准备就绪!**
+
+
+
+详情
+✅ 项目 主页 返回状态码 200。✅ 项目 nonebot-plugin-ark-roulette 已发布至 PyPI。✅ 插件类型: application。✅ 插件支持的适配器: 所有。✅ 插件 加载测试 通过。✅ 版本号: 2.0.1。✅ 发布时间:2025-05-20 03:58:54 CST。
+
+
+历史测试
+✅ 2025-06-12 22:01:37 CST
+
+
+---
+
+💡 如需修改信息,请直接修改 issue,机器人会自动更新检查结果。
+💡 当插件加载测试失败时,请发布新版本后勾选插件测试勾选框重新运行插件测试。
+
+♻️ 评论已更新至最新检查结果
+
+💪 Powered by [NoneFlow](https://github.com/nonebot/noneflow)
+
+
+"""
+ history = [
+ (valid, url, time.astimezone(TIME_ZONE).strftime("%Y-%m-%d %H:%M:%S %Z"))
+ for valid, url, time in await get_history_workflow_from_comment(CONTENT)
+ ]
+ assert history == snapshot(
+ [
+ (
+ True,
+ "https://github.com/nonebot/noneflow-test/actions/runs/15612654853",
+ "2025-06-12 22:01:37 CST",
+ )
+ ]
+ )
diff --git a/tests/plugins/github/publish/utils/test_trigger_registry_update.py b/tests/plugins/github/publish/utils/test_trigger_registry_update.py
index 72cb9856..b1f43cba 100644
--- a/tests/plugins/github/publish/utils/test_trigger_registry_update.py
+++ b/tests/plugins/github/publish/utils/test_trigger_registry_update.py
@@ -27,7 +27,7 @@ async def test_trigger_registry_update(app: App, mocker: MockerFixture):
mock_bot_comment.body = f"""
\n历史测试
-⚠️ 2025-03-28 02:21:18 CST。✅ 2025-03-28 02:21:18 CST。✅ 2025-03-28 02:22:18 CST。⚠️ 2025-03-28 02:22:18 CST。
+⚠️ 2025-03-28 02:21:18 CST✅ 2025-03-28 02:21:18 CST✅ 2025-03-28 02:22:18 CST⚠️ 2025-03-28 02:22:18 CST
{NONEFLOW_MARKER}
@@ -152,7 +152,7 @@ async def test_trigger_registry_update_missing_artifact(
mock_bot_comment.body = f"""
\n历史测试
-⚠️ 2025-03-28 02:21:18 CST。✅ 2025-03-28 02:21:18 CST。✅ 2025-03-28 02:22:18 CST。⚠️ 2025-03-28 02:22:18 CST。
+⚠️ 2025-03-28 02:21:18 CST✅ 2025-03-28 02:21:18 CST✅ 2025-03-28 02:22:18 CST⚠️ 2025-03-28 02:22:18 CST
{NONEFLOW_MARKER}
From bb9488b5b579ead4aff48cd736e96db91650b50b Mon Sep 17 00:00:00 2001
From: uy/sun
Date: Fri, 13 Jun 2025 08:09:52 +0800
Subject: [PATCH 2/2] =?UTF-8?q?test:=20=E6=B7=BB=E5=8A=A0=E6=B5=8B?=
=?UTF-8?q?=E8=AF=95=E7=9A=84=E6=B3=A8=E9=87=8A?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
tests/plugins/github/publish/utils/test_history_workflow.py | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/tests/plugins/github/publish/utils/test_history_workflow.py b/tests/plugins/github/publish/utils/test_history_workflow.py
index c51d09f8..e76e84e6 100644
--- a/tests/plugins/github/publish/utils/test_history_workflow.py
+++ b/tests/plugins/github/publish/utils/test_history_workflow.py
@@ -3,6 +3,7 @@
async def test_history_workflow(app: App):
+ """测试从评论中提取历史工作流信息"""
from src.plugins.github.plugins.publish.utils import (
get_history_workflow_from_comment,
)
@@ -63,7 +64,8 @@ async def test_history_workflow(app: App):
)
-async def test_history_workflow_2(app: App):
+async def test_history_workflow_different_repo(app: App):
+ """测试指向不同仓库的历史工作流"""
from src.plugins.github.plugins.publish.utils import (
get_history_workflow_from_comment,
)