Просмотр исходного кода

fix(B-39): 修复 pom.xml 默认 skipTests=true 假绿缺陷

- cfc-backend/pom.xml:28 <skipTests>true</skipTests> → false:默认 mvn test 不再
  静默跳过全部用例,跳过改由命令行 -DskipTests 显式控制
- .gitlab-ci.yml 新增 backend-surefire-guard 守卫 job:mvn test -DskipTests=false
  后断言 surefire-reports/TEST-*.xml 数量 > 0,否则 exit 1 → job 红(防假绿回归)
- 更新 .gitlab-ci.yml 头部注释:pom:28 关键坑已修复(B-39)

未动业务代码、未加迁移。编译受阻于既有错误 HuaweiAuthService.java:246
(Java8 不认 Java10+ URLEncoder.encode(String,Charset)),该错误在 origin/cfclub
已存在,非本次改动引入。

任务号: B-39
Sisyphus Agent 1 неделя назад
Родитель
Сommit
39cabea9d6
2 измененных файлов с 38 добавлено и 4 удалено
  1. 37 3
      .gitlab-ci.yml
  2. 1 1
      cfc-backend/pom.xml

+ 37 - 3
.gitlab-ci.yml

@@ -12,9 +12,9 @@
 #   - langgraph pytest  : tests/ 11 文件 / 47 方法可拉起(24 pass / 19 fail 为既有 schema 漂移)
 #   - Playwright e2e    : 74 spec 文件 / 2418 用例收集成功;ci-smoke.spec.js headless 冒烟 1 passed
 #
-# 🔴 关键坑(必须保留):cfc-backend/pom.xml 第 28 行 <skipTests>true</skipTests>,
-#    直接 `mvn test` 会**静默跳过全部测试(假绿)**。因此后端 job 必须显式
-#    `-DskipTests=false`,否则 CI 绿灯是假的。
+# ✅ 已修复(B-39):cfc-backend/pom.xml 第 28 行默认 <skipTests>false</skipTests>
+#    (原为 true,直接 `mvn test` 会**静默跳过全部测试 = 假绿**)。后端 job 仍显式
+#    `-DskipTests=false`,并有 backend-surefire-guard 守卫断言 surefire XML > 0。
 #
 # 🔴 启用前置(本机实测,runner 侧待平台核实):
 #    1) runner 需 JDK8 + Maven + node18/20/22 + npm + Python3.11+ + 可拉依赖网络
@@ -151,6 +151,40 @@ backend-contract-junit:
     paths:
       - cfc-backend/target/surefire-reports/
 
+# ---------------------------------------------------------------------------
+# Job 4b — B-39 守卫:后端 surefire 假绿回归防护(P0 流程黑洞)
+# ---------------------------------------------------------------------------
+# 背景:cfc-backend/pom.xml:28 曾默认 <skipTests>true</skipTests>,直接 `mvn test`
+#   会**静默跳过全部用例 = BUILD SUCCESS 假绿(surefire-reports 0 个 XML)**。
+#   本守卫强制证明测试真正执行:`mvn test -DskipTests=false` 后断言
+#   surefire-reports/TEST-*.xml 数量 > 0;若为 0(假绿回归)则 exit 1 → job 红,
+#   防止 pom.xml 默认 skipTests 被改回 true 而无人察觉。
+#   注:`-o`(离线)可选——runner .m2 预热且无外网时可加;`-Dtest` 排除需 DB 的
+#   integration 包(与 backend-contract-junit 一致)。守卫只对"0 个 XML"报红,
+#   既有契约漂移红由 backend-contract-junit 的 allow_failure 兜底,不在此重复报。
+# ---------------------------------------------------------------------------
+backend-surefire-guard:
+  stage: test
+  when: manual                 # 首次手动;确认 runner 能力后改 on_success
+  cache:
+    key: "$CI_COMMIT_REF_SLUG"
+    paths:
+      - .m2/repository
+  script:
+    - cd cfc-backend
+    # B-39 守卫:显式 -DskipTests=false 跑测试(排除需 DB 的 integration 包);
+    # 用 `|| true` 保证无论 mvn 退出码都继续做 XML 断言——守卫只防"假绿(0 XML)"
+    - mvn -B test -DskipTests=false -Dtest='!**/integration/**' || true
+    # 断言:surefire-reports 下必须产出 >=1 个 TEST-*.xml,否则判定假绿回归
+    - count=$(find target/surefire-reports -name 'TEST-*.xml' 2>/dev/null | wc -l)
+    - echo "B-39 守卫:surefire-reports 下 TEST-*.xml 数量 = ${count}"
+    - if [ "${count}" -eq 0 ]; then echo "❌ B-39 守卫失败:0 个 surefire XML(测试被跳过=假绿),pom.xml 默认 skipTests 疑似回归 true"; exit 1; fi
+  artifacts:
+    when: always
+    expire_in: 7 days
+    paths:
+      - cfc-backend/target/surefire-reports/
+
 # ---------------------------------------------------------------------------
 # Job 5 — cfc-langgraph pytest(G1,AI 服务侧)
 # ---------------------------------------------------------------------------

+ 1 - 1
cfc-backend/pom.xml

@@ -25,7 +25,7 @@
         <jwt.version>0.11.5</jwt.version>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
         <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
-        <skipTests>true</skipTests>
+        <skipTests>false</skipTests>
     </properties>
 
     <dependencies>