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..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, ) @@ -24,7 +25,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 +55,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 +62,55 @@ async def test_history_workflow(app: App): ), ] ) + + +async def test_history_workflow_different_repo(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://img.shields.io/badge/HOMEPAGE-200-green?style=for-the-badge)](https://github.com/xingzhiyou/nonebot-plugin-ark-roulette) [![测试结果](https://img.shields.io/badge/RESULT-OK-green?style=for-the-badge)](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}