Skip to content

Commit 9f55911

Browse files
First Commit
1 parent 90d9613 commit 9f55911

11 files changed

Lines changed: 3708 additions & 47 deletions

File tree

.github/workflows/CI.yaml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: CI/CD Pipeline
2+
3+
on:
4+
push:
5+
branches:
6+
- "**" # 指定触发分支
7+
paths:
8+
- "**" # 监控所有文件变更
9+
10+
jobs:
11+
build:
12+
if: ${{ !contains(github.event.head_commit.message, '[ci skip]') && !contains(github.event.head_commit.message, '[skip ci]') }}
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
19+
- name: Install uv
20+
uses: astral-sh/setup-uv@v5
21+
22+
- name: Set up Python
23+
run: uv python install
24+
25+
- name: Set up environment
26+
run: |
27+
uv venv
28+
uv sync
29+
30+
- name: Get Python path
31+
run: |
32+
PYTHON_BIN="$(uv run python -c 'import sys; print(sys.executable)')"
33+
echo "PYTHON_BIN=$PYTHON_BIN" >> $GITHUB_ENV
34+
- name: Run Pyright
35+
uses: jakebailey/pyright-action@v2
36+
with:
37+
python-path: ${{ env.PYTHON_BIN }}
38+
pylance-version: latest-release
39+
- name: Setup database
40+
run: |
41+
source ./.venv/bin/activate
42+
echo "DATABASE_URL=aiosqlite+:///db.sqlite3" > .env
43+
uv run nb orm upgrade
44+
- name: Run Load Test
45+
run: |
46+
echo "ADMIN_GROUP=1" >> .env
47+
echo "LOG_LEVEL=DEBUG" >> .env
48+
source ./.venv/bin/activate
49+
uv run amrita test
50+
51+
- name: Check code format
52+
uses: astral-sh/ruff-action@v3
53+
with:
54+
args: check . --exit-non-zero-on-fix
55+
- name: Build package
56+
run: uv build

.github/workflows/PR.yaml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Pull Requests CI/CD Pipeline
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- "**"
7+
paths:
8+
- "**"
9+
10+
jobs:
11+
check:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
18+
- name: Install uv
19+
uses: astral-sh/setup-uv@v5
20+
21+
- name: Set up Python
22+
run: uv python install
23+
24+
- name: Set up environment
25+
run: |
26+
uv venv
27+
uv sync
28+
29+
- name: Get Python path
30+
run: |
31+
PYTHON_BIN="$(uv run python -c 'import sys; print(sys.executable)')"
32+
echo "PYTHON_BIN=$PYTHON_BIN" >> $GITHUB_ENV
33+
34+
- name: Run Pyright
35+
uses: jakebailey/pyright-action@v2
36+
with:
37+
python-path: ${{ env.PYTHON_BIN }}
38+
pylance-version: latest-release
39+
- name: Setup database
40+
run: |
41+
source ./.venv/bin/activate
42+
echo "DATABASE_URL=aiosqlite+:///db.sqlite3" > .env
43+
uv run nb orm upgrade
44+
- name: Run Load Test
45+
run: |
46+
echo "ADMIN_GROUP=1" >> .env
47+
echo "LOG_LEVEL=DEBUG" >> .env
48+
source ./.venv/bin/activate
49+
uv run amrita test
50+
51+
- name: Check code format
52+
uses: astral-sh/ruff-action@v3
53+
with:
54+
args: check . --exit-non-zero-on-fix
55+
56+
- name: Build package
57+
run: uv build # 生成构建产物到dist目录

.github/workflows/PUBLISH.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Publish to PyPI on Release
2+
3+
on:
4+
release:
5+
types: [created] # 当有新Release创建时触发
6+
7+
jobs:
8+
release:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v4
14+
15+
- name: Install uv
16+
uses: astral-sh/setup-uv@v5
17+
18+
- name: Set up Python
19+
run: uv python install
20+
21+
- name: Publish to PyPI
22+
run: |
23+
uv build
24+
uv publish --token ${{ secrets.PYPI_API_TOKEN }}

.gitignore

Lines changed: 20 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
# Created by https://www.toptal.com/developers/gitignore/api/python
2+
# Edit at https://www.toptal.com/developers/gitignore?templates=python
3+
4+
### Python ###
15
# Byte-compiled / optimized / DLL files
26
__pycache__/
3-
*.py[codz]
7+
*.py[cod]
48
*$py.class
59

610
# C extensions
@@ -46,7 +50,7 @@ htmlcov/
4650
nosetests.xml
4751
coverage.xml
4852
*.cover
49-
*.py.cover
53+
*.py,cover
5054
.hypothesis/
5155
.pytest_cache/
5256
cover/
@@ -94,35 +98,20 @@ ipython_config.py
9498
# install all needed dependencies.
9599
#Pipfile.lock
96100

97-
# UV
98-
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99-
# This is especially recommended for binary packages to ensure reproducibility, and is more
100-
# commonly ignored for libraries.
101-
#uv.lock
102-
103101
# poetry
104102
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105103
# This is especially recommended for binary packages to ensure reproducibility, and is more
106104
# commonly ignored for libraries.
107105
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108106
#poetry.lock
109-
#poetry.toml
110107

111108
# pdm
112109
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
113-
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
114-
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
115110
#pdm.lock
116-
#pdm.toml
117-
.pdm-python
118-
.pdm-build/
119-
120-
# pixi
121-
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
122-
#pixi.lock
123-
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
124-
# in the .venv directory. It is recommended not to include this directory in version control.
125-
.pixi
111+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
112+
# in version control.
113+
# https://pdm.fming.dev/#use-with-ide
114+
.pdm.toml
126115

127116
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
128117
__pypackages__/
@@ -136,7 +125,6 @@ celerybeat.pid
136125

137126
# Environments
138127
.env
139-
.envrc
140128
.venv
141129
env/
142130
venv/
@@ -175,33 +163,18 @@ cython_debug/
175163
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
176164
#.idea/
177165

178-
# Abstra
179-
# Abstra is an AI-powered process automation framework.
180-
# Ignore directories containing user credentials, local state, and settings.
181-
# Learn more at https://abstra.io/docs
182-
.abstra/
183-
184-
# Visual Studio Code
185-
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
186-
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
187-
# and can be added to the global gitignore or merged into this file. However, if you prefer,
188-
# you could uncomment the following to ignore the entire vscode folder
189-
# .vscode/
166+
### Python Patch ###
167+
# Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration
168+
poetry.toml
190169

191-
# Ruff stuff:
170+
# ruff
192171
.ruff_cache/
193172

194-
# PyPI configuration file
195-
.pypirc
173+
# LSP config files
174+
pyrightconfig.json
196175

197-
# Cursor
198-
# Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
199-
# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
200-
# refer to https://docs.cursor.com/context/ignore-files
201-
.cursorignore
202-
.cursorindexingignore
176+
# End of https://www.toptal.com/developers/gitignore/api/python
203177

204-
# Marimo
205-
marimo/_static/
206-
marimo/_lsp/
207-
__marimo__/
178+
# DOTENV
179+
.env.prod
180+
.env.dev

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.10

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,13 @@
11
# plugin-template
2+
23
Amrita的插件模板
4+
5+
## How to start
6+
7+
1. 使用`uv venv`初始化开发环境
8+
2. 使用`uv sync`同步虚拟环境
9+
3. 开始你的开发吧。
10+
11+
## Environment
12+
13+
请在Actions配置`PYPI_API_TOKEN`来使用自动发布脚本。

pyproject.toml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
[project]
2+
name = "your_plugin_name"
3+
description = ""
4+
version = "0.1.0"
5+
dependencies = ["amrita[full]>=0.4.2"]
6+
readme = "README.md"
7+
requires-python = ">=3.10, <3.14"
8+
9+
[tool.nonebot]
10+
plugins = [
11+
"nonebot_plugin_orm",
12+
"amrita.plugins.chat",
13+
"amrita.plugins.manager",
14+
"amrita.plugins.menu",
15+
"amrita.plugins.perm",
16+
"your_plugin_name",
17+
]
18+
plugin_dirs = []
19+
20+
[tool.setuptools.packages.find]
21+
include = ["your_plugin_name"]
22+
23+
[[tool.nonebot.adapters]]
24+
name = "OneBot V11"
25+
module_name = "nonebot.adapters.onebot.v11"
26+
[tool.uv]
27+
dev-dependencies = [
28+
"ruff>=0.12.8",
29+
"nonebot-plugin-orm[default]>=0.8.2",
30+
#"pytest>=8.4.1",
31+
]
32+
package = true
33+
34+
[tool.ruff]
35+
line-length = 88
36+
target-version = "py310"
37+
[tool.ruff.lint]
38+
select = [
39+
"F", # Pyflakes
40+
"W", # pycodestyle warnings
41+
"E", # pycodestyle errors
42+
"UP", # pyupgrade
43+
"ASYNC", # flake8-async
44+
"C4", # flake8-comprehensions
45+
"T10", # flake8-debugger
46+
"PYI", # flake8-pyi
47+
"PT", # flake8-pytest-style
48+
"Q", # flake8-quotes
49+
"RUF", # Ruff-specific rules
50+
"I", # isort
51+
"PERF", # pylint-performance
52+
]
53+
ignore = [
54+
"E402", # module-import-not-at-top-of-file
55+
"E501", # line-too-long
56+
"UP037", # quoted-annotation
57+
"RUF001", # ambiguous-unicode-character-string
58+
"RUF002", # ambiguous-unicode-character-docstring
59+
"RUF003", # ambiguous-unicode-character-comment
60+
]
61+
62+
[tool.pyright]
63+
typeCheckingMode = "standard"

0 commit comments

Comments
 (0)