添加测试流水线
This commit is contained in:
@ -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
4
.env.test
Normal file
@ -0,0 +1,4 @@
|
||||
ENVIRONMENT=test
|
||||
ENABLE_CONSOLE=false
|
||||
ENABLE_QQ=false
|
||||
ENABLE_DISCORD=false
|
||||
19
test_plugin_load.py
Normal file
19
test_plugin_load.py
Normal 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
|
||||
Reference in New Issue
Block a user