feat(ci): M-3 三镜像matrix并行构建重构 - 代码量减21% #365

Closed
xiaoxia wants to merge 3 commits from ci/matrix-build-parallelism into develop
Owner

背景

6个独立构建job(3 staging + 3 production)结构高度相似,维护成本高,且用户误以为当前是串行构建。

改动

将6个独立构建job重构为2个matrix job:

  • build-staging:matrix 3服务(api/worker/web)
  • build-production:matrix 3服务(api/worker/web)

具体变更

  1. 代码量减少249行(21%):1186行 → 937行
  2. 构建逻辑统一:三服务共用同一套构建步骤,避免维护不同步
  3. 服务差异通过matrix变量控制
    • service_display:显示名(API/Worker/Web)
    • dockerfile:Dockerfile路径
    • image_name:镜像名
    • cache_name:缓存名
    • timeout:超时时间(worker 40min,其他30min)
  4. 条件步骤
    • npm build:仅web服务执行(if: matrix.service == 'web'
    • Cleanup old images:仅production web执行
  5. fail-fast: false:单个服务构建失败不影响其他服务
  6. deploy needs同步更新:从3个build job → 1个matrix job

性能说明

⚠️ 性能无变化:当前三个构建已经是并行启动的(由Gitea Actions调度器自动并行),matrix重构主要是代码精简和维护性提升,不会进一步提速。总耗时仍由最慢的API构建决定。

验证

  • Staging三门禁全绿
  • 三个Staging镜像构建成功
  • Deploy Staging成功
  • Production构建(tag触发)语法正确
## 背景 6个独立构建job(3 staging + 3 production)结构高度相似,维护成本高,且用户误以为当前是串行构建。 ## 改动 将6个独立构建job重构为2个matrix job: - `build-staging`:matrix 3服务(api/worker/web) - `build-production`:matrix 3服务(api/worker/web) ### 具体变更 1. **代码量减少249行(21%)**:1186行 → 937行 2. **构建逻辑统一**:三服务共用同一套构建步骤,避免维护不同步 3. **服务差异通过matrix变量控制**: - `service_display`:显示名(API/Worker/Web) - `dockerfile`:Dockerfile路径 - `image_name`:镜像名 - `cache_name`:缓存名 - `timeout`:超时时间(worker 40min,其他30min) 4. **条件步骤**: - npm build:仅web服务执行(`if: matrix.service == 'web'`) - Cleanup old images:仅production web执行 5. **fail-fast: false**:单个服务构建失败不影响其他服务 6. **deploy needs同步更新**:从3个build job → 1个matrix job ### 性能说明 ⚠️ **性能无变化**:当前三个构建已经是并行启动的(由Gitea Actions调度器自动并行),matrix重构主要是代码精简和维护性提升,不会进一步提速。总耗时仍由最慢的API构建决定。 ## 验证 - [ ] Staging三门禁全绿 - [ ] 三个Staging镜像构建成功 - [ ] Deploy Staging成功 - [ ] Production构建(tag触发)语法正确
xiaoxia added 1 commit 2026-07-15 13:32:28 +08:00
xiaoxia added 1 commit 2026-07-15 13:51:51 +08:00
fix(ci): 修复matrix重构中重复的if条件导致YAML解析失败
CI/CD Pipeline / Frontend Lint (push) Successful in 54s
CI/CD Pipeline / Build Production API Image (push) Has been skipped
CI/CD Pipeline / Build Production Web Image (push) Has been skipped
CI/CD Pipeline / Build Production Worker Image (push) Has been skipped
CI/CD Pipeline / Deploy Production (push) Has been skipped
CI/CD Pipeline / Production Browser E2E (push) Has been skipped
CI/CD Pipeline / Frontend Lint (pull_request) Successful in 39s
CI/CD Pipeline / Build Production API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Production (pull_request) Has been skipped
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
CI/CD Pipeline / Validate Code Quality And Tests (pull_request) Failing after 2m2s
CI/CD Pipeline / Build Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Validate Code Quality And Tests (push) Failing after 2m5s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI/CD Pipeline / Build Staging API Image (push) Has been skipped
CI/CD Pipeline / Build Staging Web Image (push) Has been skipped
CI/CD Pipeline / Build Staging Worker Image (push) Has been skipped
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (push) Has been skipped
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / Staging E2E Tests (push) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (push) Has been skipped
CI/CD Pipeline / Unit Tests (push) Successful in 2m18s
CI/CD Pipeline / Unit Tests (pull_request) Successful in 2m3s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 1m30s
CI/CD Pipeline / Integration Tests (push) Successful in 1m25s
d7b7c0b235
xiaoxia added 1 commit 2026-07-15 14:08:17 +08:00
Merge remote-tracking branch 'origin/develop' into ci/matrix-build-parallelism
CI/CD Pipeline / Frontend Lint (push) Successful in 35s
CI/CD Pipeline / Build Production API Image (push) Has been skipped
CI/CD Pipeline / Build Production Web Image (push) Has been skipped
CI/CD Pipeline / Build Production Worker Image (push) Has been skipped
CI/CD Pipeline / Deploy Production (push) Has been skipped
CI/CD Pipeline / Production Browser E2E (push) Has been skipped
CI/CD Pipeline / Frontend Lint (pull_request) Successful in 37s
CI/CD Pipeline / Build Production API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Production (pull_request) Has been skipped
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
CI/CD Pipeline / Validate Code Quality And Tests (push) Successful in 1m56s
CI/CD Pipeline / Build Staging API Image (push) Has been skipped
CI/CD Pipeline / Build Staging Web Image (push) Has been skipped
CI/CD Pipeline / Build Staging Worker Image (push) Has been skipped
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (push) Has been skipped
CI/CD Pipeline / Staging E2E Tests (push) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (push) Has been skipped
CI/CD Pipeline / Unit Tests (push) Successful in 2m2s
CI/CD Pipeline / Validate Code Quality And Tests (pull_request) Successful in 1m40s
CI/CD Pipeline / Build Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / Unit Tests (pull_request) Successful in 1m54s
CI/CD Pipeline / Integration Tests (push) Successful in 1m26s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 1m21s
ea32481e66
auto-approve-bot approved these changes 2026-07-15 14:23:27 +08:00
auto-approve-bot left a comment
Collaborator

CI全绿,自动审批通过。

CI全绿,自动审批通过。
xiaoxia closed this pull request 2026-07-15 22:59:38 +08:00
Some checks are pending
CI/CD Pipeline / Frontend Lint (push) Successful in 35s
CI/CD Pipeline / Build Production API Image (push) Has been skipped
CI/CD Pipeline / Build Production Web Image (push) Has been skipped
CI/CD Pipeline / Build Production Worker Image (push) Has been skipped
CI/CD Pipeline / Deploy Production (push) Has been skipped
CI/CD Pipeline / Production Browser E2E (push) Has been skipped
CI/CD Pipeline / Frontend Lint (pull_request) Successful in 37s
CI/CD Pipeline / Build Production API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Production (pull_request) Has been skipped
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
CI/CD Pipeline / Validate Code Quality And Tests (push) Successful in 1m56s
CI/CD Pipeline / Build Staging API Image (push) Has been skipped
CI/CD Pipeline / Build Staging Web Image (push) Has been skipped
CI/CD Pipeline / Build Staging Worker Image (push) Has been skipped
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (push) Has been skipped
CI/CD Pipeline / Staging E2E Tests (push) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (push) Has been skipped
CI/CD Pipeline / Unit Tests (push) Successful in 2m2s
CI/CD Pipeline / Validate Code Quality And Tests (pull_request) Successful in 1m40s
CI/CD Pipeline / Build Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / Unit Tests (pull_request) Successful in 1m54s
CI/CD Pipeline / Integration Tests (push) Successful in 1m26s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 1m21s

Pull request closed

Sign in to join this conversation.