Giter Site home page Giter Site logo

Comments (8)

kosinal avatar kosinal commented on June 12, 2024 1

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:

  • With settings in poetry.toml, virtual environment is being created inside project in .venv folder
  • I do cache .venv folder based on hash of my poetry.lock file, which contains current dependencies
  • When my CI job stars, I can see following:
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]

# poetry install
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.

from actions-poetry.

kosinal avatar kosinal commented on June 12, 2024 1

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 :)

from actions-poetry.

abatilo avatar abatilo commented on June 12, 2024 1

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

from actions-poetry.

kosinal avatar kosinal commented on June 12, 2024 1

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.

from actions-poetry.

github-actions avatar github-actions commented on June 12, 2024 1

🎉 This issue has been resolved in version 2.4.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

from actions-poetry.

lucsorel avatar lucsorel commented on June 12, 2024

🙏 thank you very much for your comprehensive explanation 😃

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?]

from actions-poetry.

lucsorel avatar lucsorel commented on June 12, 2024

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?

from actions-poetry.

lucsorel avatar lucsorel commented on June 12, 2024

hi @abatilo

I created this PR: #65. Feel free to comment and amend it 😃

from actions-poetry.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.