Caching poetry install for CI


Poetry tip:

When running poetry inside a CI pipeline, set virtualenvs.in-project config to true.

That way the virtual environment will be created inside the current folder -> you can cache it.

Gitlab example👇

stages:
  - test

cache:
  key: virtualenv
  paths:
    - .venv/

tests:
  stage: test
  image: python3.8-slim
  before_script:
    - poetry config virtualenvs.in-project true
    - poetry install
  script:
    - poetry run python -m pytest tests