Repository navigation
fix(ci): 超时退出码断言补 124 + PR 阶段也跑单元测试(修 main 上的红灯) - #16
Merged
Merged
Conversation
PR #14 给 run_with_deadline 加了「有 GNU timeout 就优先用它」的分支,脚本这边 case 已经改成 124|137|143,但测试的断言只写了 137|143: - macOS(本机开发环境)没有 timeout,走进程组回退,返回 143 → 本地全绿; - ubuntu-latest 有 GNU timeout,到点自杀返回 124 → main 上这个用例红。 实测复现:把 GNU timeout 的行为(自成进程组 + 整组 TERM→KILL + 返回 124)做成 PATH 上的替身,再用旧断言跑,报的错与 CI 一字不差: actual: ' ⚠ 本跳到 2s 上限被强制终止(退出码 124),降级到下一个\n…' expected: /上限被强制终止(退出码 (137|143))/ error: '超时必须明说并带上退出码' 脚本的分类没错(124 确实是 GNU timeout 到点自杀的码),错的是断言把平台的 具体退出码写死了。改成只要求「是脚本认定为被强制终止的那组码」,并补注释说明 两条实现路径各返回什么。两条路径本机都实测通过(原 143 路径 28/28;注入 GNU timeout 替身后 28/28,含孙进程回收断言)。
build-installers 原先只在 push main / tag / 手动触发时跑,PR 上只有 ocr-review 的 advisory 评审,不跑 npm test —— 所以「本机全绿、Linux 红」这类差异会一路 合进 main 才亮灯。PR #14 和 #15 就是这么各红了一次(两次都是同一个用例)。 构建类 job 都带 `startsWith(github.ref,'refs/tags/v') || event_name == 'workflow_dispatch'` 守卫,加 pull_request 后 PR 上只剩 test 这一个 job。 顺带修掉文件头一句不实的注释(原先写「此前只有 tag 与 PR 触发测试」,实际从 来没有过 pull_request 触发,git log 三个版本都没有)。
|
✅ OpenCodeReview: Review complete: 0 finding(s) across 1 selected item(s). |
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.
背景
用户报告「PR #14、#15 在 GitHub 上都报错了」。查证结果:
code-review pass)。build-installersworkflow:37749239370(chore(ocr): 评审脚本移植 Windows/Git Bash 适配 #14 的 push main,20s,failure)37750455653(fix(ocr-review): 采纳评审意见(版本探针 / 空格路径 / 注释回归) #15 的 push main,26s,failure)test/ocr-review.test.js的「单跳挂起会被强杀并降级」,error: '超时必须明说并带上退出码'。根因:一个只在 Linux 成立的行为差异
PR #14 给
scripts/ocr-review.sh的run_with_deadline()加了「有 GNU timeout 就优先用它」的新分支:脚本自己的判定已经改成了
124|137|143,但测试的断言只写了137|143:timeout,进程组回退timeout所以本地
npm test全绿、CI 红。git log -S'124|137|143' -- scripts/ocr-review.sh唯一定位到67766d4(PR #14 的 squash 合并)。本机复现(不是猜的):把 GNU timeout 的行为(自成进程组 + 整组 TERM→KILL + 返回 124)做成 PATH 上的替身,再跑旧断言,报错与 CI 一字不差:
改动
test/ocr-review.test.js—— 断言只要求「是脚本认定为被强制终止的那组码」,不锁死平台具体值;补注释说明两条实现路径各返回什么。脚本本身没动:124确实是 GNU timeout 到点自杀的码,错的是断言。.github/workflows/build-installers.yml—— 加pull_request: branches: [main]。原先 PR 上只跑 ocr-review 的 advisory 评审、不跑npm test,所以这类差异只能等合进 main 才亮灯。构建类 job 都有startsWith(github.ref,'refs/tags/v') || event_name == 'workflow_dispatch'守卫,PR 上只剩test这一个 job。顺带修掉文件头一句不实的注释(原先写「此前只有 tag 与 PR 触发测试」,git log三个版本都没有过pull_request)。验证
npm test→ 594 tests / 593 pass / 1 skipped / 0 failtest/ocr-review.test.js→ 28/28(含「孙进程必须已被回收」断言)pull_requesttest job,等于在真的 ubuntu-latest 上再验一次。