Skip to content

Commit ab3d9d7

Browse files
committed
chore: 配置 GitHub Issue/PR 模板、贡献指南和 CI 工作流
- 添加 Bug 报告和功能请求的 Issue 模板(YAML 表单式) - 添加 PR 模板、贡献指南和安全策略 - 配置 GitHub Actions CI(后端 ruff lint + 前端构建 + Django check) - 添加 ruff 配置到 pyproject.toml
1 parent 4ffac2b commit ab3d9d7

8 files changed

Lines changed: 329 additions & 0 deletions

File tree

.github/CONTRIBUTING.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# 贡献指南
2+
3+
感谢你对本项目的关注!欢迎任何形式的贡献,包括但不限于:
4+
5+
- 提交 Bug 报告
6+
- 提交功能请求
7+
- 提交代码修复或新功能(Pull Request)
8+
- 改进文档
9+
- 在 Discussions 中回答问题
10+
11+
## 开发环境设置
12+
13+
### 1. 克隆仓库
14+
15+
```bash
16+
git clone https://github.com/RMA-MUN/LangChain-RAG-FastAPI-Service.git
17+
cd LangChain-RAG-FastAPI-Service
18+
```
19+
20+
### 2. 后端设置
21+
22+
```bash
23+
cd backend
24+
uv sync
25+
cp .env.example .env # 编辑 .env 填入你的配置
26+
```
27+
28+
### 3. 前端设置
29+
30+
```bash
31+
cd front
32+
npm install
33+
# 或 pnpm install
34+
```
35+
36+
### 4. Django 用户服务
37+
38+
```bash
39+
cd DjangoUserService
40+
uv sync
41+
cp .env.example .env
42+
python manage.py migrate
43+
```
44+
45+
## 代码规范
46+
47+
### Python 代码
48+
49+
- 使用 `ruff` 进行代码检查和格式化
50+
- 类型注解优先
51+
- 遵循 PEP 8 命名规范
52+
53+
```bash
54+
cd backend
55+
ruff check .
56+
```
57+
58+
### JavaScript / Vue 代码
59+
60+
- 使用单文件组件(SFC)的 `<script setup>` 语法
61+
- 遵循 Vue 3 Composition API 风格
62+
63+
## 提交 PR 流程
64+
65+
1. Fork 本仓库并创建你的分支:`git checkout -b feature/your-feature`
66+
2. 进行你的变更
67+
3. 确保代码通过 lint 检查
68+
4. 提交前确保本地测试通过
69+
5. 提交 PR 到 `master` 分支
70+
71+
## Commit Message 规范
72+
73+
提交信息应简洁明了,建议使用以下前缀:
74+
75+
- `feat:` 新功能
76+
- `fix:` Bug 修复
77+
- `docs:` 文档更新
78+
- `refactor:` 重构
79+
- `chore:` 构建、依赖等杂项
80+
- `style:` 代码格式调整
81+
82+
## 项目结构速览
83+
84+
```
85+
backend/ # FastAPI 后端
86+
front/ # Vue 3 前端
87+
DjangoUserService/ # Django 用户服务
88+
docs/ # 文档
89+
```
90+
91+
初次贡献者可以关注 `good first issue` 标签的 Issue。
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Bug Report
2+
description: 报告一个 Bug 帮助我们改进
3+
title: "[Bug]: "
4+
labels: ["bug"]
5+
body:
6+
- type: markdown
7+
attributes:
8+
value: |
9+
感谢你花时间报告这个问题!请尽可能详细地描述你遇到的问题。
10+
11+
- type: textarea
12+
id: description
13+
attributes:
14+
label: Bug 描述
15+
description: 清晰简洁地描述这个 Bug 是什么
16+
placeholder: 当我...的时候,发生了...
17+
validations:
18+
required: true
19+
20+
- type: textarea
21+
id: reproduction
22+
attributes:
23+
label: 复现步骤
24+
description: 如何复现这个行为?
25+
placeholder: |
26+
1. 打开 '...'
27+
2. 点击 '...'
28+
3. 向下滚动到 '...'
29+
4. 看到错误
30+
validations:
31+
required: true
32+
33+
- type: textarea
34+
id: expected
35+
attributes:
36+
label: 期望行为
37+
description: 清晰简洁地描述你期望发生的事情
38+
validations:
39+
required: true
40+
41+
- type: textarea
42+
id: screenshots
43+
attributes:
44+
label: 截图 / 日志
45+
description: 如果适用,添加截图或错误日志来帮助解释你的问题
46+
placeholder: 拖拽图片到此处或粘贴日志
47+
48+
- type: dropdown
49+
id: llm_type
50+
attributes:
51+
label: LLM 类型
52+
description: 你使用的是哪种 LLM 后端?
53+
options:
54+
- 阿里云百炼 (DashScope)
55+
- Ollama (本地)
56+
- 其他
57+
validations:
58+
required: true
59+
60+
- type: input
61+
id: python_version
62+
attributes:
63+
label: Python 版本
64+
description: 你使用的 Python 版本
65+
placeholder: 3.12.4
66+
67+
- type: textarea
68+
id: additional
69+
attributes:
70+
label: 补充信息
71+
description: 任何其他有助于解决问题的上下文信息

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
blank_issues_enabled: false
2+
contact_links:
3+
- name: GitHub Discussions
4+
url: https://github.com/RMA-MUN/LangChain-RAG-FastAPI-Service/discussions
5+
about: 提问和讨论请使用 Discussions
6+
- name: Author Email
7+
url: mailto:n3032747608@163.com
8+
about: 如有隐私问题或商务合作,请通过邮件联系
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Feature Request
2+
description: 为这个项目提一个建议或想法
3+
title: "[Feature]: "
4+
labels: ["enhancement"]
5+
body:
6+
- type: markdown
7+
attributes:
8+
value: |
9+
感谢你的建议!请描述你想要的功能以及为什么它对你有用。
10+
11+
- type: textarea
12+
id: problem
13+
attributes:
14+
label: 相关痛点
15+
description: 这个功能请求是否与某个问题相关?请描述。
16+
placeholder: 当...的时候,我总是觉得很麻烦,因为...
17+
validations:
18+
required: true
19+
20+
- type: textarea
21+
id: solution
22+
attributes:
23+
label: 期望的解决方案
24+
description: 你希望看到什么行为或功能?
25+
validations:
26+
required: true
27+
28+
- type: textarea
29+
id: alternatives
30+
attributes:
31+
label: 替代方案
32+
description: 你考虑过的替代方案或变通方法
33+
34+
- type: textarea
35+
id: additional
36+
attributes:
37+
label: 补充信息
38+
description: 任何额外的上下文、截图或参考资料(如其他项目的类似功能)

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
## 相关 Issue
2+
3+
<!-- 如果这个 PR 解决了某个 Issue,请使用 "Closes #issue_number" 自动关闭 -->
4+
5+
## 变更类型
6+
7+
- [ ] Bug 修复
8+
- [ ] 新功能
9+
- [ ] 重构
10+
- [ ] 文档更新
11+
- [ ] 测试更新
12+
- [ ] 依赖更新
13+
- [ ] 其他(请说明)
14+
15+
## 描述
16+
17+
<!-- 请描述这个 PR 做了什么,以及为什么这么做 -->
18+
19+
## 测试
20+
21+
- [ ] 本地测试通过
22+
- [ ] 前端构建成功(如有前端变更)
23+
- [ ] 后端启动正常
24+
25+
## 截图(可选)
26+
27+
<!-- 对于 UI 变更,请提供前后对比截图 -->
28+
29+
## 额外信息
30+
31+
<!-- 任何 reviewers 需要知道的信息 -->

.github/SECURITY.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# 安全策略
2+
3+
## 报告安全漏洞
4+
5+
如果你发现了安全漏洞,**请不要公开提交 Issue**。请通过以下方式私下报告:
6+
7+
- 发送邮件至 **n3032747608@163.com**
8+
9+
我们会在 48 小时内确认收到报告,并在修复后公开披露。
10+
11+
## 受支持的版本
12+
13+
| 版本 | 支持状态 |
14+
|------|---------|
15+
| master (最新) | 支持 |
16+
| 其他分支 | 不支持 |

.github/workflows/ci.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
branches: [master]
8+
9+
jobs:
10+
backend-lint:
11+
name: Backend Lint
12+
runs-on: ubuntu-latest
13+
defaults:
14+
run:
15+
working-directory: backend
16+
steps:
17+
- uses: actions/checkout@v4
18+
- uses: astral-sh/setup-uv@v5
19+
with:
20+
python-version: "3.12"
21+
- name: Install dependencies
22+
run: uv sync --group dev
23+
- name: Run ruff
24+
run: uv run ruff check .
25+
26+
frontend-build:
27+
name: Frontend Build
28+
runs-on: ubuntu-latest
29+
defaults:
30+
run:
31+
working-directory: front
32+
steps:
33+
- uses: actions/checkout@v4
34+
- uses: actions/setup-node@v4
35+
with:
36+
node-version: "20"
37+
cache: "npm"
38+
cache-dependency-path: front/package-lock.json
39+
- name: Install dependencies
40+
run: npm ci
41+
- name: Build
42+
run: npm run build
43+
44+
django-check:
45+
name: Django Check
46+
runs-on: ubuntu-latest
47+
defaults:
48+
run:
49+
working-directory: DjangoUserService
50+
steps:
51+
- uses: actions/checkout@v4
52+
- uses: astral-sh/setup-uv@v5
53+
with:
54+
python-version: "3.12"
55+
- name: Install dependencies
56+
run: uv sync
57+
- name: Django check
58+
run: uv run python manage.py check --deploy
59+
env:
60+
DJANGO_SETTINGS_MODULE: DjangoUserService.settings
61+
JWT_SECRET_KEY: ci-test-key
62+
DB_ENGINE: django.db.backends.sqlite3
63+
DB_NAME: db.sqlite3
64+
CELERY_TASK_ALWAYS_EAGER: "True"

backend/pyproject.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,16 @@ dev = [
5757
"ruff>=0.3.0",
5858
]
5959

60+
[tool.ruff]
61+
target-version = "py312"
62+
line-length = 120
63+
64+
[tool.ruff.lint]
65+
select = ["E", "F", "I", "N", "W", "UP"]
66+
67+
[tool.ruff.format]
68+
quote-style = "double"
69+
6070
[[tool.uv.index]]
6171
url = "https://pypi.tuna.tsinghua.edu.cn/simple"
6272
default = true

0 commit comments

Comments
 (0)