Files
easygoadmin-wiki/EasyGoAdmin_Gin_NaiveVue/zh/deploy/ci-cd.md
T
2026-10-25 17:24:27 +08:00

56 lines
1.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 11.11 CI/CD 与质量门禁
:::tip 概述
质量门禁收敛为一条命令:`make check`(fmt-check + vet + test-short + check-config)。CI 流水线围绕它组织,辅以前端检查与构建产物验证。
:::
## make check 组成
| 检查 | 内容 |
|---|---|
| fmt-check | gofmt 格式(不合规即失败) |
| vet | go vet 静态分析 |
| test-short | 短测试(跳过外部依赖,无 MySQL 的 CI 可跑) |
| check-config | config.yaml 与 .env.example 键一致性硬检查 |
```bash
make check # 本地提交前必跑
make.bat check # Windows
```
本地有 MySQL 时再跑全量 `make test`(集成测试)。
## 推荐 CI 流水线
```text
① 检出代码
② Go 环境 + make check ← 后端门禁
③ pnpm install + pnpm type:check + pnpm lint:eslint ← 前端门禁
④ pnpm build(验证产物可构建)
⑤ go build ./...(验证全量编译)
⑥ 产物归档(二进制 + dist/)
⑦ 部署ステージ(测试环境自动、生产人工确认)
```
## 门禁设计原则
| 原则 | 落地 |
|---|---|
| 快 | test-short 不碰外部依赖,门禁分钟级 |
| 硬 | check-config 硬检查配置一致性,杜绝"配置漂移上线" |
| 可本地复现 | CI 跑的就是 make check,无隐藏规则 |
| 生成器友好 | 生成产物同样过 fmt/vet——模板质量受门禁约束 |
## 部署自动化建议
- 测试环境:push 分支自动构建部署
- 生产环境:tag 触发 + 人工审批
- 回滚:保留历史产物,一键切回(systemd 二进制替换 / compose 镜像回退)
- 数据库变更:独立评审的增量脚本步骤,不混在应用部署里
## 相关
- [11.4 后端部署](/zh/deploy/backend.html)
- [11.6 Docker 生产部署](/zh/deploy/docker.html)
- [12.5 Git 提交规范](/zh/standards/git.html)