Kev*_*tre 6 ruby-on-rails circleci webpacker
给定一个使用WebPacker项目的Ruby on Rails项目,哪些文件夹需要在CI服务上进行缓存以确保系统性能最佳?我的构建管道当前正在缓存public/packs-test和tmp/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
Run Code Online (Sandbox Code Playgroud)
这很有希望-编译时间最初是2分钟,然后是5秒。但是,在CI上,我始终看到2分钟的运行时间来进行资产编译。这是我在两次运行之间缓存/还原的文件夹的完整列表:
public/packs-test
tmp/cache/webpacker
tmp/yarn
node_modules
Run Code Online (Sandbox Code Playgroud)
注意:将YARN_CACHE_FOLDERENV变量设置为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
Run Code Online (Sandbox Code Playgroud)
以下步骤对我来说效果很好:
- 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
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
262 次 |
| 最近记录: |