贡献工作流(中文译文)
原始 DeepWiki 页面:https://deepwiki.com/argilla-io/argilla/5.2-contribution-workflow
翻译时间:2026-05-27T08:44:29.043Z
翻译模型:deepseek-chat
原文字符数:13056
项目:Argilla (argilla)
---
贡献工作流
相关源文件
以下文件被用作生成此 Wiki 页面的上下文:
.github/workflows/argilla-frontend.build-push-dev-frontend-docker.yml.github/workflows/argilla-frontend.deploy-environment.yml.github/workflows/argilla-frontend.yml.github/workflows/argilla-server.yml.github/workflows/argilla-v1.yml.github/workflows/argilla.docs.yml.github/workflows/argilla.yml.github/workflows/close-inactive-issues-bot.ymldocs/_source/.readthedocs.yamldocs/_source/_common/tabs/argilla_install_python.mddocs/_source/_static/images/og-doc.pngdocs/_source/_templates/page.htmldocs/_source/community/contributing.mddocs/_source/community/developer_docs.mddocs/_source/community/migration-rubrix.mddocs/_source/conf.pydocs/_source/getting_started/installation/deployments/docker.mddocs/_source/getting_started/installation/deployments/docker_compose.mddocs/_source/getting_started/installation/deployments/python.mddocs/_source/getting_started/quickstart.mddocs/_source/reference/cli.mddocs/_source/reference/notebooks.rstdocs/_source/reference/python/python_client.rstdocs/_source/reference/python/python_training.rstdocs/_source/requirements.txtdocs/migration-rubrix.mddocs/template.ipynb
本文档详细介绍了向 Argilla 项目贡献代码的流程,涵盖从搭建开发环境到将代码合并到主仓库的整个过程。有关配置开发环境的详细说明,请参阅开发环境搭建。
前置条件
在向 Argilla 贡献代码之前,请确保您已完成以下操作:
- 了解仓库结构:
- argilla/:Python SDK - argilla-server/:FastAPI 服务器 - argilla-frontend/:Vue.js 用户界面 - docs/:文档
- 加入社区:通过 Discord 与团队和其他贡献者联系。
- 搭建环境:按照开发环境搭建中的说明配置您的开发环境。
来源:
- docs/_source/community/contributing.md
- docs/_source/community/developer_docs.md
贡献流程概览
下图展示了贡献工作流的高层概览:
graph TD
A["Fork 仓库"] --> B["git clone https://github.com/[username]/argilla.git"]
B --> C["git remote add upstream https://github.com/argilla-io/argilla.git"]
C --> D["git checkout -b feature/new-feature"]
D --> E["进行代码修改"]
E --> F["pytest tests"]
F --> G["git push origin feature/new-feature"]
G --> H["在 GitHub 上创建拉取请求"]
H --> I["GitHub Actions CI (.github/workflows/*.yml)"]
I --> J["代码评审流程"]
J --> K["处理评审意见"]
K --> L["PR 合并到 develop/main"]
来源:
- docs/_source/community/contributing.md
第一步:Fork 和克隆
- Fork 仓库:访问 Argilla GitHub 仓库并点击 "Fork" 按钮。
- 克隆您的 Fork:
git clone https://github.com/[您的 GitHub 用户名]/argilla.git
cd argilla
- 添加上游远程仓库:
git remote add upstream https://github.com/argilla-io/argilla.git
来源:
- docs/_source/community/contributing.md:80-87
第二步:创建分支
为每个要解决的问题创建一个新分支,并使用适当的前缀:
# 对于代码修改,使用 develop 作为基础分支
git checkout develop
git pull upstream develop
git checkout -b feature/您的功能名称
# 对于文档修改,使用 main 作为基础分支
git checkout main
git pull upstream main
git checkout -b docs/您的文档修改
注意:仅文档修改使用main分支。所有其他修改请使用develop分支。
来源:
- docs/_source/community/contributing.md:94-110
第三步:进行修改
- 实现您的修改:进行必要的代码修改。
- 遵循编码规范:运行
pre-commit以确保代码格式正确。 - 添加测试:为您的修改添加单元测试/集成测试。
- 更新 CHANGELOG.md:在相应部分下添加条目:
- 修复了 `init` 方法的键错误([#123](链接到 PR))。由 @github_handle 贡献。
来源:
- docs/_source/community/contributing.md:117-134
第四步:测试
在提交之前,请确保所有测试通过:
对于 Python SDK:
pytest tests/unit
pytest tests/integration
对于服务器:
cd argilla-server
pdm test test/unit
对于前端:
cd argilla-frontend
npm run test
来源:
- docs/_source/community/developer_docs.md:362-399
第五步:提交拉取请求
- 推送您的分支:
git push origin 您的分支名称
- 创建拉取请求:访问 GitHub,针对适当的基础分支(代码修改使用
develop,文档修改使用main)创建 PR。
- 填写 PR 模板:添加描述性标题并使用适当的前缀(
feat:、bug:、docs:),关联相关问题,并描述您的修改。
- 添加标签:为您的 PR 添加相关标签(例如
feature、bug、documentation)。
来源:
- docs/_source/community/contributing.md:166-195
持续集成与持续交付管线
当您提交 PR 时,GitHub Actions 会自动运行多个 CI/CD 工作流:
graph TD
PR["拉取请求"] --> CI["GitHub Actions CI"]
CI --> SDK[".github/workflows/argilla.yml"]
CI --> Server[".github/workflows/argilla-server.yml"]
CI --> Frontend[".github/workflows/argilla-frontend.yml"]
CI --> Docs[".github/workflows/argilla.docs.yml"]
SDK --> SDK_Tests["pdm run test tests/unit"]
SDK_Tests --> SDK_Build["pdm build"]
Server --> Server_Tests["ARGILLA_DATABASE_URL=postgresql:// pdm test tests/unit"]
Server_Tests --> Server_Build["pdm build"]
Server_Build --> Docker["docker build"]
Frontend --> Frontend_Tests["npm run test"]
Frontend_Tests --> Frontend_Build["npm run build"]
Docs --> Docs_Build["pdm run mike deploy"]
SDK_Build --> Checks["所有检查通过?"]
Docker --> Checks
Frontend_Build --> Checks
Docs_Build --> Checks
Checks -- "是" --> Review["PR 评审"]
Checks -- "否" --> Fix["修复问题"]
Review -- "已批准" --> Merge["PR 合并"]
Review -- "请求修改" --> Fix
Fix --> PR
Merge --> Release["如果是 main 分支:pdm publish 到 PyPI"]
CI/CD 管线根据受影响的组件运行不同的工作流:
- SDK 管线(
.github/workflows/argilla.yml):
- 当 argilla/ 中的文件发生更改时触发 - 使用多个 Python 版本(3.9-3.13)测试 SDK - 构建 SDK 包 - 如果在 main 分支上,则发布到 PyPI
- 服务器管线(
.github/workflows/argilla-server.yml):
- 当 argilla-server/ 中的文件发生更改时触发 - 设置测试服务(Elasticsearch、PostgreSQL、Redis) - 构建服务器包和 Docker 镜像 - 如果在 main 分支上,则发布到 PyPI 和 Docker Hub
- 前端管线(
.github/workflows/argilla-frontend.yml):
- 当 argilla-frontend/ 中的文件发生更改时触发 - 运行 linting 和测试 - 构建前端资源
- 文档管线(
.github/workflows/argilla.docs.yml):
- 当文档文件发生更改或打标签时触发 - 构建并部署文档到相应版本
来源:
- .github/workflows/argilla.yml
- .github/workflows/argilla-server.yml
- .github/workflows/argilla-frontend.yml
- .github/workflows/argilla.docs.yml
评审流程
CI 检查通过后,维护者将评审您的 PR。他们可能会:
- 请求修改:要求对您的代码进行修改。
- 批准:按原样批准您的 PR。
- 评论:提供一般性反馈,但不明确批准或拒绝。
处理评审意见的步骤:
- 在您的分支上进行请求的修改。
- 将修改推送到您的 Fork。
- 回复评审意见,说明您已进行的修改。
一旦 PR 获得批准且所有检查通过,维护者将合并您的 PR,通常使用 squash 和 merge 策略以保持提交历史的整洁。
来源:
- docs/_source/community/contributing.md:193-204
开发环境搭建
下图说明了搭建开发环境的过程:
graph TD
Clone["git clone https://github.com/[username]/argilla.git"] --> Install["安装依赖"]
Install --> SDK["pip install -e ."]
Install --> Server["pip install -e .[server,listeners,postgresql]"]
Install --> PreCommit["pre-commit install"]
Install --> Frontend["cd argilla-frontend && npm install"]
PreCommit --> DB["设置数据库"]
SDK --> DB
Server --> DB
DB --> ES["docker run elasticsearch-for-argilla"]
DB --> Redis["docker run redis"]
DB --> Postgres["docker run postgres(可选)"]
ES --> Migrate["argilla server database migrate"]
Redis --> Migrate
Postgres --> Migrate
Migrate --> User["argilla server database users create_default"]
User --> RunServer["argilla server start"]
User --> RunFrontend["cd argilla-frontend && npm run dev"]
RunServer --> Test["运行测试(pytest/pdm test)"]
RunFrontend --> Test
Test --> Ready["准备就绪,可以开始开发"]
关键搭建步骤:
- 安装依赖:
# 对于 Python SDK
cd argilla
pip install -e .
# 对于包含所有扩展的服务器
pip install -e ".[server,listeners,postgresql,integrations,tests]"
# 对于代码格式化
pip install pre-commit
pre-commit install
# 对于前端
cd argilla-frontend
npm install
- 设置数据库:
- Elasticsearch:用于向量存储(必需) - Redis:用于任务队列(必需) - PostgreSQL(可选):替代 SQLite 用于关系数据
- 运行数据库迁移:
argilla server database migrate
argilla server database users create_default
- 启动服务:
# 启动服务器
argilla server start
# 启动前端(在另一个终端中)
cd argilla-frontend
npm run dev
来源:
- docs/_source/community/developer_docs.md:152-351
组件特定指南
| 组件 | 基础分支 | 测试命令 | 受影响文件 |
|---|---|---|---|
| SDK | develop | pytest tests/unit tests/integration | argilla/** |
| 服务器 | develop | pdm test test/unit | argilla-server/** |
| 前端 | develop | npm run test | argilla-frontend/** |
| 文档 | main | sphinx-autobuild docs/_source docs/_build/html | docs/_source/** |
来源:
- docs/_source/community/developer_docs.md
- docs/_source/community/contributing.md
PR 最佳实践
- 保持 PR 聚焦:每个 PR 只解决一个问题或功能。
- 包含测试:为您的修改添加或更新测试。
- 更新文档:保持文档与代码修改同步。
- 使用适当的前缀:
- 关联问题:始终在 PR 描述中引用相关问题
- 编写有意义的提交信息:使用清晰且描述性的提交信息
- 应用标签:为您的 PR 添加适当标签以便于分类
- PR:在标题中使用 feat:、bug: 或 docs: 前缀 - 分支:使用 feature/、bug/ 或 docs/ 前缀
来源:
- docs/_source/community/contributing.md
- .github/workflows/argilla.yml
- .github/workflows/argilla-server.yml
- .github/workflows/argilla-frontend.yml
- .github/workflows/argilla.docs.yml