|
@@ -0,0 +1,101 @@
|
|
|
|
|
+# 远端 CI 编译闸门草案(OPS-CI-GATE 方案 B)
|
|
|
|
|
+
|
|
|
|
|
+> 起草:2026-10-29|配套文档:`docs/2026-10-29-CI编译闸门待办.md`(方案总述)
|
|
|
|
|
+> 状态:**草案** — 需主理人确认 `git.iwintrue.com` 实际 CI 平台(Gitea Actions / GitLab CI / 自定义 webhook)后落地
|
|
|
|
|
+> 约束:编译闸门**仅在 `iwintrue`(远端 CI 环境)与 `local`(开发者本机)执行**
|
|
|
|
|
+
|
|
|
|
|
+## 一、目标
|
|
|
|
|
+
|
|
|
|
|
+在代码进入 `cfclub`(及主要长期分支)前,由远端 CI 强制跑 `mvn compile`(可选 + 单测),**红灯禁止合并 / 禁止 fast-forward**。与本地 `githooks/pre-push`(方案 A)形成双保险:本机漏装的,远端兜底拦。
|
|
|
|
|
+
|
|
|
|
|
+## 二、触发条件
|
|
|
|
|
+
|
|
|
|
|
+- 触发事件:`push` 到 `cfclub` / `main` / `master` / `release/*`,以及指向这些分支的 PR/MR。
|
|
|
|
|
+- 仅当提交涉及 `cfc-backend/` 时编译后端;前端(`cfc-frontend` / `cfc-web`)另行加构建步骤。
|
|
|
|
|
+- 跳过机制:提交信息含 `[skip ci]` 时跳过(已有 auto-bump 提交在用,需保留此豁免以免自 bump 触发死循环)。
|
|
|
|
|
+
|
|
|
|
|
+## 三、环境
|
|
|
|
|
+
|
|
|
|
|
+- JDK:Temurin 21(与本地开发一致,`JAVA_HOME` 指向 temurin21)。
|
|
|
|
|
+- 构建:Maven 3.9.x(`mvn -q -DskipTests compile`;单测步可单独开)。
|
|
|
|
|
+- 仅运行于 iwintrue runner(不调度到其他环境),符合"仅 iwintrue/local 编译"约束。
|
|
|
|
|
+
|
|
|
|
|
+## 四、配置示例
|
|
|
|
|
+
|
|
|
|
|
+### 4.1 若为 Gitea Actions(自托管 Gitea 常见)
|
|
|
|
|
+
|
|
|
|
|
+文件路径:`.gitea/workflows/ci-compile.yml`
|
|
|
|
|
+
|
|
|
|
|
+```yaml
|
|
|
|
|
+name: ci-compile
|
|
|
|
|
+on:
|
|
|
|
|
+ push:
|
|
|
|
|
+ branches: [cfclub, main, master]
|
|
|
|
|
+ paths:
|
|
|
|
|
+ - 'cfc-backend/**'
|
|
|
|
|
+ - '.gitea/workflows/**'
|
|
|
|
|
+ pull_request:
|
|
|
|
|
+ branches: [cfclub, main, master]
|
|
|
|
|
+ paths:
|
|
|
|
|
+ - 'cfc-backend/**'
|
|
|
|
|
+jobs:
|
|
|
|
|
+ compile:
|
|
|
|
|
+ if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }}
|
|
|
|
|
+ runs-on: [iwintrue]
|
|
|
|
|
+ steps:
|
|
|
|
|
+ - uses: actions/checkout@v4
|
|
|
|
|
+ - name: Set up JDK 21
|
|
|
|
|
+ uses: actions/setup-java@v4
|
|
|
|
|
+ with:
|
|
|
|
|
+ distribution: temurin
|
|
|
|
|
+ java-version: '21'
|
|
|
|
|
+ cache: maven
|
|
|
|
|
+ - name: Compile cfc-backend
|
|
|
|
|
+ working-directory: cfc-backend
|
|
|
|
|
+ run: mvn -B -q -DskipTests compile
|
|
|
|
|
+```
|
|
|
|
|
+
|
|
|
|
|
+### 4.2 若为 GitLab CI
|
|
|
|
|
+
|
|
|
|
|
+文件路径:`.gitlab-ci.yml`(仅保留 compile 阶段,runner tag 限定 `iwintrue`)
|
|
|
|
|
+
|
|
|
|
|
+```yaml
|
|
|
|
|
+stages:
|
|
|
|
|
+ - build
|
|
|
|
|
+
|
|
|
|
|
+cfc-backend-compile:
|
|
|
|
|
+ stage: build
|
|
|
|
|
+ tags:
|
|
|
|
|
+ - iwintrue
|
|
|
|
|
+ rules:
|
|
|
|
|
+ - if: '$CI_COMMIT_BRANCH =~ /^(cfclub|main|master)$/ && $CI_COMMIT_MESSAGE !~ /\[skip ci\]/'
|
|
|
|
|
+ changes:
|
|
|
|
|
+ - cfc-backend/**/*
|
|
|
|
|
+ image: eclipse-temurin:21-jdk
|
|
|
|
|
+ script:
|
|
|
|
|
+ - cd cfc-backend
|
|
|
|
|
+ - mvn -B -q -DskipTests compile
|
|
|
|
|
+```
|
|
|
|
|
+
|
|
|
|
|
+### 4.3 若为自定义 webhook(通用)
|
|
|
|
|
+
|
|
|
|
|
+- 在 `git.iwintrue.com` 的 push webhook 中指向 iwintrue 上的 CI 接收服务;
|
|
|
|
|
+- 服务 `git clone` 目标分支、`cd cfc-backend && mvn -DskipTests compile`;
|
|
|
|
|
+- 非零退出 → 调用 Git 平台 API 标记 commit status 为 `failure`,并阻止受保护分支的 merge(配合方案 C 分支保护)。
|
|
|
|
|
+
|
|
|
|
|
+## 五、与方案 C 的衔接
|
|
|
|
|
+
|
|
|
|
|
+- `cfclub` 设为受保护分支:仅允许经绿灯(A 本机 hook 或 B 远端 CI)的合并进入;禁止直接 push 红构建。
|
|
|
|
|
+- 远端 CI 红灯 → 标记失败 → 受保护分支拒绝 fast-forward / merge。
|
|
|
|
|
+
|
|
|
|
|
+## 六、验收
|
|
|
|
|
+
|
|
|
|
|
+1. 人为制造一处 `cfc-backend` 编译错误 → push 到 `cfclub` → 远端 CI 红灯、merge 被拒。
|
|
|
|
|
+2. 修复后重推 → 绿灯、可合入。
|
|
|
|
|
+3. 含 `[skip ci]` 的提交不被 CI 拦截(避免 auto-bump 死循环)。
|
|
|
|
|
+
|
|
|
|
|
+## 七、待主理人确认
|
|
|
|
|
+
|
|
|
|
|
+- [ ] `git.iwintrue.com` 实际 CI 平台(决定用 4.1 / 4.2 / 4.3)。
|
|
|
|
|
+- [ ] iwintrue runner 是否已装 Temurin 21 + Maven 3.9.x。
|
|
|
|
|
+- [ ] 是否同步对前端(`cfc-frontend` / `cfc-web`)加构建闸门(当前仅后端)。
|