add pytest in makefile
This commit is contained in:
125
README.md
125
README.md
@@ -318,19 +318,124 @@ toolkit = S3StorageToolkit(
|
||||
)
|
||||
```
|
||||
|
||||
## 🧪 测试
|
||||
## 🧪 开发和测试
|
||||
|
||||
运行完整的功能测试:
|
||||
### 开发环境设置
|
||||
|
||||
```bash
|
||||
# 运行测试套件
|
||||
python tests/test_toolkit.py
|
||||
# 1. 克隆项目
|
||||
git clone https://github.com/mm644706215/rustfs-s3-toolkit.git
|
||||
cd rustfs-s3-toolkit
|
||||
|
||||
# 运行基本使用示例
|
||||
python examples/basic_usage.py
|
||||
# 2. 创建虚拟环境
|
||||
UV_PYTHON=python3.12 uv venv .venv
|
||||
source .venv/bin/activate
|
||||
|
||||
# 3. 安装开发依赖
|
||||
uv pip install -e ".[dev]"
|
||||
```
|
||||
|
||||
测试将验证所有 9 个核心功能是否正常工作。
|
||||
### 测试命令
|
||||
|
||||
```bash
|
||||
# 快速测试 (当前 Python 版本)
|
||||
make test-quick
|
||||
|
||||
# 完整单元测试 (带覆盖率)
|
||||
make test
|
||||
|
||||
# 多版本测试 (Python 3.9-3.13)
|
||||
make test-all
|
||||
|
||||
# 集成测试 (需要真实 S3 服务)
|
||||
make test-integration
|
||||
|
||||
# 生成覆盖率报告
|
||||
make coverage
|
||||
```
|
||||
|
||||
**注意**:
|
||||
- 单元测试 (`make test`) 使用模拟对象,不需要真实的 S3 服务
|
||||
- 集成测试 (`make test-integration`) 需要配置真实的 S3 服务连接信息
|
||||
|
||||
### 代码质量检查
|
||||
|
||||
```bash
|
||||
# 代码格式化
|
||||
make format
|
||||
|
||||
# 代码质量检查
|
||||
make lint
|
||||
|
||||
# 运行所有检查
|
||||
make all
|
||||
```
|
||||
|
||||
## 🚀 发布流程 (开发者)
|
||||
|
||||
### 推荐发布方式:使用 Makefile
|
||||
|
||||
```bash
|
||||
# 🎯 生产发布流程 (推荐) - 包含所有质量检查
|
||||
make publish-prod
|
||||
```
|
||||
|
||||
这个命令会自动执行:
|
||||
1. ✅ **代码格式化** (`black`, `isort`)
|
||||
2. ✅ **代码质量检查** (`flake8`, `mypy`)
|
||||
3. ✅ **多版本测试** (Python 3.9-3.13)
|
||||
4. ✅ **包构建和验证** (`build`, `twine check`)
|
||||
5. ✅ **交互式发布确认**
|
||||
|
||||
**重要**: 发布前必须确保所有测试通过!
|
||||
|
||||
### 其他发布选项
|
||||
|
||||
```bash
|
||||
# 快速发布 (跳过多版本测试)
|
||||
make publish
|
||||
|
||||
# 自动发布 (无交互,适合 CI/CD)
|
||||
make publish-auto
|
||||
|
||||
# 发布到 TestPyPI
|
||||
make publish-test
|
||||
|
||||
# 仅构建和检查 (不发布)
|
||||
make check
|
||||
```
|
||||
|
||||
### 发布前检查清单
|
||||
|
||||
在发布前,请确保:
|
||||
|
||||
- [ ] 更新了版本号 (`pyproject.toml` 中的 `version`)
|
||||
- [ ] 更新了 `CHANGELOG.md` (如果有)
|
||||
- [ ] **所有单元测试通过** (`make test`)
|
||||
- [ ] **多版本测试通过** (`make test-all`)
|
||||
- [ ] **代码质量检查通过** (`make lint`)
|
||||
- [ ] 文档是最新的
|
||||
- [ ] 配置了 PyPI 认证 (`~/.pypirc`)
|
||||
|
||||
### 测试策略说明
|
||||
|
||||
1. **单元测试** (`make test`): 使用模拟对象,测试代码逻辑,无需外部服务
|
||||
2. **多版本测试** (`make test-all`): 在 Python 3.9-3.13 上运行单元测试
|
||||
3. **集成测试** (`make test-integration`): 可选,需要真实 S3 服务连接
|
||||
|
||||
**发布要求**: 必须通过单元测试和多版本测试,集成测试为可选。
|
||||
|
||||
### PyPI 认证配置
|
||||
|
||||
创建 `~/.pypirc` 文件:
|
||||
```ini
|
||||
[distutils]
|
||||
index-servers = pypi
|
||||
|
||||
[pypi]
|
||||
username = __token__
|
||||
password = pypi-your-api-token-here
|
||||
```
|
||||
|
||||
## 📁 项目结构
|
||||
|
||||
@@ -339,8 +444,10 @@ rustfs-s3-toolkit/
|
||||
├── README.md # 项目文档
|
||||
├── pyproject.toml # 项目配置
|
||||
├── LICENSE # MIT 许可证
|
||||
├── install.py # 安装脚本
|
||||
├── build.py # 构建脚本
|
||||
├── Makefile # 开发工具
|
||||
├── tox.ini # 多版本测试配置
|
||||
├── publish.py # 发布脚本
|
||||
├── PACKAGING_GUIDE.md # 打包指南
|
||||
├── src/
|
||||
│ └── rustfs_s3_toolkit/
|
||||
│ ├── __init__.py # 包初始化
|
||||
|
||||
Reference in New Issue
Block a user