Continuous integration 如何在CircleCI上缓存长生不老药/凤凰?
目前,我的Continuous integration 如何在CircleCI上缓存长生不老药/凤凰?,continuous-integration,elixir,phoenix-framework,circleci,circleci-2.0,Continuous Integration,Elixir,Phoenix Framework,Circleci,Circleci 2.0,目前,我的CircleCI 2.0Elixir项目的缓存策略如下: - restore_cache: keys: - v1-mix-cache-{{ .Branch }}-{{ checksum "mix.lock" }} - v1-mix-cache-{{ .Branch }} - v1-mix-cache - v1-build-cache-{{ .Branch }} - v1-build-cach
CircleCI 2.0
Elixir项目的缓存策略如下:
- restore_cache:
keys:
- v1-mix-cache-{{ .Branch }}-{{ checksum "mix.lock" }}
- v1-mix-cache-{{ .Branch }}
- v1-mix-cache
- v1-build-cache-{{ .Branch }}
- v1-build-cache
- save_cache:
key: v1-mix-cache-{{ .Branch }}-{{ checksum "mix.lock" }}
paths: deps
- save_cache:
key: v1-mix-cache-{{ .Branch }}
paths: deps
- save_cache:
key: v1-mix-cache
paths: deps
- save_cache:
key: v1-build-cache-{{ .Branch }}
paths: _build
- save_cache:
key: v1-build-cache
paths: _build
但是,它有时会导致如下错误:
===> Compiling certifi
=ERROR REPORT==== 12-Jul-2018::15:37:40 ===
Loading of /home/circleci/project/_build/test/lib/parse_trans/ebin/parse_trans.beam failed: badfile
=ERROR REPORT==== 12-Jul-2018::15:37:40 ===
beam/beam_load.c(1863): Error loading module parse_trans:
This BEAM file was compiled for a later version of the run-time system than 20.
To fix this, please recompile this module with an 20 compiler.
(Use of opcode 162; this emulator supports only up to 159.)
===> Compiling src/certifi.erl failed
有时我们会:
** (UndefinedFunctionError) function :hackney.request/5 is undefined (module :hackney is not available)
/home/circleci/project/_build/test/lib/hackney/ebin/hackney.beam failed: :badfile
12:44:02.665 [error] beam/beam_load.c(1863): Error loading module hackney:
This BEAM file was compiled for a later version of the run-time system than 20.
To fix this, please recompile this module with an 20 compiler.
(Use of opcode 162; this emulator supports only up to 159.)
当然,一切都是缓存的问题,因为当我们在没有缓存的情况下重新运行构建时,一切都按预期工作
这种情况并非每次都会发生,但有时会出现不同的错误
您是否有任何可靠的缓存策略用于Elixir
项目?免责声明:我是CircleCI开发者的拥护者
我在这里看到一个问题和一个潜在问题
首先,您不希望为部分密钥多次保存缓存。通过部分匹配恢复缓存密钥。保存缓存时,只需使用一次完整的密钥名即可。恢复缓存将在需要时进行军事匹配
第二,Elixir是否支持部分缓存?我自己不使用它,所以我还不太了解它。如果没有,您可能只希望恢复完整缓存密钥,而不希望恢复任何部分密钥
关于我的第一点:
- restore_cache:
keys:
- v1-mix-cache-{{ .Branch }}-{{ checksum "mix.lock" }}
- v1-mix-cache-{{ .Branch }}
- v1-mix-cache
- v1-build-cache-{{ .Branch }}
- v1-build-cache
- save_cache:
key: v1-mix-cache-{{ .Branch }}-{{ checksum "mix.lock" }}
paths: deps
- save_cache:
key: v1-build-cache-{{ .Branch }}
paths: _build
关于我的第二点:
- restore_cache:
keys:
- v1-mix-cache-{{ .Branch }}-{{ checksum "mix.lock" }}
- v1-build-cache-{{ .Branch }}
- save_cache:
key: v1-mix-cache-{{ .Branch }}-{{ checksum "mix.lock" }}
paths: deps
- save_cache:
key: v1-build-cache-{{ .Branch }}
paths: _build
解决办法是:
- restore_cache:
keys:
- v{{ .Environment.CACHE_VERSION }}-mix-cache-{{ .Branch }}-{{ checksum "mix.lock" }}
- restore_cache:
keys:
- v{{ .Environment.CACHE_VERSION }}-build-cache-{{ .Branch }}
- save_cache:
key: v{{ .Environment.CACHE_VERSION }}-mix-cache-{{ .Branch }}-{{ checksum "mix.lock" }}
paths: deps
- save_cache:
key: v{{ .Environment.CACHE_VERSION }}-build-cache-{{ .Branch }}
paths: _build
我遇到的问题仍然是:
10:08:04.821[error]加载/home/circleci/project/\u-build/test/lib/hackney/ebin/hackney.beam失败::badfile 10:08:04.822[error]beam/beam\u-load.c(1863):错误加载模块hackney:此beam文件是为运行时系统的20以上版本编译的。要修复此问题,请使用20编译器重新编译此模块。(使用操作码162;此仿真器最多支持159。)
@kamilelonek您的缓存似乎包含使用不同版本的Erlang/OTP的生成。尝试通过碰撞密钥的版本号来破坏缓存。