fix(ci): 修复 ootb 工作流连续失败的 4 处根因#5
Closed
cursor[bot] wants to merge 5 commits into
Closed
Conversation
仓库根 package.json 未设置 "type": "module",check-catalog.js 却使用 ESM import 语法,直接 node tools/check-catalog.js 运行会抛出 SyntaxError: Cannot use import statement outside a module。 改为与 tools/ 下其余脚本一致的 CommonJS 写法,并用 __dirname 替代 import.meta.url + fileURLToPath。 Co-authored-by: Shiroha <Tanya7z@users.noreply.github.com>
真实入口是 db-server/dist/index.js(由 tsc 构建产出),db-server/index.js 从未存在过。这导致 CI 中 'db-server 启动 + 模块接口' 与 'sim-new-user 全流程通过' 两项检查必然失败(进程启动失败 → 健康检查超时)。 改为指向 dist/index.js,并在未构建时给出明确报错提示运行 npm run build。 Co-authored-by: Shiroha <Tanya7z@users.noreply.github.com>
modulesDir 由 db-server/src/env.ts 通过 resolve(PROJECT_ROOT, modulesDir) 解析,PROJECT_ROOT 即仓库根(SFMC_ROOT)。旧值 "../modules" 会解析到仓库 外的父目录,导致模块 catalog 接口返回空列表(check-ootb 报 'modules 为 空')。改为 "modules",正确解析到 <root>/modules。 Co-authored-by: Shiroha <Tanya7z@users.noreply.github.com>
"node /tools/check-catalog.js" 是从文件系统根解析的绝对路径,该文件从 未存在于 /tools/,脚本会直接报错。改为仓库相对路径 tools/check-catalog.js。 Co-authored-by: Shiroha <Tanya7z@users.noreply.github.com>
configs/ 已被 .gitignore 忽略,CI checkout 后该目录不存在,
check-ootb.js 第 1 项 '必备仓库文件齐全' 检查
configs/{db_config,bds_updater,qq_config}.json 因此必然失败。
新增一步在构建之后、检查之前,把 configs-default/*.json 复制到
configs/(仅在目标文件不存在时才复制,不覆盖用户自定义配置)。
Co-authored-by: Shiroha <Tanya7z@users.noreply.github.com>
This was referenced Jul 21, 2026
Member
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.
触发原因
ootb工作流在最近多次 push(包括5e6fe15)上持续失败,check-ootb步骤报通过 2 / 失败 4。逐项定位后发现 4 个独立的真实 bug(均非环境问题),本 PR 逐一修复:1.
tools/check-catalog.js用 ESMimport但仓库是 CommonJS仓库根
package.json没有"type": "module",但该脚本用import ... from。直接node tools/check-catalog.js(CI 和文档里都是这么调用的)会抛出:改为与
tools/目录下其余脚本一致的 CommonJS 写法(require+__dirname),行为不变。2.
check-ootb.js/sim-new-user.js启动了不存在的db-server/index.js真实入口是构建产物
db-server/dist/index.js;db-server/index.js从未存在。这导致spawn静默失败、健康检查超时,连带拖垃 "db-server 启动 + 模块接口" 和 "sim-new-user 全流程通过" 两项检查。改为指向dist/index.js,并在未构建时报出清晰的错误提示(提示运行npm run build),而不是超时。3.
configs-default/db_config.json里modulesDir相对路径写反了db-server/src/env.ts用resolve(PROJECT_ROOT, modulesDir)解析该字段,PROJECT_ROOT就是仓库根。旧值"../modules"会解析到仓库外的上级目录,导致模块 catalog 接口返回空列表。改为"modules",正确落在<root>/modules。4. CI 从未把
configs-default/的默认配置复制到configs/configs/被.gitignore忽略,actions/checkout之后该目录根本不存在,check-ootb.js的第 1 项检查(必备仓库文件齐全)因此必然报缺失configs/db_config.json等文件。在.github/workflows/ootb.yml里新增一步,在 build 之后、check-ootb 之前,把configs-default/*.json复制到configs/(仅当目标文件不存在时才复制)。5. (顺手修)
package.json里check-catalog脚本路径多了个前导斜杠"node /tools/check-catalog.js"是从文件系统根解析的绝对路径,该文件从未存在于/tools/。改为仓库相对路径tools/check-catalog.js。验证
在本地按 CI 相同步骤复现并验证:
未改动任何运行时业务逻辑(模块系统、SAPI、QQ 桥等),仅修复工具脚本、默认配置和 CI 工作流中的路径/语法错误。