File tree Expand file tree Collapse file tree 5 files changed +16
-16
lines changed
Expand file tree Collapse file tree 5 files changed +16
-16
lines changed Original file line number Diff line number Diff line change 44from nonebot .plugin import PluginMetadata
55from pydantic import BaseModel , Extra , validator
66
7- from src .utils .helper import strip_ansi
7+ from src .utils .plugin_test import strip_ansi
88
99
1010class PublishConfig (BaseModel ):
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -59,6 +59,14 @@ def default(self, obj):
5959"""
6060
6161
62+ def strip_ansi (text : str | None ) -> str :
63+ """去除 ANSI 转义字符"""
64+ if not text :
65+ return ""
66+ ansi_escape = re .compile (r"\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])" )
67+ return ansi_escape .sub ("" , text )
68+
69+
6270def get_plugin_list () -> dict [str , str ]:
6371 """获取插件列表
6472
@@ -126,14 +134,16 @@ async def run(self):
126134 f .write (f"RESULT={ self ._run } \n " )
127135 # 输出测试输出
128136 output = "\n " .join (self ._output_lines )
137+ # GitHub 不支持 ANSI 转义字符所以去掉
138+ ansiless_output = strip_ansi (output )
129139 # 限制输出长度,防止评论过长,评论最大长度为 65536
130- output = output [:50000 ]
140+ ansiless_output = ansiless_output [:50000 ]
131141 with open (self .github_output_file , "a" , encoding = "utf8" ) as f :
132- f .write (f"OUTPUT<<EOF\n { output } \n EOF\n " )
142+ f .write (f"OUTPUT<<EOF\n { ansiless_output } \n EOF\n " )
133143 # 输出至作业摘要
134144 with open (self .github_step_summary_file , "a" , encoding = "utf8" ) as f :
135145 summary = f"插件 { self .project_link } 加载测试结果:{ '通过' if self ._run else '未通过' } \n "
136- summary += f"<details><summary>测试输出</summary><pre><code>{ output } </code></pre></details>"
146+ summary += f"<details><summary>测试输出</summary><pre><code>{ ansiless_output } </code></pre></details>"
137147 f .write (f"{ summary } " )
138148 return self ._run , output
139149
Original file line number Diff line number Diff line change 1111from pydantic import ValidationError
1212
1313from src .plugins .publish .validation import PluginPublishInfo
14- from src .utils .helper import strip_ansi
15- from src .utils .plugin_test import PluginTest
14+ from src .utils .plugin_test import PluginTest , strip_ansi
1615
1716from .constants import PLUGIN_CONFIGS_URL
1817from .models import Metadata , PluginData
Original file line number Diff line number Diff line change 22
33
44async def test_strip_ansi (app : App ):
5- from src .utils .helper import strip_ansi
5+ from src .utils .plugin_test import strip_ansi
66
77 assert strip_ansi ("test" ) == "test"
88
You can’t perform that action at this time.
0 commit comments