如何为 Gitlab CI 缓存 "poetry install"?
How to cache "poetry install" for Gitlab CI?
有没有办法在 Gitlab 中缓存 poetry install
命令 CI (.gitlab-ci.yml
)?
例如,在 node
yarn
中有一种缓存 yarn install
的方法(https://classic.yarnpkg.com/lang/en/docs/install-ci/ Gitlab
部分)这使得阶段更快。
GitLab can only cache things in the working directory and Poetry stores packages elsewhere by default:
Directory where virtual environments will be created. Defaults to {cache-dir}/virtualenvs
({cache-dir}\virtualenvs
on Windows).
在我的机器上,cache-dir
是 /home/chris/.cache/pypoetry
。
您可以使用 the virtualenvs.in-project
option 更改此行为:
If set to true, the virtualenv wil be created and expected in a folder named .venv
within the root directory of the project.
所以,像这样的东西应该适用于你的 gitlab-ci.yml
:
before_script:
- poetry config virtualenvs.in-project true
cache:
paths:
- .venv
有没有办法在 Gitlab 中缓存 poetry install
命令 CI (.gitlab-ci.yml
)?
例如,在 node
yarn
中有一种缓存 yarn install
的方法(https://classic.yarnpkg.com/lang/en/docs/install-ci/ Gitlab
部分)这使得阶段更快。
GitLab can only cache things in the working directory and Poetry stores packages elsewhere by default:
Directory where virtual environments will be created. Defaults to
{cache-dir}/virtualenvs
({cache-dir}\virtualenvs
on Windows).
在我的机器上,cache-dir
是 /home/chris/.cache/pypoetry
。
您可以使用 the virtualenvs.in-project
option 更改此行为:
If set to true, the virtualenv wil be created and expected in a folder named
.venv
within the root directory of the project.
所以,像这样的东西应该适用于你的 gitlab-ci.yml
:
before_script:
- poetry config virtualenvs.in-project true
cache:
paths:
- .venv