fix(ci): fix ootb workflow failures (check-catalog ESM crash, wrong db-server entry path, missing configs)#9
Closed
cursor[bot] wants to merge 5 commits into
Closed
Conversation
Node 22.5 (used by ootb.yml CI) does not auto-detect ESM syntax in plain .js files without "type": "module" — this made check-ootb.js crash with 'Cannot use import statement outside a module' every run. Convert to require()/__dirname to match the CommonJS convention used by every other tools/*.js script. Co-authored-by: Shiroha <Tanya7z@users.noreply.github.com>
…b-server/index.js check-ootb.js, sim-new-user.js and test-db-api.js all spawned a non-existent db-server/index.js (the real built entry is db-server/dist/index.js). This made the 'db-server 启动 + 模块接口' and 'sim-new-user 全流程通过' checks fail every CI run with 'db-server 不可达' / timeout. Co-authored-by: Shiroha <Tanya7z@users.noreply.github.com>
configs-default/db_config.json shipped modulesDir: "../modules", which db-server/src/env.ts resolves relative to PROJECT_ROOT (the repo root itself) — landing one directory *above* the repo, outside it, where no catalog.json exists. Use "modules" so it resolves to <root>/modules. Co-authored-by: Shiroha <Tanya7z@users.noreply.github.com>
configs/ is gitignored, so a fresh CI checkout never had configs/db_config.json, bds_updater.json, qq_config.json — failing the '必备仓库文件齐全' check every run. Copy the defaults in before running check-ootb, mirroring the documented local setup steps. Co-authored-by: Shiroha <Tanya7z@users.noreply.github.com>
Every other workspace's dist/ is gitignored; these two were missing, so a local > @sfmc/sdk@0.1.0 build > node build.mjs [sdk] emitting .d.ts via tsc... @sfmc/sdk build done: 13 subpaths > db-server@1.0.0 build > tsc -p tsconfig.json > qq-bridge@1.0.0 build > tsc -p tsconfig.json > bds-tools@1.1.0 build > tsc -p tsconfig.json > sfmc-cil@0.1.0 build > tsc -p tsconfig.json > @sfmc/remote-controller@0.1.0 build > tsc -p tsconfig.json leaves them as untracked/ stageable artifacts. Co-authored-by: Shiroha <Tanya7z@users.noreply.github.com>
This was referenced Jul 21, 2026
Member
|
Superseded by #12. |
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.
触发原因
ootbworkflow 在最近多次 push(包括触发本次自动化的 commit38fbf9e)上持续失败。定位到 4 个独立的真实 bug,均已修复并本地复现验证(node tools/check-ootb.js现在 6/6 全部通过)。根因与修复
tools/check-catalog.js用 ESMimport语法,但以纯.js+require()环境执行 — CI 用的 Node 22.5 没有默认开启「无 package.json type 时自动探测 ESM 语法」(该特性是 Node 22.7+ 才默认开启),所以每次都在check-ootb.js里以SyntaxError: Cannot use import statement outside a module崩溃。已改为和其他tools/*.js脚本一致的 CommonJSrequire/__dirname写法。check-ootb.js/sim-new-user.js/test-db-api.js都 spawn 了不存在的db-server/index.js— 真实入口是构建产物db-server/dist/index.js(AGENTS.md 中已经记录过这个 gotcha,但只在sim-new-user.js里提到,check-ootb.js自身也有同样的 bug)。这导致db-server 启动 + 模块接口和sim-new-user 全流程通过两项检查每次必挂(db-server 不可达/timeout)。三处均已改为指向db-server/dist/index.js。configs-default/db_config.json默认modulesDir: "../modules"—db-server/src/env.ts是相对PROJECT_ROOT(即仓库根目录本身)来 resolve 这个路径的,"../modules"会解析到仓库外面一层,找不到catalog.json。已改为"modules"。tools/test-db-api.js里手写的同款配置也一并修正。configs/被.gitignore忽略,CI 从没有把configs-default/的默认值复制进去 — 导致check-ootb.js里「必备仓库文件齐全」检查因为缺少configs/db_config.json、bds_updater.json、qq_config.json而必然失败。在.github/workflows/ootb.yml里加了一步,在 build 之后、跑 check-ootb 之前,把configs-default/*.json复制进configs/(仅在目标文件不存在时才复制,不覆盖)。附带修了一个小的一致性问题:
.gitignore里其他 workspace 的dist/都有单独条目,但漏了qq-bridge/dist/和sfmc/dist/,补上避免以后本地构建产物被误加入暂存区。验证
本地按 CI 同样的步骤跑了一遍:
npm install→npm run build --workspaces --if-present→ 复制configs-default/*.json到configs/→node tools/check-ootb.js,结果 6 / 6 全部 PASS(此前是 3/6,未修复时甚至有 SyntaxError 崩溃)。另外单独启动 db-server 后跑了node tools/smoke-modules.js,全部通过。改动文件
tools/check-catalog.js— ESM → CommonJStools/check-ootb.js,tools/sim-new-user.js,tools/test-db-api.js— db-server 入口路径修正configs-default/db_config.json—modulesDir默认值修正.github/workflows/ootb.yml— 新增 seed configs 步骤.gitignore— 补充qq-bridge/dist/、sfmc/dist/