feat: doctor local health check - #37
Merged
Merged
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
doctor CLI 当前始终返回 0 且缺少对 CLI 退出码行为的测试覆盖,影响脚本/CI 使用可靠性。
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
新增 doctor 本地健康检查能力,用于快速验证 goratio 的主要模块在当前环境中是否可导入(从而尽早暴露缺失依赖或导入时错误),并通过 CLI 暴露为一个可调用的子命令。
Changes:
- 新增
goratio.doctor.run_doctor():批量导入关键模块并生成结构化检查报告。 - CLI 增加
doctor子命令,支持文本/JSON 输出。 - 增加基础单测与更新变更日志/路线图条目。
File summaries
| File | Description |
|---|---|
| tests/test_doctor.py | 新增 doctor 报告的基础断言测试。 |
| src/goratio/doctor.py | 新增本地模块导入健康检查实现与报告结构。 |
| src/goratio/cli.py | 增加 doctor 子命令解析与输出逻辑。 |
| CHANGELOG.md | 记录新增 doctor CLI 与健康检查能力。 |
| .planning/ROADMAP.md | 路线图勾选 doctor CLI,并更新当前测试数量。 |
Review details
- Files reviewed: 5/5 changed files
- Comments generated: 3
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+572
to
+579
| if args.command == "doctor": | ||
| report = run_doctor() | ||
| if args.as_json: | ||
| stdout.write(json.dumps(report, ensure_ascii=False, indent=2, sort_keys=True) + "\n") | ||
| else: | ||
| for check in report["checks"]: | ||
| stdout.write(f" {check['module']}: {check['status']}\n") | ||
| return 0 |
Comment on lines
+30
to
+32
| except Exception as exc: # noqa: BLE001 | ||
| status = f"error: {exc}" | ||
| ok = False |
Comment on lines
+1
to
+16
| import unittest | ||
|
|
||
| from goratio.doctor import run_doctor | ||
|
|
||
|
|
||
| class DoctorTests(unittest.TestCase): | ||
| def test_all_modules_import(self) -> None: | ||
| report = run_doctor() | ||
|
|
||
| self.assertTrue(report["ok"]) | ||
| self.assertGreaterEqual(report["module_count"], 10) | ||
| self.assertTrue(all(c["status"] == "ok" for c in report["checks"])) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| unittest.main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
新增 doctor 命令与 run_doctor,检查主要模块可导入。