ci(ci-stability): 为pip install和npm ci添加重试机制 (#619) #627
Reference in New Issue
Block a user
Delete Branch "feature/ci-pip-npm-retry"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
CI稳定性增强:pip install + npm ci 重试机制 (#619)
背景
#619 CI稳定性全面根治方案中,pip install / yarn install重试是计划内项。integration tests已加,但unit tests和前端npm ci还裸跑,网络抖动时容易挂。
修改内容
1. Unit Tests pip install 重试 (scripts/ci/run_unit_tests.sh)
2. 前端 npm ci 重试 (scripts/ci/step_frontend_install.sh)
预期效果
📊 审查概览
❌ 需修改的问题(严重)
无
💡 改进建议(一般)
[scripts/ci/run_unit_tests.sh] 代码重复
for循环用于处理 pip 安装重试。建议将重试逻辑提取为一个 Shell 函数(例如retry_install),接收命令和包名作为参数,以减少代码冗余,提高可维护性。[scripts/ci/run_unit_tests.sh, scripts/ci/step_frontend_install.sh] Shell 变量未加引号
[ $i -eq 3 ]中,变量$i建议使用双引号包裹,即[ "$i" -eq 3 ]。虽然在此场景下$i的值是可控的数字,但保持变量引用加引号是编写健壮 Shell 脚本的最佳实践,可以防止潜在的空值或包含空格导致的语法错误。✅ 良好实践
pip install和npm ci添加了重试逻辑,显著提高了构建的稳定性。&& break确保成功即退出,以及[ $i -eq 3 ] && exit 1确保彻底失败时脚本正确终止,逻辑清晰正确。python3 -m pip代替直接调用pip,能更明确地指定 Python 环境;docker run使用了--rm参数,确保容器退出后自动清理,避免占用磁盘空间。🤖 由 AI 代码审查机器人自动生成 | 2026-07-20 10:54:03 | 模型:
CI全绿,自动审批通过。
CI全绿,自动审批通过。
🗑️ 预览环境已清理
PR #627 已关闭或合并,对应的预览环境已被清理。
🚀 预览环境已部署