From 88d9c775222a0a6ee8c939522ed2f73a8796c26e Mon Sep 17 00:00:00 2001 From: Stev_Wang <304865932@qq.com> Date: Wed, 4 Nov 2026 17:52:16 +0800 Subject: [PATCH] =?UTF-8?q?fix(ci):=20=E4=BF=AE=E5=A4=8D=E5=85=A8=E6=96=B0?= =?UTF-8?q?=E6=A3=80=E5=87=BA=20Lint=20=E5=A4=B1=E8=B4=A5=E5=B9=B6?= =?UTF-8?q?=E6=81=A2=E5=A4=8D=20main=20=E8=87=AA=E5=8A=A8=E8=A7=A6?= =?UTF-8?q?=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 背景:run #37 在 runner 上失败于 Lint,日志报 @lingxi/* 下发类型无法解析—— workspace 包 types 指向 dist/,而 dist/ 被 gitignore,全新检出未构建导致 类型感知规则失效;另 postgres 健康检查 -U lingxi 与 POSTGRES_USER=postgres 不一致。 改动: - ci.yml:Lint 前新增 packages 构建步骤;健康检查改为 pg_isready -U postgres; 恢复 push main 自动触发(保留 workflow_dispatch)。 - ci-local.mjs:同步补充 packages 构建步骤,避免全新检出本地 CI 同样失败。 影响面:仅 CI 配置与本地 CI 脚本,不改业务代码;push main 后自动跑完整门禁。 回滚方式:revert 本提交;如需临时停用远端 CI,注释 on.push。 验证证据:runner 冒烟 run #38 全绿(ci-smoke.yml,71s);本提交推送后由远端 ci.yml 完整链路验证。 --- .gitea/workflows/ci.yml | 14 +++++++++++--- scripts/ci-local.mjs | 6 +++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index e2ef54f..bbd474c 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -1,8 +1,11 @@ -# 远端 Gitea 未部署 Actions runner:本工作流不随 push 触发,仅供本地参考 / 手动触发。 -# 本地等价命令:pnpm ci:local(推送前必须全绿)。 +# 自建 Gitea 已部署 Actions runner(gitea-runner-01,label ubuntu-latest): +# push main 自动执行,也可在 Actions 页面手动触发。轻量冒烟见 ci-smoke.yml。 +# 本地等价命令:pnpm ci:local(推送前仍必须全绿,远端 CI 是第二道防线)。 name: ci on: + push: + branches: [main] workflow_dispatch: concurrency: @@ -25,7 +28,7 @@ jobs: ports: - 5432:5432 options: >- - --health-cmd "pg_isready -U lingxi -d lingxi_test" + --health-cmd "pg_isready -U postgres -d lingxi_test" --health-interval 5s --health-timeout 3s --health-retries 10 @@ -69,6 +72,11 @@ jobs: - name: 安装依赖 run: pnpm install --frozen-lockfile + # workspace 包的 types 指向 dist/(gitignore),全新检出必须先构建, + # 否则 Lint 的类型感知规则会报 type that cannot be resolved。 + - name: 构建 workspace 包(Lint 类型解析前置) + run: pnpm exec turbo run build --filter='./packages/*' + - name: 格式检查 run: pnpm format:check diff --git a/scripts/ci-local.mjs b/scripts/ci-local.mjs index e0112fa..c1993a9 100644 --- a/scripts/ci-local.mjs +++ b/scripts/ci-local.mjs @@ -1,6 +1,6 @@ #!/usr/bin/env node /** - * 本地 CI:在无 Gitea Actions runner 时,按 .gitea/workflows/ci.yml 的门禁顺序执行。 + * 本地 CI:按 .gitea/workflows/ci.yml 的门禁顺序执行(推送前强制;远端 Gitea Actions 为第二道防线)。 * 用法:pnpm ci:local(推荐通过 ./.tools/pnpm ci:local 锁定 pnpm 10) */ import { spawnSync } from 'node:child_process'; @@ -19,6 +19,10 @@ const e2eEnv = { /** 每一步可包含多条 pnpm 命令,任一失败立即退出;env 为该步骤追加的环境变量。 */ const steps = [ { label: '检查本地依赖(PG / Redis)', commands: [['check:dev']] }, + { + label: '构建 workspace 包(Lint 类型解析前置)', + commands: [['exec', 'turbo', 'run', 'build', '--filter=./packages/*']], + }, { label: '格式化检查', commands: [['format:check']] }, { label: 'Lint', commands: [['lint']] }, { label: '类型检查', commands: [['typecheck']] },