# Profeto CI —— 首次引入自动化质量防线。 # # 背景:此前仓库无任何 CI。唯一的测试文件 frontend/src/lib/http.test.ts # 从未被自动执行过,类型检查也仅靠本地手跑 tsc。本流水线把 # 「类型检查 + 单元测试 + 构建」固化为 MR 门禁。 # # 复用项目自带的 Docker 镜像(与 docker-compose.yml 同源), # 避免 CI 环境与本地/线上不一致。 stages: - verify default: image: node:22-alpine # ── 前端:Lint ──────────────────────────────────────────────────── # 拦截「机器能看出来、人容易漏掉」的问题:幻影 CSS 变体、 # 硬编码色值、渲染期间副作用、未使用符号。 # 当前基线为 0 error / 56 warning,故本 job 会真实失败于新增 error。 frontend-lint: stage: verify before_script: - cd frontend - corepack enable - pnpm install --frozen-lockfile script: - pnpm lint cache: key: files: - frontend/pnpm-lock.yaml paths: - frontend/node_modules/ rules: - if: $CI_PIPELINE_SOURCE == "merge_request_event" - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH # ── 前端:类型检查 ──────────────────────────────────────────────── frontend-typecheck: stage: verify before_script: - cd frontend - corepack enable - pnpm install --frozen-lockfile script: - pnpm typecheck # 缓存 pnpm store,避免每次 MR 重新下载依赖 cache: key: files: - frontend/pnpm-lock.yaml paths: - frontend/node_modules/ rules: - if: $CI_PIPELINE_SOURCE == "merge_request_event" - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH # ── 前端:单元测试 ──────────────────────────────────────────────── # 这是 http.test.ts 第一次被自动化调用。它覆盖 HTTP 层的 # method/body/Content-Type 组装与 /health 免前缀豁免 —— 后者的 # 回归会导致管理后台右上角永远显示「系统异常」。 frontend-test: stage: verify before_script: - cd frontend - corepack enable - pnpm install --frozen-lockfile script: - pnpm test cache: key: files: - frontend/pnpm-lock.yaml paths: - frontend/node_modules/ rules: - if: $CI_PIPELINE_SOURCE == "merge_request_event" - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH # ── 前端:生产构建 ──────────────────────────────────────────────── # 独立于 typecheck:构建会暴露类型检查覆盖不到的问题 # (Tailwind 配置错误、资源缺失、chunk 拆分失败等)。 frontend-build: stage: verify before_script: - cd frontend - corepack enable - pnpm install --frozen-lockfile script: - pnpm build artifacts: name: "frontend-dist-$CI_COMMIT_SHORT_SHA" paths: - frontend/dist/ expire_in: 1 week cache: key: files: - frontend/pnpm-lock.yaml paths: - frontend/node_modules/ rules: - if: $CI_PIPELINE_SOURCE == "merge_request_event" - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH