添加测试流水线

This commit is contained in:
2025-09-30 02:08:35 +08:00
parent a855c69f61
commit 8cfe58c7dd
3 changed files with 32 additions and 0 deletions

View File

@ -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

4
.env.test Normal file
View File

@ -0,0 +1,4 @@
ENVIRONMENT=test
ENABLE_CONSOLE=false
ENABLE_QQ=false
ENABLE_DISCORD=false

19
test_plugin_load.py Normal file
View File

@ -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