ambiguous-pointer commented on issue #1644:
URL: https://github.com/apache/dubbo-admin/issues/1644#issuecomment-6877572234

   ## 解决方案思路
   
   核心是**让流水线真的在 `ai` 分支上跑起来**,然后把 `ai` 模块纳入已有的三类检查(测试 / 格式 / 许可证)。分成四步,每步都可以独立提 
PR。
   
   ### 第 1 步:把 `ai` 加进触发条件(必须先做)
   
   ```yaml
   on:
     push:
       branches:
         - develop
         - ai          # ← 新增
     pull_request:
       branches:
         - develop
         - ai          # ← 新增
   ```
   
   需要特别注意 GitHub 的语义:**`pull_request.branches` 过滤的是 PR 的 base 分支**。所以只加 `push` 
不够——base 为 `ai` 的 PR(#1585/#1616/#1618)必须靠 `pull_request` 
那一段才会触发。`riscv-build.yml` 同样只有 `develop`,也要一并加上,否则 `ai` 分支连交叉编译验证都没有。
   
   这一步是后面所有门禁生效的前提:触发条件没加上,AI 模块的测试跑了也没人看得到结果。
   
   ### 第 2 步:让 `ai` 模块进入格式与静态检查
   
   `Makefile` 的 `fmt` 目标目前只作用于根模块:
   
   ```make
   fmt:
        go fmt ./...
   ```
   
   改成:
   
   ```make
   fmt:
        go fmt ./...
        cd ai && go fmt ./...
   ```
   
   `test` 目标**已经**带了 `cd ai && go test ./... 
-short`,所以测试这块不用改——加了触发条件就自动生效。`lint` 目标同理(`golangci-lint` 需要在 `ai` 目录下再跑一次,或改用 
`--path-prefix` 一次性覆盖两个 module)。
   
   CI 步骤 `make fmt && git status && [[ -z $(git status -s) ]]` 会因此第一次真正检查到 `ai` 
模块的格式——预期会暴露若干个 gofmt 不干净的文件,需要一并修掉。
   
   ### 第 3 步:修许可证校验的覆盖盲区
   
   `.licenserc.yaml` 里的 `'**/tools/**'` 排除项本意是放行 `tools` 目录,但它同时命中了两个不该放行的位置:
   
   - `pkg/mcp/tools/**`
   - `ai/component/tools/**`
   
   建议**删除这条通配排除**,改为按具体路径精确放行(例如只放行确实不需要头的第三方资源目录),然后补齐缺失的头部:
   
   - `ai` 模块整体约 30 
个文件(`ai/cmd/index.go`、`ai/main.go`、`ai/runtime/`、`ai/config/`、`ai/schema/`、`ai/utils/`、`ai/component/**`
 下的 yaml 与 go 文件等);
   - `ai/component/tools/engine/mcp_tools.go`、`mock_tools.go`(目前首行直接是 
`package`);
   - `pkg/mcp/tools/cluster.go`、`instance.go`;
   - `ai/testutils/` 三个文件的头部引号缺失,需补齐成合法注释。
   
   删除该排除项后,受许可证检查覆盖的文件会从当前状态增加到约 **38 个**,这一步能一次性把 `ai` 模块的历史欠账清掉。
   
   ### 第 4 步:修掉流水线第一次跑就暴露的两个构建缺陷
   
   **(a)依赖镜像失效**——`ui-vue3/yarn.lock` 里 63 个包指向 
`registry.debugmode.cn`(该镜像已不能解析),而同文件其余 848 个包用的是 `registry.npmmirror.com`。CI 
步骤是 `yarn install --frozen-lockfile`,在构建开始之前就会失败。这 63 条 `resolved` 改回 
`registry.npmmirror.com` 即可(版本号与 hash 都一致,只是换了镜像域名)。
   
   **(b)prettier 与工作树判空冲突**——前端构建前会跑 `prettier --write src/`,它把工作树改脏了,于是 CI 的 
`[[ -z $(git status -s) ]]` 判空失败。两条路可选:
   
   1. 先在本地统一跑一遍 `prettier --write src/` 并把结果提交入库,同时让构建阶段只做 `prettier 
--check`(**推荐**:构建不再写盘,格式问题在 lint 阶段就暴露,而不是在构建阶段把工作树写脏);
   2. 或者把构建阶段的 `--write` 挪到独立 job。
   
   另外 `ui-vue3/postcss.config.js` 在 `ai` 分支上缺失,导致构建阶段的样式处理配置不完整,需要补齐。
   
   ### 已有可用实现
   
   上述第 1、3、4 步以及一部分第 2 步的修复,已经在 fork 上有一个完整提交:
   
   - 分支:`https://github.com/ambiguous-pointer/dubbo-admin/tree/fix/ai-branch-ci`
   - 提交:`57b2442` — *ci: run the pipeline on the ai branch and fix what it 
finds*
   - 内容:`.github/workflows/ci.yml` 加 `ai` 触发;`.licenserc.yaml` 删除 `**/tools/**` 
排除;`ai` 模块与 `ai` chat 组件补许可证头(含 `ai/cmd/index.go`);`ai/testutils` 头部修正;3 个 
console 文件 gofmt;前端 prettier 修正 + 补 `postcss.config.js`;`yarn.lock` 63 个镜像地址修正。
   
   **它需要 rebase**:该提交基于 `97d2db4`(#1598),落后于当前 `ai` 分支头 `e6cef77`(#1592),rebase 
后开 PR 即可,base 选 `ai`。
   
   ### 验证方式
   
   PR 提交后,确认 Checks 列表里出现 `dubbo-admin ci`(此前 base=`ai` 的 PR 只有 SonarCloud 
两项)。这一步本身就是这个 Issue 的验收标准——**修完之后,`ai` 分支上的 PR 必须能看到流水线运行记录**。
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to