build(migration): push之前校验migration multiple head

This commit is contained in:
sophie committed 2026-06-23 13:37:30 +08:00
1 parent 1bc938155a
commit 2aa8609c17
3 files changed
+53 -8

No files matched your search

+7 -6
View File
@@ -16,7 +16,7 @@
|------|------|--------|----------|
| **pre-commit** | `git commit` | 已安装 Hook 的本机 | models 须带 migration;migration 须单 head;暂存 `frontend/` 时跑 `vue-tsc` |
| **commit-msg** | `git commit` | 已安装 Hook 的本机 | 提交信息须符合 [COMMIT_CONVENTION](./convention/COMMIT_CONVENTION.md)(commitlint) |
| **pre-push** | `git push` | 已安装 Hook 的本机 | 本次推送含 `frontend/` 变更时跑 `npm run build` |
| **pre-push** | `git push` | 已安装 Hook 的本机 | 本次推送含 migration 变更时校验单 head;含 `frontend/` 变更时跑 `npm run build` |
| **Jenkins CI** | push 触发流水线 | 全员(不装 Hook 也跑) | `npm ci && npm run build`(`scripts/ci_frontend_build.sh`) |
- Hook **不会**随 `git clone` 自动启用,需每人配置 `core.hooksPath=.githooks`。
@@ -74,7 +74,7 @@ chmod +x scripts/install_git_hooks.sh
[hook-install] Installed Git hooks successfully.
[hook-install] pre-commit: models 变更需带 migration;migration 须单 head;frontend 暂存时跑 vue-tsc
[hook-install] commit-msg: 校验提交信息格式(Conventional Commits)
[hook-install] pre-push: 推送含 frontend 变更时跑 npm run build
[hook-install] pre-push: 推送含 migration 变更时校验单 head;推送含 frontend 变更时跑 npm run build
[hook-install] core.hooksPath=.githooks
```
@@ -160,8 +160,9 @@ echo "feat(auth): add SMS login support" | npx commitlint
| 条件 | 行为 |
|------|------|
| 本次 push 的提交 diff 含 `backend/migrations/versions/*.py` | 运行 `scripts/check_migration_heads.py`,Alembic **必须仅 1 个 head** |
| 本次 push 的提交 diff 含 `frontend/` | 运行 `npm run build`(`vue-tsc -b && vite build`) |
| 无 `frontend/` 变更 | 直接通过 |
| 无 migration / `frontend/` 变更 | 直接通过 |
### 5.4 Jenkins CI
@@ -183,7 +184,7 @@ echo "feat(auth): add SMS login support" | npx commitlint
### 7.1 只跳过前端检查
migration 规则在 pre-commit 中仍会执行。
migration 规则在 pre-commit / pre-push 中仍会执行。
**Git Bash:**
@@ -213,7 +214,7 @@ git push --no-verify
| 变量 | 默认值 | 生效条件 |
|------|--------|----------|
| `SKIP_FRONTEND_HOOKS` | 未设置 | 设为 `1` 时跳过前端 vue-tsc / build |
| `SKIP_FRONTEND_HOOKS` | 未设置 | 设为 `1` 时仅跳过前端 vue-tsc / build;若本次 push 含 migration,仍会检查 migration |
| `SKIP_GIT_HOOKS` | 未设置 | 设为 `1` 时跳过前端检查(与上一项在前端逻辑等价) |
仓库内**没有**预置这些变量的配置文件,仅在单次命令前临时设置。
@@ -246,7 +247,7 @@ git push --no-verify
| `package.json` | 根目录 tooling 依赖(commitlint) |
| `scripts/install_git_hooks.sh` | 一键安装 |
| `scripts/ci_frontend_build.sh` | Jenkins / 本地 CI 同款 build |
| `scripts/check_migration_heads.py` | 离线校验 Alembic 仅 1 个 head(pre-commit 调用) |
| `scripts/check_migration_heads.py` | 离线校验 Alembic 仅 1 个 head(pre-commit / pre-push 调用) |
| `Jenkinsfile` | `Frontend Build (CI)` 阶段 |
| `docs/新人环境搭建与配置文档.md` | 新人环境 §4.2 简要说明 |