AlexStocks commented on code in PR #1085: URL: https://github.com/apache/dubbo-go-pixiu/pull/1085#discussion_r4577108368
########## .github/workflows/admin-build.yml: ########## @@ -0,0 +1,69 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +name: Admin CI + +permissions: + contents: read + +on: + push: + paths: + - 'admin/**' + - 'cmd/admin/**' + - 'docker-compose.yml' + - 'go.mod' + - 'go.sum' + - '.github/workflows/admin-build.yml' + pull_request: + paths: + - 'admin/**' + - 'cmd/admin/**' + - 'docker-compose.yml' + - 'go.mod' + - 'go.sum' + - '.github/workflows/admin-build.yml' + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + admin-build: + name: Admin Build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + - uses: actions/setup-go@v6 + with: + go-version-file: 'go.mod' + cache: true + + - name: Download Go modules + run: sh .github/scripts/download-go-modules.sh + + - name: Build Admin backend + run: go build -o /tmp/pixiu-admin ./cmd/admin + + - name: Validate Docker Compose configuration + run: docker compose config --quiet + + - name: Check and build Admin frontend in Compose + run: >- + docker compose run --rm --no-deps frontend + sh -c 'npm ci --ignore-scripts && npm run typecheck && npm test && npm run build' Review Comment: 🟡 **这一步没有验证 compose 能把 admin 跑起来(对应 #842 的验收标准)** issue #842 的原文是 *try build `pixiu-admin` based on `docker-compose`*,而这里实际做的是「借 `frontend` 一个 service 当 Node 容器」: - `--no-deps` 明确跳过 `backend` / `etcd` / `opa` / `mysql`;`docker compose run` 也不执行 `frontend` 的 healthcheck; - 上面的 `docker compose config --quiet` 只做语法与 `${VAR:-}` 插值校验,不拉镜像、不启服务; - Go 后端是在 runner 上 `go build ./cmd/admin`,而 compose 的 `backend` 走 `go mod tidy && go run ./cmd/admin/admin.go`,还带一个对 etcd 的 `curl ... || exit 1` —— 这条链路从头到尾没被碰过。 一条具体风险:compose 里 `backend` 对 `etcd` 只有 `depends_on`(启动顺序)没有 healthcheck,`curl` 也没有重试,真实 `docker compose up` 很容易在 etcd 就绪前就 `exit 1`。这类问题当前门禁看不见,而 Similarityoung 那条评论里 *ideally add a Compose-based smoke test* 的 ideally 部分并未实现。 **Why**:`Admin CI 绿` 会被读成「compose 方案可用」,但它证明的只是「`frontend` 的 image / working_dir / volumes 能跑通四条 npm 命令」。 **建议二选一**: 1. 补一个最小 smoke:`docker compose up -d backend frontend` → 等 `frontend` healthcheck 变 `healthy`(`vite.config.ts:30-32` 已经把 port 8088 / host 0.0.0.0 配对了,这条能跑)→ `docker compose down`; 2. 如果社区认为范围就该是「复用 compose 的镜像定义」,在 #842 里把验收标准写清楚再关 issue,别让「based on docker-compose」留着歧义。 顺带一提:`docker compose run` 会以容器内 root 把 `npm ci` 生成的 `node_modules` 写进 bind mount。CI runner 是一次性的所以无害;本地开发者若先 `docker compose up` 再回宿主机 `npm run dev`,拿到的是 Linux 原生二进制。这属于 compose 既有行为,不是本 PR 引入的。 ########## .github/workflows/admin-build.yml: ########## @@ -0,0 +1,69 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +name: Admin CI + +permissions: + contents: read + +on: + push: + paths: + - 'admin/**' + - 'cmd/admin/**' + - 'docker-compose.yml' + - 'go.mod' + - 'go.sum' + - '.github/workflows/admin-build.yml' + pull_request: + paths: + - 'admin/**' + - 'cmd/admin/**' + - 'docker-compose.yml' + - 'go.mod' + - 'go.sum' + - '.github/workflows/admin-build.yml' + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + admin-build: + name: Admin Build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + - uses: actions/setup-go@v6 + with: + go-version-file: 'go.mod' + cache: true + + - name: Download Go modules + run: sh .github/scripts/download-go-modules.sh Review Comment: 🟡 **Go 侧有重试 + 缓存,npm 侧两样都没有** `91794fb2` 把 `actions/setup-node` 的 `cache: npm` / `cache-dependency-path` 一起删了。改成 compose 之后,每次都要从公网全量拉:本次 CI 日志里 `Image node:22.23.5 Pulling → Pulled` 约 11s,`added 180 packages ... in 37s`,合计占这个 job 约一半。而 Go 侧既有这个脚本的 3 次重试,又有 setup-go 的 cache(日志里有 `Cache hit occurred on the primary key setup-go-...`)。 **Why**:`paths` 过滤让 Admin CI 成为前端唯一的门禁,npm registry 一次抖动就能把它变红,而且没有任何重试兜底 —— 这是「偶发红灯」最常见的来源,比类型错误更难复现。 **建议**:给容器里的 `npm ci` 加 `--fetch-retries=3 --fetch-retry-mintimeout=20000 --prefer-offline`,或把 `~/.npm` 挂到 Actions cache。 另有一处小缺口 💭:本 workflow 直接 `sh .github/scripts/download-go-modules.sh`,但这个脚本不在上面六个 `paths` 条目里,改它不会触发 Admin CI。主 CI(`github-actions.yml` 无 paths 过滤)会跑并间接覆盖,所以不阻塞,补一条 path 成本几乎为零。 ########## docker-compose.yml: ########## @@ -114,7 +114,7 @@ services: # frontend(Web) frontend: - image: node:18.20.8 + image: node:22.23.5 Review Comment: 🟡 **固定到 22.23.5 是对的,但缺一条显式守卫;另外这里与 CI 的安装命令分叉了** 先说结论:这个改动本身是必要的修复,不只是「配套 CI」。`package-lock.json` 里 `[email protected]` 与 `[email protected]` 的 engines 都是 `^20.19.0 || >=22.12.0`,原来的 `node:18.20.8` 根本起不来 frontend。我核对了 nodejs.org 发布清单,`v22.23.5` 是 2026-11-11 发布的真实版本、当前 22.x 最高 patch;CI 日志里也有 `Image node:22.23.5 Pulling → Pulled`。Similarityoung 那条意见闭环了。 两个仍值得处理的点: **1. 回归保护靠的是隐式运行时报错。** `admin/web/package.json` 没有 `engines`,仓库也没有 `.npmrc`(无 `engine-strict`)。npm 遇到 engines 不匹配默认只发 `EBADENGINE` warning、不失败,所以换回 `node:18` 时 `npm ci` 和 `tsc --noEmit` 都可能照常通过,要等 `vite build` 用到 Node 20.19+ 的 API 才炸。建议把 CI 里的 `npm ci --ignore-scripts` 改成 `npm ci --ignore-scripts --engine-strict`,让 vite 8 的 engines 在安装阶段就硬失败;或在容器命令开头加 `node -e` 版本断言。(本机只有 Node v22.22.2,无法实测 Node 18 下的具体失败点,此处为静态推演。) **2. 这里的 `command` 与 CI 不是同一条路径。** 下面第 126-130 行是 `npm ci && npm run dev`(不带 `--ignore-scripts`),CI 是 `npm ci --ignore-scripts && typecheck && test && build`。所以 Admin CI 绿灯不能证明 compose 默认的安装路径可用,11-10 Sonar 报的 lifecycle scripts 风险在 compose 侧仍然存在。建议把两处的安装参数统一。 补充一个已核实的排除项:lockfile 里唯一带 `hasInstallScript` 的包是 `[email protected]`(macOS-only optional),Linux 不安装 —— 所以 `--ignore-scripts` 在 CI 平台没有副作用,不会反过来破坏构建。 ########## .github/workflows/admin-build.yml: ########## @@ -0,0 +1,69 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +name: Admin CI + +permissions: + contents: read + +on: + push: + paths: + - 'admin/**' + - 'cmd/admin/**' + - 'docker-compose.yml' + - 'go.mod' + - 'go.sum' + - '.github/workflows/admin-build.yml' + pull_request: + paths: + - 'admin/**' + - 'cmd/admin/**' + - 'docker-compose.yml' + - 'go.mod' + - 'go.sum' + - '.github/workflows/admin-build.yml' + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + admin-build: + name: Admin Build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 Review Comment: 💭 **建议保留 SHA pin** `9d39e41a` 把 `b9dc776f` 里的 commit SHA 改成了可变 tag(`actions/checkout@v5` / `actions/setup-go@v6`),而 GitHub Advanced Security 在 11-11 03:36 刚报过 *External GitHub Actions and workflows should be pinned to a commit hash*。 需要说清楚:仓库其它 workflow(`github-actions.yml` / `docker-build.yml` / `release.yml` / `riscv-build.yml`)全都是 tag,所以这是既有惯例、不是本 PR 引入的偏差;SonarCloud 最新 Quality Gate 也是 0 New Issues。不阻塞合并。 **Why**:`permissions: contents: read` 已经把 token 权限压到最小,但 action 代码本身仍以该 token 运行;tag 是可变引用,上游重打 tag 就会在未 review 的情况下改变 CI 行为。新建 workflow 是成本最低的收紧点。 **建议**:本文件至少保持原来的写法 `actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0`、`actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0`;全仓统一 pin 可以另开 issue。 另:本次 `npm ci` 日志报了 **9 moderate severity vulnerabilities**,当前门禁不检查。属于既存依赖问题,加 `npm audit --audit-level=moderate` 会让本 PR 上线即红,建议单开 issue 跟进。 -- 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]
