gpt4 book ai didi

ruby-on-rails - WebPacker CI 缓存所需文件夹

转载 作者:行者123 更新时间:2023-12-03 14:43:52 26 4
gpt4 key购买 nike

给定一个使用 WebPacker 的 Ruby on Rails 项目项目中,哪些文件夹需要缓存在 CI 服务上以确保系统规范以最佳方式执行?我的构建管道当前正在缓存 public/packs-testtmp/cache/webpacker .

在本地测试我看到这种行为:

time rake assets:precompile RAILS_ENV=test # 2.0m
time rake assets:precompile RAILS_ENV=test # 5.0s
rm -rf ./public/packs-test ./tmp/cache/webpacker
time rake assets:precompile RAILS_ENV=test # 2.0m

这是有希望的 - 编译时间最初是 2 分钟,然后是 5 秒。但是,在 CI 上,我始终看到 Assets 编译的运行时间为 2 分钟。这是我在两次运行之间缓存/恢复的文件夹的完整列表:
public/packs-test
tmp/cache/webpacker
tmp/yarn
node_modules

注意:设置 YARN_CACHE_FOLDER ENV 变量为 tmp/yarn并使用 CircleCI。

编辑:

在 CircleCI 配置中使用以下片段进行缓存。
type: cache-restore
keys:
- assets-{{ .Branch }}-{{ .Revision }}
- assets-{{ .Branch }}
- assets

type: cache-save
key: assets-{{ .Branch }}-{{ .Revision }}
paths:
- public/packs-test
- tmp/cache/webpacker
- tmp/yarn
- node_modules

最佳答案

以下步骤对我来说效果很好:

  - restore_cache:
name: Restore webpacker cache
keys:
- v1-webpacker-{{ .Branch }}-
- v1-webpacker-

- restore_cache:
name: Restore compiled packs
key: v1-packs-{{ checksum "tmp/cache/webpacker/last-compilation-digest-test" }}

- save_cache:
name: Store webpacker cache
key: v1-webpacker-{{ .Branch }}-{{ epoch }}
paths:
- tmp/cache/webpacker

- save_cache:
name: Store compiled packs
key: v1-packs-{{ checksum "tmp/cache/webpacker/last-compilation-digest-test" }}
paths:
- public/packs-test

关于ruby-on-rails - WebPacker CI 缓存所需文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50883620/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com