Skip to content

Commit

Permalink
remove: 移除 pre-commit 相关操作 (#310)
Browse files Browse the repository at this point in the history
  • Loading branch information
he0119 authored Dec 5, 2024
1 parent 794b16a commit 2af9375
Show file tree
Hide file tree
Showing 11 changed files with 11 additions and 212 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/lang/zh-CN/
- 修复机器人修改议题等操作时仍会触发响应器的问题
- 修复修改配置流程中忘记修改标题的问题

### Removed

- 移除 pre-commit 相关操作

## [4.1.1] - 2024-12-01

### Added
Expand Down
10 changes: 0 additions & 10 deletions examples/noneflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,6 @@ jobs:
with:
token: ${{ steps.generate-token.outputs.token }}

- name: Cache pre-commit hooks
uses: actions/cache@v4
with:
path: .cache/.pre-commit
key: noneflow-${{ runner.os }}-${{ hashFiles('.pre-commit-config.yaml') }}

- name: NoneFlow
uses: docker://ghcr.io/nonebot/noneflow:latest
with:
Expand All @@ -69,7 +63,3 @@ jobs:
env:
APP_ID: ${{ secrets.APP_ID }}
PRIVATE_KEY: ${{ secrets.APP_KEY }}
PRE_COMMIT_HOME: /github/workspace/.cache/.pre-commit

- name: Fix permission
run: sudo chown -R $(whoami):$(id -ng) .cache/.pre-commit
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ dependencies = [
"jinja2>=3.1.4",
"nonebot-adapter-github>=0.4.1",
"nonebot2>=2.4.0",
"pre-commit>=4.0.1",
"pydantic-extra-types>=2.10.0",
"pyjson5>=1.6.7",
"tzdata>=2024.2",
Expand Down
21 changes: 5 additions & 16 deletions src/plugins/github/plugins/publish/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
get_issue_handler,
get_related_issue_handler,
get_related_issue_number,
install_pre_commit_hooks,
is_bot_triggered_workflow,
is_publish_workflow,
)
Expand Down Expand Up @@ -74,9 +73,7 @@ async def check_rule(
)


@publish_check_matcher.handle(
parameterless=[Depends(bypass_git), Depends(install_pre_commit_hooks)]
)
@publish_check_matcher.handle(parameterless=[Depends(bypass_git)])
async def handle_publish_plugin_check(
bot: GitHubBot,
state: T_State,
Expand Down Expand Up @@ -108,9 +105,7 @@ async def handle_publish_plugin_check(
state["validation"] = result


@publish_check_matcher.handle(
parameterless=[Depends(bypass_git), Depends(install_pre_commit_hooks)]
)
@publish_check_matcher.handle(parameterless=[Depends(bypass_git)])
async def handle_adapter_publish_check(
bot: GitHubBot,
state: T_State,
Expand All @@ -130,9 +125,7 @@ async def handle_adapter_publish_check(
state["validation"] = result


@publish_check_matcher.handle(
parameterless=[Depends(bypass_git), Depends(install_pre_commit_hooks)]
)
@publish_check_matcher.handle(parameterless=[Depends(bypass_git)])
async def handle_bot_publish_check(
bot: GitHubBot,
state: T_State,
Expand All @@ -152,9 +145,7 @@ async def handle_bot_publish_check(
state["validation"] = result


@publish_check_matcher.handle(
parameterless=[Depends(bypass_git), Depends(install_pre_commit_hooks)]
)
@publish_check_matcher.handle(parameterless=[Depends(bypass_git)])
async def handle_pull_request_and_update_issue(
bot: GitHubBot,
validation: ValidationDict = Arg(),
Expand Down Expand Up @@ -199,9 +190,7 @@ async def pr_close_rule(
pr_close_matcher = on_type(PullRequestClosed, rule=Rule(pr_close_rule))


@pr_close_matcher.handle(
parameterless=[Depends(bypass_git), Depends(install_pre_commit_hooks)]
)
@pr_close_matcher.handle(parameterless=[Depends(bypass_git)])
async def handle_pr_close(
event: PullRequestClosed,
bot: GitHubBot,
Expand Down
5 changes: 1 addition & 4 deletions src/plugins/github/plugins/remove/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
get_issue_handler,
get_related_issue_number,
get_type_by_labels_name,
install_pre_commit_hooks,
is_bot_triggered_workflow,
is_remove_workflow,
)
Expand Down Expand Up @@ -71,9 +70,7 @@ async def check_rule(
)


@remove_check_matcher.handle(
parameterless=[Depends(bypass_git), Depends(install_pre_commit_hooks)]
)
@remove_check_matcher.handle(parameterless=[Depends(bypass_git)])
async def handle_remove_check(
bot: GitHubBot,
installation_id: int = Depends(get_installation_id),
Expand Down
5 changes: 1 addition & 4 deletions src/plugins/github/plugins/resolve/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
get_related_issue_handler,
get_related_issue_number,
get_type_by_labels_name,
install_pre_commit_hooks,
is_publish_workflow,
is_remove_workflow,
)
Expand Down Expand Up @@ -43,9 +42,7 @@ async def pr_close_rule(
pr_close_matcher = on_type(PullRequestClosed, rule=pr_close_rule, priority=10)


@pr_close_matcher.handle(
parameterless=[Depends(bypass_git), Depends(install_pre_commit_hooks)]
)
@pr_close_matcher.handle(parameterless=[Depends(bypass_git)])
async def handle_pr_close(
event: PullRequestClosed,
bot: GitHubBot,
Expand Down
10 changes: 0 additions & 10 deletions tests/github/config/process/test_config_pull_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,6 @@ async def test_config_process_pull_request(
check=True,
capture_output=True,
),
mocker.call(
["pre-commit", "install", "--install-hooks"],
check=True,
capture_output=True,
),
mocker.call(
["git", "push", "origin", "--delete", "publish/issue76"],
check=True,
Expand Down Expand Up @@ -171,11 +166,6 @@ async def test_process_config_pull_request_not_merged(
check=True,
capture_output=True,
),
mocker.call(
["pre-commit", "install", "--install-hooks"],
check=True,
capture_output=True,
),
mocker.call(
["git", "push", "origin", "--delete", "publish/issue76"],
check=True,
Expand Down
50 changes: 0 additions & 50 deletions tests/github/publish/process/test_publish_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,6 @@ async def test_bot_process_publish_check(
check=True,
capture_output=True,
),
mocker.call(
["pre-commit", "install", "--install-hooks"],
check=True,
capture_output=True,
),
mocker.call(
["git", "switch", "-C", "publish/issue80"],
check=True,
Expand Down Expand Up @@ -348,11 +343,6 @@ async def test_adapter_process_publish_check(
check=True,
capture_output=True,
),
mocker.call(
["pre-commit", "install", "--install-hooks"],
check=True,
capture_output=True,
),
mocker.call(
["git", "switch", "-C", "publish/issue80"],
check=True,
Expand Down Expand Up @@ -640,11 +630,6 @@ async def test_plugin_process_publish_check(
check=True,
capture_output=True,
),
mocker.call(
["pre-commit", "install", "--install-hooks"],
check=True,
capture_output=True,
),
mocker.call(
["git", "switch", "-C", "publish/issue80"],
check=True,
Expand Down Expand Up @@ -937,11 +922,6 @@ async def test_plugin_process_publish_check_re_run(
check=True,
capture_output=True,
),
mocker.call(
["pre-commit", "install", "--install-hooks"],
check=True,
capture_output=True,
),
mocker.call(
["git", "switch", "-C", "publish/issue80"],
check=True,
Expand Down Expand Up @@ -1161,11 +1141,6 @@ async def test_edit_title(
check=True,
capture_output=True,
),
mocker.call(
["pre-commit", "install", "--install-hooks"],
check=True,
capture_output=True,
),
mocker.call(
["git", "switch", "-C", "publish/issue80"],
check=True,
Expand Down Expand Up @@ -1471,11 +1446,6 @@ async def test_process_publish_check_not_pass(
check=True,
capture_output=True,
),
mocker.call(
["pre-commit", "install", "--install-hooks"],
check=True,
capture_output=True,
),
] # type: ignore
)

Expand Down Expand Up @@ -1546,11 +1516,6 @@ async def test_issue_state_closed(
check=True,
capture_output=True,
),
mocker.call(
["pre-commit", "install", "--install-hooks"],
check=True,
capture_output=True,
),
] # type: ignore
)

Expand Down Expand Up @@ -1844,11 +1809,6 @@ async def test_skip_plugin_check(
check=True,
capture_output=True,
),
mocker.call(
["pre-commit", "install", "--install-hooks"],
check=True,
capture_output=True,
),
] # type: ignore
)

Expand Down Expand Up @@ -1982,11 +1942,6 @@ async def test_convert_pull_request_to_draft(
check=True,
capture_output=True,
),
mocker.call(
["pre-commit", "install", "--install-hooks"],
check=True,
capture_output=True,
),
] # type: ignore
)

Expand Down Expand Up @@ -2145,11 +2100,6 @@ async def test_process_publish_check_ready_for_review(
check=True,
capture_output=True,
),
mocker.call(
["pre-commit", "install", "--install-hooks"],
check=True,
capture_output=True,
),
mocker.call(
["git", "switch", "-C", "publish/issue80"],
check=True,
Expand Down
30 changes: 0 additions & 30 deletions tests/github/remove/process/test_remove_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,6 @@ async def test_process_remove_bot_check(
check=True,
capture_output=True,
),
mocker.call(
["pre-commit", "install", "--install-hooks"],
check=True,
capture_output=True,
),
mocker.call(
["git", "switch", "-C", "remove/issue80"],
check=True,
Expand Down Expand Up @@ -377,11 +372,6 @@ async def test_process_remove_plugin_check(
check=True,
capture_output=True,
),
mocker.call(
["pre-commit", "install", "--install-hooks"],
check=True,
capture_output=True,
),
mocker.call(
["git", "switch", "-C", "remove/issue80"],
check=True,
Expand Down Expand Up @@ -524,11 +514,6 @@ async def test_process_remove_not_found_check(
check=True,
capture_output=True,
),
mocker.call(
["pre-commit", "install", "--install-hooks"],
check=True,
capture_output=True,
),
] # type: ignore
)

Expand Down Expand Up @@ -645,11 +630,6 @@ async def test_process_remove_author_info_not_eq(
check=True,
capture_output=True,
),
mocker.call(
["pre-commit", "install", "--install-hooks"],
check=True,
capture_output=True,
),
] # type: ignore
)

Expand Down Expand Up @@ -764,11 +744,6 @@ async def test_process_remove_issue_info_not_found(
check=True,
capture_output=True,
),
mocker.call(
["pre-commit", "install", "--install-hooks"],
check=True,
capture_output=True,
),
] # type: ignore
)

Expand Down Expand Up @@ -864,11 +839,6 @@ async def test_process_remove_driver(
check=True,
capture_output=True,
),
mocker.call(
["pre-commit", "install", "--install-hooks"],
check=True,
capture_output=True,
),
] # type: ignore
)

Expand Down
10 changes: 0 additions & 10 deletions tests/github/remove/process/test_remove_pull_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,6 @@ async def test_remove_process_pull_request(
check=True,
capture_output=True,
),
mocker.call(
["pre-commit", "install", "--install-hooks"],
check=True,
capture_output=True,
),
mocker.call(
["git", "push", "origin", "--delete", "publish/issue76"],
check=True,
Expand Down Expand Up @@ -177,11 +172,6 @@ async def test_process_remove_pull_request_not_merged(
check=True,
capture_output=True,
),
mocker.call(
["pre-commit", "install", "--install-hooks"],
check=True,
capture_output=True,
),
mocker.call(
["git", "push", "origin", "--delete", "publish/issue76"],
check=True,
Expand Down
Loading

0 comments on commit 2af9375

Please sign in to comment.