perf(ci): 修复Frontend Lint的npm缓存假命中问题 #341

Merged
xiaoxia merged 2 commits from feat/frontend-cache-fix into develop 2026-07-15 09:04:03 +08:00
Owner

问题

Frontend Lint Job每次执行 rm -rf node_modules/* 然后 npm ci,Docker volume缓存完全失效,缓存等于摆设。

优化方案

基于 package-lock.json 的 md5 hash 判断依赖是否变更:

  • hash不变 → 跳过npm ci(缓存命中)
  • hash变化 → 执行npm ci并更新hash(缓存失效)

预期收益

  • 依赖不变时,Lint Job从~4min → ~1min(省60%+)
  • 依赖变更时,耗时不变(正常npm ci)

验证方式

合并后连续观察3-5次PR的Frontend Lint耗时,对比优化前数据。

## 问题 Frontend Lint Job每次执行 `rm -rf node_modules/*` 然后 `npm ci`,Docker volume缓存完全失效,缓存等于摆设。 ## 优化方案 基于 package-lock.json 的 md5 hash 判断依赖是否变更: - hash不变 → 跳过npm ci(缓存命中) - hash变化 → 执行npm ci并更新hash(缓存失效) ## 预期收益 - 依赖不变时,Lint Job从~4min → ~1min(省60%+) - 依赖变更时,耗时不变(正常npm ci) ## 验证方式 合并后连续观察3-5次PR的Frontend Lint耗时,对比优化前数据。
xiaoxia added 1 commit 2026-07-15 08:03:27 +08:00
- 移除每次rm -rf node_modules的操作
- 基于package-lock.json hash判断是否需要重装依赖
- 依赖不变时跳过npm ci,预计节省50%+Lint耗时
xiaoxia added 1 commit 2026-07-15 08:47:06 +08:00
fix(ci): 修复YAML语法错误,npm缓存逻辑需在同一行双引号字符串内
CI/CD Pipeline / Frontend Lint (pull_request) Successful in 1m1s
CI/CD Pipeline / Validate Code Quality And Tests (pull_request) Successful in 1m27s
CI/CD Pipeline / Build Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Web Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Production (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 / Production Browser E2E (pull_request) Has been skipped
CI/CD Pipeline / Unit Tests (pull_request) Successful in 1m33s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 1m5s
e2c6d77965
auto-approve-bot approved these changes 2026-07-15 09:02:01 +08:00
auto-approve-bot left a comment
Collaborator

CI全绿,自动审批通过。

CI全绿,自动审批通过。
xiaoxia merged commit e705cbdd8a into develop 2026-07-15 09:04:03 +08:00
xiaoxia deleted branch feat/frontend-cache-fix 2026-07-15 09:04:04 +08:00
Sign in to join this conversation.