Repository navigation
Description
现象
test job 在 main 上从未成功过,Unit Test 步骤 100% 失败。
test job 的步骤是 checkout → setup-node → corepack enable → yarn --no-immutable → yarn test:json,没有 build,而 lib 在 .gitignore 里,于是测试在导入阶段就挂了:
Error: Cannot find package '.../node_modules/@koishijs/plugin-admin/lib/index.js'
imported from .../plugins/admin/tests/index.spec.ts
code: 'ERR_MODULE_NOT_FOUND'
但是补一个 build 步骤并不能让 CI 变绿
corepack yarn build 在 main 上本身就是失败的。冷编译(先删掉所有 *.tsbuildinfo,两次运行结果一致,exit 2):
packages/client/src/index.ts(160,7): error TS2551: Property 'register' does not exist on type 'Context'. Did you mean 'registry'?
packages/client/src/index.ts(161,48): error TS2339: Property 'argv' does not exist on type 'Yakumo'.
把这两行临时改成 (ctx as any) / (ctx.yakumo as any) 后再冷编译,tsc 与 esbuild 都过了,但紧接着仍然失败(exit 1):
Error: unknown command
Usage: yakumo build [...args]
即 build pipeline 的第三步 client 无法执行。yakumo.yml 里:
pipeline:
build:
- tsc
- esbuild
- client而 client 本应由 packages/client/src/index.ts 的 apply() 注册,但注册用的是 yakumo 里不存在的 API:
// packages/client/src/index.ts:160-161
ctx.register('client', async () => {
const paths = ctx.yakumo.locate(ctx.yakumo.argv._)已核对 yakumo@3.2.1 的 lib/index.js 与 lib/index.d.ts:
ctx.register在整个 yakumo 包里没有任何定义(cordis 的Context也没有);Yakumo类没有argv字段(只有cwd/manager/workspaces/indent/commands/config);- yakumo 自身注册命令一律走
ctx.cli.command(...)(lib/index.js:148起),pipeline 阶段也是ctx.cli.command(name, { unknownOption: 'allow' })(lib/index.js:760)。
因此 ctx.register('client', ...) 是空操作:yakumo --help 的命令列表里没有 client 这一项。这两行从 c8b506f("refa: support tsconfig path for client lib",把 src/yakumo.ts 的内容合并进 src/index.ts)起就是这个样子,之后的提交没有改过。
即使 build 修好,test job 也还缺一步
test 的脚本是 yakumo mocha -r esbuild-register -r yml-register,但 yakumo-mocha@3.0.3 的 apply() 只把 bail/retries/slow/timeout 传给 new Mocha(),从不转发 -r:
// node_modules/yakumo-mocha/lib/index.js
const mocha = new Mocha({ bail: options.bail, retries: options.retries, slow: options.slow, timeout: options.timeout })所以 corepack yarn test 直接在 @koishijs/loader/lib/index.mjs:23 抛 TypeError: Class extends value #<Object> is not a constructor or null。加上 -r 才能跑起来:
$ corepack yarn yakumo esbuild
$ node --no-experimental-strip-types node_modules/mocha/bin/mocha -r esbuild-register -r yml-register "plugins/*/tests/*.spec.ts"
5 passing (118ms)
1 failing
1) @koishijs/plugin-commands basic usage edit command:
Uncaught TypeError: Cannot destructure property 'create' of 'override' as it is undefined.
at CommandManager.accept (plugins\commands\src\index.ts:266:13)
最后那个产品 bug 已有 PR #377 在修,这里只是记录它同样挡在"CI 变绿"前面。
现状数据
- main 上最近 15 次 workflow run:
failure× 15(total_count = 15),Build步骤每次都是failure。 - 逐个 job 扫过这 15 次 run,
Unit Test步骤结论为success的次数:0。
修复需要的判断
把 ctx.register('client', …) 改写成 yakumo 3 的注册方式(ctx.cli.command('client', …)),同时把 ctx.yakumo.argv._ 换成 pipeline 阶段可用的入参来源 —— 这一步涉及"client 这个 pipeline 任务应该怎样注册、参数从哪里来",属于设计选择,所以这里只报告现象与证据,不附猜测性的补丁。
Activity