fix(ci): 修复 staging 测试 shell 引号嵌套 bug,测试从未实际运行 #1290
Reference in New Issue
Block a user
Delete Branch "bugfix/1286-staging-ci-shell-quoting"
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?
问题
.gitea/workflows/ci-pipeline.yml中两个 staging 测试 job 的docker create命令存在 shell 引号嵌套 bug,导致测试从未实际运行过。Bug 1: Staging E2E Tests
sh -lc "...\$i..."双引号导致$i被外层 bash 展开为unbound variableBug 2: Staging API Integration Tests
sh -lc '...\"...\"...'单引号内\"是字面反斜杠+引号,dash 报Syntax errorBug 3: Production Browser E2E
同样的引号问题
修复方案
提取 docker run 逻辑为独立脚本
scripts/ci/run_staging_tests.sh:bash -c '...'(单引号保护,$i不会被外层展开)bash替代sh(dash),避免引号解析差异bash scripts/ci/run_staging_tests.sh e2e|api验收标准
unbound variable或Syntax error脚本级错误🚀 预览环境已部署
代码审查结果 - PR #1290
⚠️ 问题(1个需要修改)
docker create ... bash -c '...'的命令字符串中,重试逻辑for ...; do npm ci ... && break; ...; done && npx ...缺少set -e。npm ci连续3次失败后,循环结束。由于没有set -e,该命令段的退出状态由最后一条命令sleep 15决定(退出码0),导致&& npx ...被跳过,但容器整体以状态码0退出。.gitea/workflows/ci-pipeline.yml 第1473行的 Production E2E 测试步骤中。bash -c引用的字符串开头添加set -e;。例如:bash -c 'set -e; for i in 1 2 3; do ...'。💡 建议(1个可选)
set -eu。set -eu,虽然docker run的退出码通常能正确传递,但保留set -eu能确保脚本在遇到未定义变量等意外情况时立即报错,提高 CI 脚本的健壮性。✅ 格式检查通过 | ❌ 逻辑审查需修改 | ✅ 性能良好
🤖 由 AI 代码审查机器人自动生成 | 2026-08-07 14:40:13 | 模型:
🗑️ 预览环境已清理
PR #1290 已关闭或合并,对应的预览环境已被清理。