fix(test): 修复test_agent_docs.py相对路径问题,Unit Tests CI从apps/api运行也能通过 #989

Closed
xiaoxia wants to merge 3 commits from fix/test-agent-docs-path into develop
Owner

问题

test_agent_docs.py 使用相对路径 Path("docs/agents"),当 Unit Tests CI 从 apps/api/ 目录运行 pytest 时找不到 docs/agents 目录,导致3个测试全部失败。

修复

使用 Path(__file__).parent.parent.parent / "docs" / "agents" 定位项目根目录,不依赖 pytest 运行目录。

验证

  • 从项目根目录运行:3/3 passed
  • 从 apps/api/ 目录运行:3/3 passed
## 问题 `test_agent_docs.py` 使用相对路径 `Path("docs/agents")`,当 Unit Tests CI 从 `apps/api/` 目录运行 pytest 时找不到 docs/agents 目录,导致3个测试全部失败。 ## 修复 使用 `Path(__file__).parent.parent.parent / "docs" / "agents"` 定位项目根目录,不依赖 pytest 运行目录。 ## 验证 - 从项目根目录运行:3/3 passed - 从 apps/api/ 目录运行:3/3 passed

🚀 预览环境已部署

项目 详情
PR号 #989
预览链接 https://pr-989.preview.xiaoxiajianji.com
API环境 staging

💡 预览环境使用 staging API 数据,请勿在预览环境中操作重要数据。

🔄 每次提交新代码后预览环境会自动更新。

🗑️ PR 关闭或合并后,预览环境会自动清理。

🚀 **预览环境已部署** | 项目 | 详情 | |------|------| | PR号 | #989 | | 预览链接 | [https://pr-989.preview.xiaoxiajianji.com](https://pr-989.preview.xiaoxiajianji.com) | | API环境 | staging | > 💡 预览环境使用 staging API 数据,请勿在预览环境中操作重要数据。 > > 🔄 每次提交新代码后预览环境会自动更新。 > > 🗑️ PR 关闭或合并后,预览环境会自动清理。
xiaoxia added 1 commit 2026-07-27 11:26:04 +08:00
fix: 修复全量ruff/black/isort代码质量问题 (50个错误)
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 24s
CI/CD Pipeline / PR Build Web Image (pull_request) Successful in 29s
CI/CD Pipeline / Frontend Lint (pull_request) Successful in 54s
CI/CD Pipeline / Build Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 7s
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Successful in 1m37s
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Successful in 1m55s
CI/CD Pipeline / Validate - Code Quality (pull_request) Failing after 2m37s
AI Code Review / AI Code Review (pull_request) Successful in 1m43s
CI/CD Pipeline / Build Production API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been skipped
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 1m4s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / Deploy Production (pull_request) Has been skipped
CI/CD Pipeline / ACR Image Cleanup (pull_request) Has been skipped
CI/CD Pipeline / Canary Release to Production (pull_request) Has been skipped
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
CI/CD Pipeline / Frontend Unit Tests (pull_request) Successful in 26s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 3m4s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 3m17s
CI/CD Pipeline / Integration Tests (pull_request) Failing after 3m35s
CI/CD Pipeline / Unit Tests (pull_request) Failing after 6m44s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 7m16s
c8163cbadc
xiaoxia force-pushed fix/test-agent-docs-path from 351751a196 to c8163cbadc 2026-07-27 11:26:04 +08:00 Compare
xiaoxia added 1 commit 2026-07-27 11:49:33 +08:00
fix: 全量修复ruff/black/isort代码质量问题
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 23s
CI/CD Pipeline / Build Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 37s
CI/CD Pipeline / Frontend Lint (pull_request) Successful in 58s
CI/CD Pipeline / PR Build Web Image (pull_request) Successful in 1m2s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 53s
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Successful in 1m56s
CI/CD Pipeline / Frontend Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / Build Production API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Web Image (pull_request) Has been skipped
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Successful in 2m1s
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
AI Code Review / AI Code Review (pull_request) Successful in 1m35s
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / Deploy Production (pull_request) Has been skipped
CI/CD Pipeline / ACR Image Cleanup (pull_request) Has been skipped
CI/CD Pipeline / Canary Release to Production (pull_request) Has been skipped
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 2m43s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 3m6s
CI/CD Pipeline / Validate - Code Quality (pull_request) Successful in 5m2s
CI/CD Pipeline / Unit Tests (pull_request) Failing after 3m42s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 4m59s
CI/CD Pipeline / Integration Tests (pull_request) Failing after 2m58s
fbf3c5288e
- 修复50个ruff错误(未使用import、重复定义、命名歧义等)
- 解决black与isort在长import行上的死循环问题
- 2个文件使用isort:off保护向后兼容re-export块
- 全量657个文件通过ruff+black+isort三重检查
xiaoxia added 1 commit 2026-07-27 12:05:12 +08:00
fix: 恢复被ruff误删的向后兼容re-export常量
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 19s
CI/CD Pipeline / Frontend Lint (pull_request) Successful in 37s
CI/CD Pipeline / PR Build Web Image (pull_request) Successful in 32s
CI/CD Pipeline / Build Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 9s
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Successful in 1m25s
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Successful in 1m24s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 54s
CI/CD Pipeline / Frontend Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / Build Production API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
AI Code Review / AI Code Review (pull_request) Successful in 1m38s
CI/CD Pipeline / Deploy Production (pull_request) Has been skipped
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / ACR Image Cleanup (pull_request) Has been skipped
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
CI/CD Pipeline / Canary Release to Production (pull_request) Has been skipped
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 2m32s
CI/CD Pipeline / Validate - Code Quality (pull_request) Successful in 3m40s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 3m10s
CI/CD Pipeline / Unit Tests (pull_request) Successful in 2m53s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 2m3s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 50m4s
ACR Cleanup / ACR Image Cleanup (pull_request_target) Has been cancelled
Preview Cleanup / Cleanup Preview Environment (pull_request) Successful in 28s
57d45c3219
- 9个engine模块的re-export常量被ruff --fix误删(F401)
- 这些是测试文件依赖的向后兼容导出
- 全部加回并标记 # noqa: F401
Collaborator

代码审查结果 - PR #989

⚠️ 问题(1个需要修改)

  1. tests/unit/test_color_grade_config.py:在 test_all_presets_within_ranges 函数中,循环变量被重命名为 _preset,但断言错误信息的 f-string 中仍使用 preset。这会导致运行时抛出 NameError,测试无法通过。

💡 建议(3个可选)

  1. apps/worker/video_processing/unified_render_service.py:移除了 can_pass_through 的导入。请确认该函数在文件中确实不再被调用,否则会导致运行时错误。
  2. packages/domain/subtitle_style.py, trim_config.py, watermark_config.py:移除了 dataclasses.field 的导入。请确认这些文件中的 dataclass 不再使用 field() 来定义默认值或可变字段,否则会导致 NameError
  3. apps/worker/video_processing/pip_engine.py, subtitle_render_engine.py, render_subtitles.py:移除了大量常量导入(如 POSITION_BOTTOM_LEFT, DEFAULT_COLOR 等)。请确认这些常量在文件逻辑中确实未被使用,避免潜在的引用错误。

格式检查通过 | 逻辑审查需修改 | ⚠️ 建议关注性能


🤖 由 AI 代码审查机器人自动生成 | 2026-07-27 04:09:21 | 模型:

## 代码审查结果 - PR #989 ### ⚠️ 问题(1个需要修改) 1. **tests/unit/test_color_grade_config.py**:在 `test_all_presets_within_ranges` 函数中,循环变量被重命名为 `_preset`,但断言错误信息的 f-string 中仍使用 `preset`。这会导致运行时抛出 `NameError`,测试无法通过。 ### 💡 建议(3个可选) 1. **apps/worker/video_processing/unified_render_service.py**:移除了 `can_pass_through` 的导入。请确认该函数在文件中确实不再被调用,否则会导致运行时错误。 2. **packages/domain/subtitle_style.py, trim_config.py, watermark_config.py**:移除了 `dataclasses.field` 的导入。请确认这些文件中的 dataclass 不再使用 `field()` 来定义默认值或可变字段,否则会导致 `NameError`。 3. **apps/worker/video_processing/pip_engine.py, subtitle_render_engine.py, render_subtitles.py**:移除了大量常量导入(如 `POSITION_BOTTOM_LEFT`, `DEFAULT_COLOR` 等)。请确认这些常量在文件逻辑中确实未被使用,避免潜在的引用错误。 --- ✅ 格式检查通过 | ❌ 逻辑审查需修改 | ⚠️ 建议关注性能 --- <sub>🤖 由 AI 代码审查机器人自动生成 | 2026-07-27 04:09:21 | 模型: </sub> <!-- AI_CODE_REVIEW_AUTO_COMMENT -->
xiaoxia closed this pull request 2026-07-27 15:28:42 +08:00

🗑️ 预览环境已清理

PR #989 已关闭或合并,对应的预览环境已被清理。

如有需要,可以重新打开 PR 来重新生成预览环境。

🗑️ **预览环境已清理** PR #989 已关闭或合并,对应的预览环境已被清理。 > 如有需要,可以重新打开 PR 来重新生成预览环境。
Some checks are pending
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 19s
CI/CD Pipeline / Frontend Lint (pull_request) Successful in 37s
CI/CD Pipeline / PR Build Web Image (pull_request) Successful in 32s
CI/CD Pipeline / Build Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 9s
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Successful in 1m25s
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Successful in 1m24s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 54s
CI/CD Pipeline / Frontend Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / Build Production API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
AI Code Review / AI Code Review (pull_request) Successful in 1m38s
CI/CD Pipeline / Deploy Production (pull_request) Has been skipped
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / ACR Image Cleanup (pull_request) Has been skipped
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
CI/CD Pipeline / Canary Release to Production (pull_request) Has been skipped
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 2m32s
CI/CD Pipeline / Validate - Code Quality (pull_request) Successful in 3m40s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 3m10s
CI/CD Pipeline / Unit Tests (pull_request) Successful in 2m53s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 2m3s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 50m4s
ACR Cleanup / ACR Image Cleanup (pull_request_target) Has been cancelled
Preview Cleanup / Cleanup Preview Environment (pull_request) Successful in 28s

Pull request closed

Sign in to join this conversation.