Áng*_*gel 13 python continuous-integration gitlab python-poetry
有没有办法poetry install在 Gitlab CI 中缓存命令(.gitlab-ci.yml)?
例如,node yarn有一种缓存方法yarn install(https://classic.yarnpkg.com/lang/en/docs/install-ci/ Gitlab部分),这使得阶段更快。
Chr*_*ris 20
GitLab 只能缓存工作目录中的内容,而 Poetry默认将包存储在其他地方:
将在其中创建虚拟环境的目录。默认为
{cache-dir}/virtualenvs({cache-dir}\virtualenvs在 Windows 上)。
在我的机器上,cache-dir是/home/chris/.cache/pypoetry.
您可以使用该virtualenvs.in-project选项来更改此行为:
.venv如果设置为 true,则将在项目根目录中指定的文件夹中创建 virtualenv 并预期该文件夹中。
所以,像这样的东西应该在你的gitlab-ci.yml:
before_script:
- poetry config virtualenvs.in-project true
cache:
paths:
- .venv
Run Code Online (Sandbox Code Playgroud)