← 返回
未分类

Ci Build Cache Advisor

Optimize CI/CD build caching across GitHub Actions, GitLab CI, CircleCI, and Jenkins — analyze cache hit rates, recommend cache keys, and reduce build times.
优化跨 GitHub Actions、GitLab CI、CircleCI 和 Jenkins 的 CI/CD 构建缓存——分析缓存命中率、推荐缓存键并缩短构建时间。
charlie-morrison charlie-morrison 来源
未分类 clawhub v1.0.0 1 版本 100000 Key: 无需
★ 0
Stars
📥 279
下载
💾 1
安装
1
版本
#latest

概述

CI Build Cache Advisor

Optimize CI/CD build caching strategies across GitHub Actions, GitLab CI, CircleCI, and Jenkins. Analyze cache configurations, recommend cache keys, identify cache misses, and reduce build times by maximizing cache hit rates.

Usage

"Optimize caching in my CI pipeline"
"Why are my builds not using cache?"
"Design cache keys for my monorepo CI"
"Reduce my CI build time"

How It Works

1. CI Platform Detection

ls .github/workflows/ 2>/dev/null && echo "GitHub Actions"
ls .gitlab-ci.yml 2>/dev/null && echo "GitLab CI"
ls .circleci/config.yml 2>/dev/null && echo "CircleCI"
ls Jenkinsfile 2>/dev/null && echo "Jenkins"

2. Cache Analysis

What should be cached:

  • Package manager dependencies (node_modules, .pip, .cargo, .gradle)
  • Build artifacts (compiled code, generated assets)
  • Docker layers
  • Test fixtures and snapshots
  • Linter and type checker caches

Cache key strategy:

  • Primary key: hash of lockfile (package-lock.json, Cargo.lock)
  • Restore key: platform + branch fallback
  • Matrix-aware: different caches per OS/Node version/Python version
  • Monorepo: workspace-specific caches

3. Common Issues

  • Cache too broad: Single cache for entire node_modules invalidated by any dep change
  • Cache too narrow: Cache key includes commit SHA (never hits)
  • Missing restore keys: No fallback when primary key misses
  • Cache pollution: Dev dependencies cached for production builds
  • Stale cache: Cache never expires, using outdated artifacts
  • Cache size limit: Exceeding platform limits (GitHub: 10GB, GitLab: varies)

4. Recommendations by Platform

GitHub Actions:

- uses: actions/cache@v4
  with:
    path: ~/.npm
    key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
    restore-keys: |
      ${{ runner.os }}-npm-

GitLab CI:

cache:
  key:
    files: [package-lock.json]
    prefix: $CI_JOB_NAME
  paths: [node_modules/]
  policy: pull-push

5. Advanced Strategies

  • Turbo/Nx remote caching: Share build cache across CI and developers
  • Docker layer caching: BuildKit cache mounts, registry-backed cache
  • Gradle build cache: Remote cache server for team-wide sharing
  • ccache/sccache: C/C++/Rust compilation caching

Output

## CI Cache Optimization

**Platform:** GitHub Actions | **Workflows:** 3

### Current Cache Usage
| Workflow | Cache Configured | Hit Rate | Build Time |
|----------|-----------------|----------|------------|
| CI | Yes (npm) | 67% | 8m 30s |
| Deploy | No | 0% | 12m 15s |
| Release | Partial | 45% | 15m |

### Recommendations
1. **Add npm cache to Deploy workflow** — saves ~3 min/run
2. **Fix CI cache key** — includes branch name (low hit rate on PRs)
   → Remove branch, use lockfile hash only
3. **Add Docker layer caching to Release** — saves ~5 min
4. **Add TypeScript build cache** — `tsBuildInfoFile` not cached

### Projected Improvement
- CI: 8m 30s → 3m 45s (56% faster)
- Deploy: 12m 15s → 7m (43% faster)
- Release: 15m → 8m (47% faster)
- Monthly minutes saved: ~2,400 (~$19)

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-05-08 03:31 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

it-ops-security

MoltGuard - Security & Antivirus & Guardrails

thomaslwang
MoltGuard — OpenClaw 安全守卫,由 OpenGuardrails 提供。安装 MoltGuard,保护您和您的用户免受提示注入、数据泄露和恶意攻击。
★ 116 📥 30,911
ai-agent

Slack Messaging

charlie-morrison
Slack 消息—通过 CLI 和 API 发送消息、管理频道、上传文件、添加反应并自动化团队通知。
★ 0 📥 518
it-ops-security

1password

steipete
设置和使用 1Password CLI (op)。适用于:安装 CLI、启用桌面应用集成、登录(单/多账户)、通过 op 读取/注入/运行密钥。
★ 53 📥 31,629