Skip to content

Commit 1502254

Browse files
authored
Initialize resource
0 parents  commit 1502254

File tree

16 files changed

+2073
-0
lines changed

16 files changed

+2073
-0
lines changed

.docs/NoneBotPlugin.svg

Lines changed: 1 addition & 0 deletions
Loading

.env.test

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
PORT=8888
2+
LOG_LEVEL=DEBUG
3+
FASTAPI_RELOAD=false

.github/workflows/pypi-publish.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Publish
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
workflow_dispatch:
8+
9+
jobs:
10+
pypi-publish:
11+
name: Upload release to PyPI
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout repository
15+
uses: actions/checkout@v4
16+
17+
- name: Install uv and set the python version
18+
uses: astral-sh/setup-uv@v5
19+
with:
20+
python-version: "3.12"
21+
22+
- name: Build a binary wheel and a source tarball
23+
run: >-
24+
uv build
25+
26+
- name: Publish distribution to PyPI
27+
uses: pypa/gh-action-pypi-publish@release/v1
28+
with:
29+
password: ${{ secrets.PYPI_API_TOKEN }}

.github/workflows/pytest.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Pytest
2+
3+
on:
4+
push:
5+
branches:
6+
- '*'
7+
- '**'
8+
9+
jobs:
10+
pytest:
11+
runs-on: ubuntu-latest
12+
env:
13+
LOG_LEVEL: DEBUG
14+
strategy:
15+
matrix:
16+
python-version:
17+
- "3.10"
18+
- "3.11"
19+
- "3.12"
20+
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v4
24+
25+
- name: Install uv and set the python version
26+
uses: astral-sh/setup-uv@v5
27+
with:
28+
python-version: ${{ matrix.python-version }}
29+
30+
- name: Install Dependencies for test group
31+
run: |
32+
uv sync --group test
33+
34+
- name: Run all tests
35+
run: |
36+
python -m pytest -v -s

.github/workflows/rename.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Initialize Repository
2+
3+
on:
4+
workflow_dispatch: # 手动触发,可用于仓库首次初始化
5+
push:
6+
paths:
7+
- 'LICENSE' # 当 LICENSE 文件发生变更时触发
8+
9+
jobs:
10+
init:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v3
15+
with:
16+
fetch-depth: 0 # 获取完整历史以确保可以正确提交
17+
token: ${{ secrets.GITHUB_TOKEN }} # 使用具有写入权限的token
18+
19+
- name: Set repository variables
20+
run: |
21+
# 从环境变量 GITHUB_REPOSITORY 中提取仓库名称和所有者(格式为 owner/repo)
22+
REPO_FULL="${GITHUB_REPOSITORY}"
23+
REPO_OWNER="${REPO_FULL%/*}"
24+
REPO_NAME="${REPO_FULL#*/}"
25+
# 将横杠替换为下划线
26+
UNDERSCORE_REPO_NAME=$(echo "$REPO_NAME" | tr '-' '_')
27+
echo "REPO_OWNER=${REPO_OWNER}" >> $GITHUB_ENV
28+
echo "REPO_NAME=${REPO_NAME}" >> $GITHUB_ENV
29+
echo "UNDERSCORE_REPO_NAME=${UNDERSCORE_REPO_NAME}" >> $GITHUB_ENV
30+
echo "Repository owner: $REPO_OWNER"
31+
echo "Repository name: $REPO_NAME"
32+
echo "Repository underscore name: $UNDERSCORE_REPO_NAME"
33+
34+
- name: Update README.md
35+
run: |
36+
# 替换 README.md 中的内容
37+
rm -f README.md
38+
sed -i.bak "s/owner/${REPO_OWNER}/g" readme_template.md
39+
sed -i.bak "s/nonebot-plugin-template/${REPO_NAME}/g" readme_template.md
40+
sed -i.bak "s/nonebot_plugin_template/${UNDERSCORE_REPO_NAME}/g" readme_template.md
41+
mv readme_template.md README.md
42+
rm -f README.md.bak
43+
rm -f readme_template.md.bak
44+
45+
- name: Update pyproject.toml
46+
run: |
47+
# 替换 pyproject.toml 中的内容
48+
sed -i.bak "s/nonebot-plugin-template/${REPO_NAME}/g" pyproject.toml
49+
sed -i.bak "s/owner/${REPO_OWNER}/g" pyproject.toml
50+
sed -i.bak "s/nonebot_plugin_template/${UNDERSCORE_REPO_NAME}/g" pyproject.toml
51+
rm -f pyproject.toml.bak
52+
53+
- name: Rename plugin metadata
54+
run : |
55+
# 修改 nonebot_plugin_template/__init__.py 中的插件元数据 中的 homepage
56+
sed -i.bak "s/owner/${REPO_OWNER}/g" nonebot_plugin_template/__init__.py
57+
sed -i.bak "s/nonebot-plugin-template/${REPO_NAME}/g" nonebot_plugin_template/__init__.py
58+
rm -f nonebot_plugin_template/__init__.py.bak
59+
60+
- name: Rename plugin folder
61+
run: |
62+
if [ -d "nonebot_plugin_template" ]; then
63+
mv nonebot_plugin_template "${UNDERSCORE_REPO_NAME}"
64+
echo "Successfully renamed plugin folder to ${UNDERSCORE_REPO_NAME}"
65+
else
66+
echo "Directory nonebot_plugin_template not found."
67+
exit 1
68+
fi
69+
70+
- name: Rename tests/plugin_test plugin name
71+
run: |
72+
# 修改 tests/plugin_test.py 中的插件名称
73+
sed -i.bak "s/nonebot_plugin_template/${UNDERSCORE_REPO_NAME}/g" tests/plugin_test.py
74+
rm -f tests/plugin_test.py.bak
75+
76+
- name: Commit and push changes
77+
run: |
78+
git config user.name "github-actions[bot]"
79+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
80+
git add .
81+
git commit -m "🎉 Initialize repository with correct naming"
82+
git push

.gitignore

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
share/python-wheels/
24+
*.egg-info/
25+
.installed.cfg
26+
*.egg
27+
MANIFEST
28+
29+
# PyInstaller
30+
# Usually these files are written by a python script from a template
31+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
32+
*.manifest
33+
*.spec
34+
35+
# Installer logs
36+
pip-log.txt
37+
pip-delete-this-directory.txt
38+
39+
# Unit test / coverage reports
40+
htmlcov/
41+
.tox/
42+
.nox/
43+
.coverage
44+
.coverage.*
45+
.cache
46+
nosetests.xml
47+
coverage.xml
48+
*.cover
49+
*.py,cover
50+
.hypothesis/
51+
.pytest_cache/
52+
cover/
53+
54+
# Translations
55+
*.mo
56+
*.pot
57+
58+
# Django stuff:
59+
*.log
60+
local_settings.py
61+
db.sqlite3
62+
db.sqlite3-journal
63+
64+
# Flask stuff:
65+
instance/
66+
.webassets-cache
67+
68+
# Scrapy stuff:
69+
.scrapy
70+
71+
# Sphinx documentation
72+
docs/_build/
73+
74+
# PyBuilder
75+
.pybuilder/
76+
target/
77+
78+
# Jupyter Notebook
79+
.ipynb_checkpoints
80+
81+
# IPython
82+
profile_default/
83+
ipython_config.py
84+
85+
# pyenv
86+
# For a library or package, you might want to ignore these files since the code is
87+
# intended to run in multiple environments; otherwise, check them in:
88+
# .python-version
89+
90+
# pipenv
91+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
93+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
94+
# install all needed dependencies.
95+
#Pipfile.lock
96+
97+
# poetry
98+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
99+
# This is especially recommended for binary packages to ensure reproducibility, and is more
100+
# commonly ignored for libraries.
101+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
102+
#poetry.lock
103+
# Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration
104+
poetry.toml
105+
106+
# pdm
107+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
108+
#pdm.lock
109+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
110+
# in version control.
111+
# https://pdm.fming.dev/#use-with-ide
112+
.pdm-python
113+
114+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
115+
__pypackages__/
116+
117+
# Celery stuff
118+
celerybeat-schedule
119+
celerybeat.pid
120+
121+
# SageMath parsed files
122+
*.sage.py
123+
124+
# Environments
125+
.env
126+
.venv
127+
env/
128+
venv/
129+
ENV/
130+
env.bak/
131+
venv.bak/
132+
133+
# Spyder project settings
134+
.spyderproject
135+
.spyproject
136+
137+
# Rope project settings
138+
.ropeproject
139+
140+
# mkdocs documentation
141+
/site
142+
143+
# mypy
144+
.mypy_cache/
145+
.dmypy.json
146+
dmypy.json
147+
148+
# Pyre type checker
149+
.pyre/
150+
151+
# pytype static type analyzer
152+
.pytype/
153+
154+
# Cython debug symbols
155+
cython_debug/
156+
157+
# ruff
158+
.ruff_cache/
159+
160+
# LSP config files
161+
pyrightconfig.json
162+
163+
bot.py
164+
165+
# PyCharm
166+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
167+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
168+
# and can be added to the global gitignore or merged into this file. For a more nuclear
169+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
170+
#.idea/
171+
172+
# VisualStudioCode
173+
.vscode/*
174+
!.vscode/settings.json
175+
!.vscode/tasks.json
176+
!.vscode/launch.json
177+
!.vscode/extensions.json
178+
!.vscode/*.code-snippets

.pre-commit-config.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
default_install_hook_types: [pre-commit, prepare-commit-msg]
2+
ci:
3+
autofix_commit_msg: ":rotating_light: auto fix by pre-commit hooks"
4+
autofix_prs: true
5+
autoupdate_branch: master
6+
autoupdate_schedule: monthly
7+
autoupdate_commit_msg: ":arrow_up: auto update by pre-commit hooks"
8+
repos:
9+
- repo: https://github.com/astral-sh/ruff-pre-commit
10+
rev: v0.11.2
11+
hooks:
12+
- id: ruff
13+
args: [--fix]
14+
stages: [pre-commit]
15+
- id: ruff-format
16+
stages: [pre-commit]
17+
18+
- repo: https://github.com/nonebot/nonemoji
19+
rev: v0.1.4
20+
hooks:
21+
- id: nonemoji
22+
stages: [prepare-commit-msg]

.vscode/settings.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"python.testing.pytestArgs": [
3+
"tests"
4+
],
5+
"python.testing.unittestEnabled": false,
6+
"python.testing.pytestEnabled": true
7+
}

0 commit comments

Comments
 (0)