.gitlab-ci.yml 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. # =============================================================================
  2. # 浠艾福 (XAF) — 最小 CI 管线(GitLab CI,仓库根,自动加载)
  3. # -----------------------------------------------------------------------------
  4. # 落地:2026-11-06(最小 CI 管线搭建)
  5. # 前置:remote = http://git.iwintrue.com/liaoxg/cfc(GitLab 系自托管)
  6. # 命令均已在本机实测通过(2026-11-06 16:2x):
  7. # - 后端 G0 编译 : mvn test-compile -DskipTests=false → BUILD SUCCESS (2046+231 源)
  8. # - 前端 jest : cfc-frontend 14 suites / 296 例全绿
  9. # - 管理端 jest : cfc-web 12 suites / 90 例全绿
  10. #
  11. # 🔴 关键坑(必须保留):cfc-backend/pom.xml 第 28 行 <skipTests>true</skipTests>,
  12. # 直接 `mvn test` 会**静默跳过全部测试(假绿)**。因此后端 job 必须显式
  13. # `-DskipTests=false`,否则 CI 绿灯是假的。
  14. #
  15. # 🔴 启用前置(本机实测,runner 侧待平台核实):
  16. # 1) runner 需 JDK8 + Maven + node22/npm + 可拉依赖网络(本机已备 JDK8/Maven3.9.9/node22)
  17. # 2) 本文件默认 when: manual(首次先手动触发跑通);确认 runner 能力后
  18. # 将三处 `when: manual` 改为 `when: on_success`(或删除该行走默认自动)
  19. # 3) 若 runner .m2 已预热且无外网,可在 mvn 命令加 `-o`(离线)
  20. # -----------------------------------------------------------------------------
  21. # 设计说明(最小闭环,绿灯基准):
  22. # - 后端采用 G0 编译门禁(必绿,最快信号);契约复验(159 例/轮)仍由本地
  23. # 轮次承担——因 P-2 MapContract 3 红为已知未拍板项,纳入会让 CI 必红,
  24. # 待口径拍板后再并入 backend job(见 docs/tdd/ci/CI_READINESS_2026-11-05.md)
  25. # - 前端/管理端用 jest --ci(已验证全绿,无外部依赖)
  26. # =============================================================================
  27. stages:
  28. - build
  29. - test
  30. variables:
  31. MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository"
  32. cache:
  33. key: "$CI_COMMIT_REF_SLUG"
  34. paths:
  35. - .m2/repository
  36. - cfc-frontend/node_modules/
  37. - cfc-web/node_modules/
  38. # ---------------------------------------------------------------------------
  39. # Job 1 — 后端 G0 编译门禁
  40. # ---------------------------------------------------------------------------
  41. backend-g0-compile:
  42. stage: build
  43. when: manual # 首次手动;确认 runner 能力后改 on_success
  44. cache:
  45. key: "$CI_COMMIT_REF_SLUG"
  46. paths:
  47. - .m2/repository
  48. script:
  49. - cd cfc-backend
  50. # 必须 -DskipTests=false 覆盖 pom 默认假绿(pom.xml:28)
  51. - mvn test-compile -DskipTests=false
  52. artifacts:
  53. when: always
  54. expire_in: 7 days
  55. paths:
  56. - cfc-backend/target/classes/
  57. # 注:契约/单测复验(G1)暂由本地轮次承担(P-2 3 红未拍板,见 CI_READINESS)
  58. # ---------------------------------------------------------------------------
  59. # Job 2 — 小程序前端(cfc-frontend)jest 单测
  60. # ---------------------------------------------------------------------------
  61. frontend-jest:
  62. stage: test
  63. when: manual # 首次手动;确认 runner 能力后改 on_success
  64. cache:
  65. key: "$CI_COMMIT_REF_SLUG"
  66. paths:
  67. - cfc-frontend/node_modules/
  68. script:
  69. - cd cfc-frontend
  70. - npm ci || npm install
  71. - npx jest --ci
  72. artifacts:
  73. when: always
  74. expire_in: 7 days
  75. reports:
  76. junit:
  77. - cfc-frontend/junit.xml
  78. paths:
  79. - cfc-frontend/coverage/
  80. # ---------------------------------------------------------------------------
  81. # Job 3 — 管理端(cfc-web)jest 单测
  82. # ---------------------------------------------------------------------------
  83. web-jest:
  84. stage: test
  85. when: manual # 首次手动;确认 runner 能力后改 on_success
  86. cache:
  87. key: "$CI_COMMIT_REF_SLUG"
  88. paths:
  89. - cfc-web/node_modules/
  90. script:
  91. - cd cfc-web
  92. - npm ci || npm install
  93. - npx jest --ci
  94. artifacts:
  95. when: always
  96. expire_in: 7 days
  97. reports:
  98. junit:
  99. - cfc-web/junit.xml
  100. paths:
  101. - cfc-web/coverage/