代码之家  ›  专栏  ›  技术社区  ›  James Chevalier

如何将bundle clean放入CircleCI缓存?

  •  1
  • James Chevalier  · 技术社区  · 6 年前

    CircleCI文档包含了一些关于原因的信息 bundle clean Bundler (Ruby) 在此部分: https://circleci.com/docs/2.0/caching/#bundler-ruby

    - run: bundle install & bundle clean
    - restore_cache:
        keys:
          # when lock file changes, use increasingly general patterns to restore cache
          - v1-gem-cache-{{ arch }}-{{ .Branch }}-{{ checksum "Gemfile.lock" }}
          - v1-gem-cache-{{ arch }}-{{ .Branch }}-
          - v1-gem-cache-{{ arch }}-
    - save_cache:
        paths:
          - ~/.bundle
        key: v1-gem-cache-{{ arch }}-{{ .Branch }}-{{ checksum "Gemfile.lock" }}
    

    我把这个过程解读为:

    • bundle install 之前 缓存被放置到位(在恢复缓存之前需要一个完整的gem安装时间,这抵消了缓存节省时间的好处),然后运行 捆绑清洁
    • 不要这样做 任何东西 (双方 restore_cache save_cache

    我对这个过程的理解正确吗?

    在我看来 还原\u缓存 保存\u缓存 这些步骤不会有效,因为 时间早就过去了。

    如果我能理解的话,这是一个更有效的过程吗?

    - restore_cache:
        keys:
          # when lock file changes, use increasingly general patterns to restore cache
          - v1-gem-cache-{{ arch }}-{{ .Branch }}-{{ checksum "Gemfile.lock" }}
          - v1-gem-cache-{{ arch }}-{{ .Branch }}-
          - v1-gem-cache-{{ arch }}-
    - run: bundle install & bundle clean
    - save_cache:
        paths:
          - ~/.bundle
        key: v1-gem-cache-{{ arch }}-{{ .Branch }}-{{ checksum "Gemfile.lock" }}
    

    如果我没有正确理解这一点,有人能帮助澄清建议的代码块是如何工作的吗?

    更新: 它看起来也像

    - run: bundle install & bundle clean
    

    需要修改为

    - run: bundle install && bundle clean
    
    1 回复  |  直到 6 年前
        1
  •  2
  •   FelicianoTech    6 年前

    我很肯定你是对的,这是一个错误的循环文件。我已经打开了一个PR来修复: https://github.com/circleci/circleci-docs/pull/2663

    推荐文章