已开启
fix(ci): build.sh 变更分析失败时不再静默跳过测试 #136
lizhe创建于 22 天前
fix(ci): build.sh 变更分析失败时不再静默跳过测试 #136
已开启
合并受阻
22 天前 添加了label:cann-cla/yes
CANN-robot
22 天前 评论:
22 天前 评论:
CANN-robot
22 天前 评论:
22 天前 评论:
Thanks for your pull-request.
The full list of commands accepted by me can be found at here.
You can get sig-info at here.
You can self-configure the PR merge rules for this repository. For more details, please refer to Here.
For more, you also can visit HICANN.
PR Approval Progress
⚠️ This PR does not yet meet the following requirements:lgtm (requires ≥ 2 person(s) per module)、approve (requires ≥ 1 person(s) per module)
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| repo-cann/cannbot-dsl | ❌ (0/2)(You can also ask: 沈敏, 陆玲辉, 金炯, 陈振宇, 刘佳玮) | ❌ (0/1)(You can also ask: yang-jiwei, 陆玲辉, 金炯, 沈敏, 陈振宇) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
lizhe_li, thanks for your pull request. All authors of the commits have signed the CLA. 👍


CANN-robot
22 天前 评论:
22 天前 评论:
| 🚀 CI 流水线已启动 |
|---|
| 📋 执行详情: 点击查看流水线 |


22 天前 添加了label:ci-pipeline-running
22 天前 删除了label:ci-pipeline-running
22 天前 添加了label:ci-pipeline-failed
CANN-robot
15 天前 评论:
15 天前 评论:
| 🚀 CI 流水线已启动 |
|---|
| 📋 执行详情: 点击查看流水线 |


15 天前 删除了label:ci-pipeline-failed
15 天前 添加了label:ci-pipeline-running
15 天前 删除了label:ci-pipeline-running
15 天前 添加了label:ci-pipeline-failed
CANN-robot
15 天前 评论:
15 天前 评论:
流水线分析报告 — cannbot-dsl run#410
流水线: https://gitcode.com/CANN/cannbot-dsl/actions/runs/6895c32525aa48919bab6a2b6945e1cd | PR#136 | 2026-10-08 23:27:13 ~ 2026-10-08 23:32:44 | 失败 Job 2 个
定界结论: 环境问题 / 依赖缺失 — runner 缺少 cannbot conda 环境, 回退系统 Python 后被 PEP 668 拒绝安装
- 失败类型: 环境问题(runner 环境依赖缺失, 确定性故障, 重试无效)
- 根因: Test Job 在环境准备阶段安装 cannbotdsl wheel 时, runner 上不存在测试脚本预期的 conda env
cannbot, 回退到系统 Python(python3.12, externally-managed); pip 依据 PEP 668 拒绝系统级安装, wheel 安装失败后脚本 exit 1 - 排除项: 与本 PR 代码无关 — PR#136 仅修改
build.sh中 parse_changed_ops 失败时的报错处理(+4/-1); 失败发生在 wheel 安装阶段, 早于变更文件分析逻辑执行; 同 run 其余 11 个 Job(CodeCheck / CodeCheck_precommit / SCA / Antipoison / Test_get-pr 等)全部通过 - 处置: 由 CI/环境维护者修复:
- ① 在 runner 镜像预装
cannbotconda 环境(测试脚本预期路径), 并检查 ascend-toolkitset_env.sh挂载; - 或 ② 修改 run_tests 脚本回退路径: 创建 venv 后安装, 或 pip 加
--break-system-packages - 修复后重新触发流水线验证; PR 提交者无需改代码
- ① 在 runner 镜像预装
失败根因分析
根因 #1: 环境问题 / 依赖缺失 — conda env 'cannbot' 缺失 + 系统 Python externally-managed
- 定位步骤:
3_run_tests.log(两个 Test Job 均在 [1/3] env check 阶段失败, 各耗时 12s, 测试用例尚未执行) - 影响 Job: Test (job 158427f4), Test (job b437c44b) — 同因
- 根因证据(日志原文):
[WARN] conda env 'cannbot' not found, using default python
=== [1/3] env check ===
[WARN] ascend-toolkit set_env.sh not found; torch_npu may fail to import
[INFO] installing local cannbotdsl wheel: /opt/cannbot-dsl/whl/20260817_141417/cannbotdsl-0.3.dev126+gfd7852302-cp312-cp312-linux_x86_64.whl
error: externally-managed-environment
× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
python3-xyz, where xyz is the package you are trying to install.
note: If you believe this is a mistake, ... You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.
[ERROR] failed to install cannbotdsl wheel: /opt/cannbot-dsl/whl/20260817_141417/cannbotdsl-0.3.dev126+gfd7852302-cp312-cp312-linux_x86_64.whl
::error::Process exited with code 1
由门禁失败定界分析自动生成 | repo: cannbot-dsl | run: 6895c32525aa48919bab6a2b6945e1cd | PR#136


问题
build.sh:98调用变更分析工具(scripts/ci/parse_changed_ops.py)后没有检查返回码:ops=$("$PYTHON" "$REPO_ROOT/scripts/ci/parse_changed_ops.py" "$CHANGED_LIST") echo "affected ops: [$ops]" if [[ -z "$ops" ]]; then echo "[INFO] no operator affected, skip tests" exit 0 fi工具异常退出时 stdout 为空,于是被执行成「没有算子受影响」,整个算子测试阶段零用例执行却判定成功(CI 假绿)。这是 #22「命令失败后仍可能以成功结束」的一种具体形态。
可触发的真实场景:
requirements.txt里的包时,分析工具直接ModuleNotFoundError退出;test/test_config.yamlschema 被改坏 — 例如新增 module 结点时把src写成 mapping(Module.__init__里Path(p)直接TypeError),此时该 PR 自己的用例也会被静默跳过;改动
if ! ops=$("$PYTHON" "$REPO_ROOT/scripts/ci/parse_changed_ops.py" "$CHANGED_LIST"); then echo "[ERROR] changed-file analysis failed ($CHANGED_LIST); refusing to skip tests" >&2 exit 1 fi只在分析成功且确实无算子受影响时才跳过(
skip_all_tests: true的既定跳过路径不受影响)。验证(本机 before/after 实跑)
同一份
build.sh(before = mastere5f6641,after = 本 MR),同一份真实scripts/ci/parse_changed_ops.py/operator_list.yaml/run_tests.sh/test/test_config.yaml;沙箱仅把install_deps.sh换成桩(真脚本要求平台本地 cannbotdsl/torch wheel),并把PYTHON指向一个只做 MSYS→原生路径转换的 wrapper(CI 在 Linux 上无此问题)。[INFO] no operator affected, skip tests(零用例却成功)[ERROR] changed-file analysis failed … refusing to skip teststest_config.yamlschema 坏(TypeError)skip_all_tests: true的既定跳过no operator affectedno operator affected(无回归)affected ops: [flash_attn]affected ops: [flash_attn](无回归)场景④ 的 rc=4 来自沙箱里
test/flash_attn用例目标不存在(pytest 用法错误),两个版本一致;它同时说明测试阶段的返回码本来就是透传的。没测什么:本机没有 cannbotdsl / torch / torch_npu / NPU,没有跑通完整的 build.sh 流水线(未执行真实算子用例),也没有在平台的 conda 环境里复现场景①;以上结论限于脚本层的 before/after 行为对比。
bash -n build.sh通过,本机无 shellcheck。范围边界
#22 里另一条「
git diff双失败被当成『无变更』」(build.sh:93-96)不在本 MR 内——该区域正有 !59 在改,刻意不碰以免两处同时改同一段。本 MR 只修分析步骤这一段。