Is there a way to cache poetry install command in Gitlab CI (.gitlab-ci.yml)?
For example, in node yarn there is a way to cache yarn install (https://classic.yarnpkg.com/lang/en/docs/install-ci/ Gitlab section) this makes stages a lot faster.
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}\virtualenvson Windows).
On my machine, cache-dir is /home/chris/.cache/pypoetry.
You can use the virtualenvs.in-project option to change this behaviour:
If set to true, the virtualenv wil be created and expected in a folder named
.venvwithin the root directory of the project.
So, something like this should work in your gitlab-ci.yml:
before_script:
- poetry config virtualenvs.in-project true
cache:
paths:
- .venv
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With