Skip to content

Commit

Permalink
fix(github/config): 补上插件测试按钮 (#299)
Browse files Browse the repository at this point in the history
  • Loading branch information
he0119 authored Nov 28, 2024
1 parent 40cee3b commit 2ae0fc4
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/plugins/github/plugins/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
)
from src.plugins.github.models import IssueHandler
from src.plugins.github.plugins.publish.render import render_comment
from src.plugins.github.plugins.publish.utils import (
ensure_issue_plugin_test_button,
ensure_issue_plugin_test_button_in_progress,
)
from src.plugins.github.plugins.remove.depends import check_labels
from src.plugins.github.typing import IssuesEvent
from src.plugins.github.utils import run_shell_command
Expand Down Expand Up @@ -72,6 +76,9 @@ async def handle_remove_check(
logger.info("议题未开启,已跳过")
await config_check_matcher.finish()

# 提示插件正在测试中
await ensure_issue_plugin_test_button_in_progress(handler)

# 需要先切换到结果分支
run_shell_command(["git", "fetch", "origin", RESULTS_BRANCH])
run_shell_command(["git", "checkout", RESULTS_BRANCH])
Expand Down Expand Up @@ -115,6 +122,9 @@ async def handle_remove_check(
# 如果之前已经创建了拉取请求,则将其转换为草稿
await handler.draft_pull_request(branch_name)

# 确保插件重测按钮存在
await ensure_issue_plugin_test_button(handler)


async def review_submitted_rule(
event: PullRequestReviewSubmitted,
Expand Down
60 changes: 60 additions & 0 deletions tests/github/config/process/test_config_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,36 @@ async def test_process_config_check(
{"owner": "he0119", "repo": "action-test", "issue_number": 80},
mock_issues_resp,
)
ctx.should_call_api(
"rest.issues.async_update",
snapshot(
{
"owner": "he0119",
"repo": "action-test",
"issue_number": 80,
"body": """\
### PyPI 项目名
nonebot-plugin-treehelp
### 插件 import 包名
nonebot_plugin_treehelp
### 插件配置项
```dotenv
log_level=DEBUG
```
### 插件测试
- [x] 🔥插件测试中,请稍后\
""",
}
),
None,
)
# 检查是否可以复用评论
ctx.should_call_api(
"rest.issues.async_list_comments",
Expand Down Expand Up @@ -161,6 +191,36 @@ async def test_process_config_check(
),
None,
)
ctx.should_call_api(
"rest.issues.async_update",
snapshot(
{
"owner": "he0119",
"repo": "action-test",
"issue_number": 80,
"body": """\
### PyPI 项目名
nonebot-plugin-treehelp
### 插件 import 包名
nonebot_plugin_treehelp
### 插件配置项
```dotenv
log_level=DEBUG
```
### 插件测试
- [ ] 如需重新运行插件测试,请勾选左侧勾选框\
""",
}
),
None,
)

ctx.receive_event(bot, event)

Expand Down

0 comments on commit 2ae0fc4

Please sign in to comment.