Closed lucsorel closed 1 year ago
I use caching in my project with following setting:
In definition of the github action job:
- uses: actions/cache@v3
name: Cache .venv
with:
path: ./.venv
key: venv-${{ hashFiles('poetry.lock') }}
Add poetry.toml file in root of project with following settings:
[virtualenvs]
create = true
in-project = true
How does it work:
Run actions/cache@v3
with:
path: ./.venv
key: venv-1cdf[2]
enableCrossOsArchive: false
fail-on-cache-miss: false
lookup-only: false
Received 855004 (100.0%), 144.3 MBs/sec Cache Size: ~82 MB (85500470 B) /usr/bin/tar -xf /home/runner/work/_temp/8cca7c6a-f27b-448d-8c10-5f718fafd2ed/cache.tzst -P -C Cache restored successfully Cache restored from key: venv-1cdf2[9]
Installing dependencies from lock file
No dependencies to install or update
Using this, when dependencies do not change in build, I do not have to download and install it again, but I can skip this step and do testing.
:pray: thank you very much for your comprehensive explanation :smiley:
Just to make sure I got it right, can you confirm that the steps would be in the following order, please?
name: Python package
# ...
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Python
uses: actions/setup-python@v4
with:
python-version-file: '.python-version'
- name: Install poetry
uses: abatilo/actions-poetry@v2
with:
poetry-version: 1.5.1
- uses: actions/cache@v3
name: Cache .venv
with:
path: ./.venv
key: venv-${{ hashFiles('poetry.lock') }}
- name: Install project dependencies
run: poetry install
- name: Run automated tests
run: poetry run pytest -v
Is that ok? [edit: it seems to work as expected like this - @kosinal I would like to write a pull-request which would add a section in the README file explaining the process of caching the virtual environment: what do you think? Would that be of interest to you?]
[edit2: hi @abatilo; would you be interested in a pull-request adding a section in the README file to document how to combine actions-poetry with actions/cache for faster poetry install
calls?]
I am neither owner nor contributer to this repo.
It is more up to @abatilo what should or should not be in his project readme :)
I am neither owner nor contributer to this repo.
It is more up to abatilo what should or should not be in his project readme :)
Forgive me for the confusion :+1:
Beside that, does the workflow proposed in https://github.com/abatilo/actions-poetry/issues/64#issuecomment-1621917036 seem ok to you?
Sorry for the delay here. I was traveling for work.
I think it makes sense that the original workflow steps would fail. You are trying to reference the poetry cash in this step that installs Python but poetry hasn't actually been installed yet. So there's a chicken and egg problem.
Installing Python and then installing poetry and then doing the cache steps make sense to me.
I would definitely be open to a pull request that adds the guidance to the readme.
Thank you both
I am neither owner nor contributer to this repo. It is more up to abatilo what should or should not be in his project readme :)
Forgive me for the confusion 👍
Beside that, does the workflow proposed in #64 (comment) seem ok to you?
It looks good.
hi @abatilo
I created this PR: https://github.com/abatilo/actions-poetry/pull/65. Feel free to comment and amend it :smiley:
:tada: This issue has been resolved in version 2.4.0 :tada:
The release is available on GitHub release
Your semantic-release bot :package::rocket:
thank you @abatilo for this github action :pray:
Before using your action, I:
I tried using the actions-poetry action like this:
The
cache 'poetry'
line in the actions/setup-python@v4 action causes the job to fail:Can you please tell me (and add in the README file) how one should set up a cache for poetry to speed up the download of dependencies? :pray: