From 8cfe58c7ddb771e668e5d829e84b064ae3779b77 Mon Sep 17 00:00:00 2001 From: passthem Date: Tue, 30 Sep 2025 02:08:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B5=8B=E8=AF=95=E6=B5=81?= =?UTF-8?q?=E6=B0=B4=E7=BA=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .drone.yml | 9 +++++++++ .env.test | 4 ++++ test_plugin_load.py | 19 +++++++++++++++++++ 3 files changed, 32 insertions(+) create mode 100644 .env.test create mode 100644 test_plugin_load.py diff --git a/.drone.yml b/.drone.yml index eb29bb6..9ac7fec 100644 --- a/.drone.yml +++ b/.drone.yml @@ -26,6 +26,15 @@ steps: volumes: - name: docker-socket path: /var/run/docker.sock + - name: 在容器中测试插件加载 + image: docker:dind + privileged: true + commands: + - docker login -u kagami-ci -p ${KAGAMI_CI_PASSWORD} gitea.service.jazzwhom.top + - docker run --rm gitea.service.jazzwhom.top/mttu-developers/konabot:nightly-${DRONE_COMMIT_SHA} python test_plugin_load.py + environment: + KAGAMI_CI_PASSWORD: + from_secret: KAGAMI-CI-PASSWORD volumes: - name: docker-socket diff --git a/.env.test b/.env.test new file mode 100644 index 0000000..2e7236a --- /dev/null +++ b/.env.test @@ -0,0 +1,4 @@ +ENVIRONMENT=test +ENABLE_CONSOLE=false +ENABLE_QQ=false +ENABLE_DISCORD=false \ No newline at end of file diff --git a/test_plugin_load.py b/test_plugin_load.py new file mode 100644 index 0000000..175de77 --- /dev/null +++ b/test_plugin_load.py @@ -0,0 +1,19 @@ +from pathlib import Path + +import nonebot +from loguru import logger + +nonebot.init() +nonebot.load_plugins("konabot/plugins") + +plugins = nonebot.get_loaded_plugins() +len_requires = len( + [f for f in Path("konabot/plugins").iterdir() if f.is_dir() and (f / "__init__.py").exists()] +) + +plugins = [p for p in plugins if p.module.__name__.startswith("konabot.plugins")] + +logger.info(f"已经加载的插件数量 {len(plugins)}") +logger.info(f"期待加载的插件数量 {len_requires}") + +assert len(plugins) == len_requires