Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/plugins/github/plugins/publish/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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("标签"))
Expand Down Expand Up @@ -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 = """[![{name}](https://img.shields.io/badge/{head}-{content}-{color}?style=for-the-badge)]({url})"""

# 发布信息项对应的中文名
LOC_NAME_MAP = {
"name": "名称",
Expand Down
27 changes: 23 additions & 4 deletions src/plugins/github/plugins/publish/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -98,12 +98,31 @@ 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="200",
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),
reuse=reuse,
title=title,
valid=result.valid,
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/github/plugins/publish/templates/comment.md.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

> {{ title }}

{% if homepage %}
[![主页](https://img.shields.io/badge/HOMEPAGE-200-green?style=for-the-badge)]({{ homepage }})
{% if card %}
{{ card }}

{% endif -%}

Expand Down
2 changes: 1 addition & 1 deletion tests/plugins/github/config/process/test_config_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ async def test_process_config_check(

> Plugin: name

[![主页](https://img.shields.io/badge/HOMEPAGE-200-green?style=for-the-badge)](https://nonebot.dev)
[![主页](https://img.shields.io/badge/HOMEPAGE-200-green?style=for-the-badge)](https://nonebot.dev) [![测试结果](https://img.shields.io/badge/RESULT-OK-green?style=for-the-badge)](https://github.com/owner/repo/actions/runs/123456)

**✅ 所有测试通过,一切准备就绪!**

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ async def test_plugin_process_publish_check(

> Plugin: name

[![主页](https://img.shields.io/badge/HOMEPAGE-200-green?style=for-the-badge)](https://nonebot.dev)
[![主页](https://img.shields.io/badge/HOMEPAGE-200-green?style=for-the-badge)](https://nonebot.dev) [![测试结果](https://img.shields.io/badge/RESULT-OK-green?style=for-the-badge)](https://github.com/owner/repo/actions/runs/123456)

**✅ 所有测试通过,一切准备就绪!**

Expand Down Expand Up @@ -454,7 +454,7 @@ async def test_plugin_process_publish_check_re_run(

> Plugin: name

[![主页](https://img.shields.io/badge/HOMEPAGE-200-green?style=for-the-badge)](https://nonebot.dev)
[![主页](https://img.shields.io/badge/HOMEPAGE-200-green?style=for-the-badge)](https://nonebot.dev) [![测试结果](https://img.shields.io/badge/RESULT-OK-green?style=for-the-badge)](https://github.com/owner/repo/actions/runs/123456)

**✅ 所有测试通过,一切准备就绪!**

Expand Down Expand Up @@ -700,6 +700,8 @@ async def test_plugin_process_publish_check_missing_metadata(

> Plugin: project_link

[![测试结果](https://img.shields.io/badge/RESULT-ERROR-red?style=for-the-badge)](https://github.com/owner/repo/actions/runs/123456)

**⚠️ 在发布检查过程中,我们发现以下问题:**

<pre><code><li>⚠️ 无法获取到插件元数据。<dt>请确保插件正常加载。</dt></li></code></pre>
Expand Down Expand Up @@ -953,6 +955,8 @@ async def test_skip_plugin_check(

> Plugin: project_link

[![测试结果](https://img.shields.io/badge/RESULT-ERROR-red?style=for-the-badge)](https://github.com/owner/repo/actions/runs/123456)

**⚠️ 在发布检查过程中,我们发现以下问题:**

<pre><code><li>⚠️ 名称: 无法匹配到数据。<dt>请确保填写该数据项。</dt></li><li>⚠️ 描述: 无法匹配到数据。<dt>请确保填写该数据项。</dt></li><li>⚠️ 项目仓库/主页链接: 无法匹配到数据。<dt>请确保填写该数据项。</dt></li><li>⚠️ 插件类型: 无法匹配到数据。<dt>请确保填写该数据项。</dt></li><li>⚠️ 插件支持的适配器: 无法匹配到数据。<dt>请确保填写该数据项。</dt></li><li>⚠️ 无法获取到插件元数据。<dt>请确保插件正常加载。</dt></li></code></pre>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ async def test_render_data_plugin(app: App, mocker: MockFixture):

> Plugin: 帮助

[![主页](https://img.shields.io/badge/HOMEPAGE-200-green?style=for-the-badge)](https://github.com/he0119/nonebot-plugin-treehelp)
[![主页](https://img.shields.io/badge/HOMEPAGE-200-green?style=for-the-badge)](https://github.com/he0119/nonebot-plugin-treehelp) [![测试结果](https://img.shields.io/badge/RESULT-OK-green?style=for-the-badge)](https://github.com/owner/repo/actions/runs/123456)

**✅ 所有测试通过,一切准备就绪!**

Expand Down Expand Up @@ -249,6 +249,8 @@ async def test_render_data_plugin_supported_adapters(app: App, mocker: MockFixtu

> Plugin: 帮助

[![测试结果](https://img.shields.io/badge/RESULT-OK-green?style=for-the-badge)](https://github.com/owner/repo/actions/runs/123456)

**✅ 所有测试通过,一切准备就绪!**


Expand Down
12 changes: 11 additions & 1 deletion tests/plugins/github/publish/render/test_publish_render_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ async def test_render_error_plugin(app: App, mocker: MockFixture):

> Plugin: 帮助

[![主页](https://img.shields.io/badge/HOMEPAGE-200-green?style=for-the-badge)](https://github.com/he0119/nonebot-plugin-treehelp)
[![主页](https://img.shields.io/badge/HOMEPAGE-200-green?style=for-the-badge)](https://github.com/he0119/nonebot-plugin-treehelp) [![测试结果](https://img.shields.io/badge/RESULT-ERROR-red?style=for-the-badge)](https://github.com/owner/repo/actions/runs/123456)

**⚠️ 在发布检查过程中,我们发现以下问题:**

Expand Down Expand Up @@ -359,6 +359,8 @@ async def test_render_error_plugin_metadata(app: App, mocker: MockFixture):

> Plugin: 帮助

[![测试结果](https://img.shields.io/badge/RESULT-ERROR-red?style=for-the-badge)](https://github.com/owner/repo/actions/runs/123456)

**⚠️ 在发布检查过程中,我们发现以下问题:**

<pre><code><li>⚠️ 插件测试元数据: 无法获取到插件元数据。</li></code></pre>
Expand Down Expand Up @@ -427,6 +429,8 @@ async def test_render_error_tags_invalid(app: App, mocker: MockFixture):

> Plugin: 帮助

[![测试结果](https://img.shields.io/badge/RESULT-ERROR-red?style=for-the-badge)](https://github.com/owner/repo/actions/runs/123456)

**⚠️ 在发布检查过程中,我们发现以下问题:**

<pre><code><li>⚠️ 第 3 个标签格式错误。<dt>请确保标签为字典。</dt></li><li>⚠️ 标签: 格式错误。<dt>请确保其为列表。</dt></li><li>⚠️ 标签: 解码失败。<dt>请确保其为 JSON 格式。</dt></li></code></pre>
Expand Down Expand Up @@ -496,6 +500,8 @@ async def test_render_type_error(app: App, mocker: MockFixture):

> Plugin: 帮助

[![测试结果](https://img.shields.io/badge/RESULT-ERROR-red?style=for-the-badge)](https://github.com/owner/repo/actions/runs/123456)

**⚠️ 在发布检查过程中,我们发现以下问题:**

<pre><code><li>⚠️ 插件类型 invalid 不符合规范。<dt>请确保插件类型正确,当前仅支持 application 与 library。</dt></li><li>⚠️ 适配器 missing 不存在。<dt>请确保适配器模块名称正确。</dt></li><li>⚠️ 插件支持的适配器: 格式错误。<dt>请确保其为集合。</dt></li></code></pre>
Expand Down Expand Up @@ -552,6 +558,8 @@ async def test_render_unknown_error(app: App, mocker: MockFixture):

> Plugin: 帮助

[![测试结果](https://img.shields.io/badge/RESULT-ERROR-red?style=for-the-badge)](https://github.com/owner/repo/actions/runs/123456)

**⚠️ 在发布检查过程中,我们发现以下问题:**

<pre><code><li>⚠️ tests &gt; 2 &gt; test: unknown error</li></code></pre>
Expand Down Expand Up @@ -619,6 +627,8 @@ async def test_render_http_error(app: App, mocker: MockFixture):

> Plugin: 帮助

[![测试结果](https://img.shields.io/badge/RESULT-ERROR-red?style=for-the-badge)](https://github.com/owner/repo/actions/runs/123456)

**⚠️ 在发布检查过程中,我们发现以下问题:**

<pre><code><li>⚠️ 项目 <a href="https://www.baidu.com">主页</a> 返回状态码 404。<dt>请确保你的项目主页可访问。</dt></li><li>⚠️ 项目 <a href="12312">主页</a> 访问出错。<details><summary>错误信息</summary></details></li></code></pre>
Expand Down
Loading