diff --git a/CHANGELOG.md b/CHANGELOG.md index 3121a477..d9f18084 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/lang/zh-CN/ ## [Unreleased] +### Fixed + +- 修复机器人/适配器发布时没有历史测试的问题 + ## [4.4.0] - 2025-06-17 ### Added diff --git a/src/plugins/github/plugins/publish/render.py b/src/plugins/github/plugins/publish/render.py index 58fb8638..9c41c9aa 100644 --- a/src/plugins/github/plugins/publish/render.py +++ b/src/plugins/github/plugins/publish/render.py @@ -84,14 +84,14 @@ async def render_comment( history = history or [] + action_url = f"https://github.com/{plugin_config.github_repository}/actions/runs/{plugin_config.github_run_id}" if result.type == PublishType.PLUGIN: # https://github.com/he0119/action-test/actions/runs/4469672520 # 仅在测试通过或跳过测试时显示 # 如果 load 为 False 的时候 valid_data 里面没有 load 字段,所以直接用 raw_data if result.raw_data["load"] or result.raw_data["skip_test"]: - valid_data["action_url"] = ( - f"https://github.com/{plugin_config.github_repository}/actions/runs/{plugin_config.github_run_id}" - ) + valid_data["action_url"] = action_url + # 如果 tags 字段为空则不显示 if not valid_data.get("tags"): valid_data.pop("tags", None) @@ -122,7 +122,7 @@ async def render_comment( url=homepage, ) ) - if action_url := data.get("action_url"): + if "action_url" in data: card.append( COMMENT_CARD_TEMPLATE.format( name="测试结果", @@ -132,14 +132,9 @@ async def render_comment( url=action_url, ) ) - history.append( - ( - result.valid, - action_url, - datetime.now(tz=TIME_ZONE), - ) - ) + # 添加历史测试 + history.append((result.valid, action_url, datetime.now(tz=TIME_ZONE))) # 测试历史应该时间倒序排列 history.sort(key=lambda x: x[2], reverse=True) # 限制最多显示 10 条历史 diff --git a/tests/plugins/github/publish/process/test_publish_check.py b/tests/plugins/github/publish/process/test_publish_check.py index ef8570c9..0b5d81cb 100644 --- a/tests/plugins/github/publish/process/test_publish_check.py +++ b/tests/plugins/github/publish/process/test_publish_check.py @@ -100,6 +100,10 @@ async def test_bot_process_publish_check( 详情
  • ✅ 项目 主页 返回状态码 200。
  • ✅ 标签: test-#ffffff。
  • +
    +历史测试 +
  • 2023-08-23 09:22:14 CST
  • +
    --- @@ -259,6 +263,10 @@ async def test_adapter_process_publish_check( 详情
  • ✅ 项目 主页 返回状态码 200。
  • ✅ 项目 project_link 已发布至 PyPI。
  • ✅ 标签: test-#ffffff。
  • ✅ 版本号: 0.0.1。
  • ✅ 发布时间:2023-09-01 08:00:00 CST。
  • +
    +历史测试 +
  • 2023-08-23 09:22:14 CST
  • +
    --- @@ -437,6 +445,10 @@ async def test_edit_title( 详情
  • ✅ 项目 主页 返回状态码 200。
  • ✅ 标签: test-#ffffff。
  • +
    +历史测试 +
  • 2023-08-23 09:22:14 CST
  • +
    --- @@ -627,6 +639,10 @@ async def test_edit_title_too_long( 详情
  • ✅ 项目 主页 返回状态码 200。
  • ✅ 标签: test-#ffffff。
  • +
    +历史测试 +
  • ⚠️ 2023-08-23 09:22:14 CST
  • +
    --- @@ -757,6 +773,10 @@ async def test_process_publish_check_not_pass( 详情
  • ✅ 标签: test-#ffffff。
  • +
    +历史测试 +
  • ⚠️ 2023-08-23 09:22:14 CST
  • +
    --- @@ -984,6 +1004,10 @@ async def test_convert_pull_request_to_draft( 详情
  • ✅ 标签: test-#ffffff。
  • +
    +历史测试 +
  • ⚠️ 2023-08-23 09:22:14 CST
  • +
    --- @@ -1117,6 +1141,10 @@ async def test_process_publish_check_ready_for_review( 详情
  • ✅ 项目 主页 返回状态码 200。
  • ✅ 标签: test-#ffffff。
  • +
    +历史测试 +
  • 2023-08-23 09:22:14 CST
  • +
    --- @@ -1302,6 +1330,10 @@ async def test_comment_immediate_after_pull_request_closed( 详情
  • ✅ 项目 主页 返回状态码 200。
  • ✅ 标签: test-#ffffff。
  • +
    +历史测试 +
  • 2023-08-23 09:22:14 CST
  • +
    --- diff --git a/tests/plugins/github/publish/render/test_publish_render.py b/tests/plugins/github/publish/render/test_publish_render.py index ec7ff58b..eb141d5b 100644 --- a/tests/plugins/github/publish/render/test_publish_render.py +++ b/tests/plugins/github/publish/render/test_publish_render.py @@ -27,6 +27,10 @@ async def test_render_empty(app: App): **✅ 所有测试通过,一切准备就绪!** +
    +历史测试 +
  • 2023-08-23 09:22:14 CST
  • +
    --- @@ -61,6 +65,10 @@ async def test_render_reuse(app: App): **✅ 所有测试通过,一切准备就绪!** +
    +历史测试 +
  • 2023-08-23 09:22:14 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 65581f93..258f1b51 100644 --- a/tests/plugins/github/publish/render/test_publish_render_data.py +++ b/tests/plugins/github/publish/render/test_publish_render_data.py @@ -43,6 +43,10 @@ async def test_render_data_bot(app: App): 详情
  • ✅ 项目 主页 返回状态码 200。
  • +
    +历史测试 +
  • 2023-08-23 09:22:14 CST
  • +
    --- @@ -91,6 +95,10 @@ async def test_render_data_bot(app: App): 详情
  • ✅ 项目 主页 返回状态码 200。
  • ✅ 标签: StarRail-#5a8ccc, 星穹铁道-#6faec6。
  • +
    +历史测试 +
  • 2023-08-23 09:22:14 CST
  • +
    --- @@ -146,6 +154,10 @@ async def test_render_data_adapter(app: App): 详情
  • ✅ 项目 主页 返回状态码 200。
  • ✅ 项目 nonebot-adapter-villa 已发布至 PyPI。
  • ✅ 标签: 米哈游-#e10909。
  • ✅ 版本号: 1.4.2。
  • ✅ 发布时间:2023-12-21 14:57:44 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 d78ed6c1..c8f997a6 100644 --- a/tests/plugins/github/publish/render/test_publish_render_error.py +++ b/tests/plugins/github/publish/render/test_publish_render_error.py @@ -58,6 +58,10 @@ async def test_render_error_bot(app: App):
  • ⚠️ 名称: 字符过多。
    请确保其不超过 50 个字符。
  • ⚠️ 项目 主页 返回状态码 404。
    请确保你的项目主页可访问。
  • ⚠️ 第 2 个标签名称过长。
    请确保标签名称不超过 10 个字符。
  • ⚠️ 第 2 个标签颜色错误。
    请确保标签颜色符合十六进制颜色码规则。
  • +
    +历史测试 +
  • ⚠️ 2023-08-23 09:22:14 CST
  • +
    --- @@ -145,6 +149,10 @@ async def test_render_error_adapter(app: App): 详情
  • ✅ 项目 nonebot-adapter-villa 已发布至 PyPI。
  • +
    +历史测试 +
  • ⚠️ 2023-08-23 09:22:14 CST
  • +
    --- @@ -314,6 +322,10 @@ async def test_render_error_plugin_load_test(app: App): 详情
  • ✅ 项目 主页 返回状态码 200。
  • +
    +历史测试 +
  • ⚠️ 2023-08-23 09:22:14 CST
  • +
    ---