snok / install-poetry

Github action for installing and configuring Poetry
MIT License
582 stars 53 forks source link

Test Example for GA not working #161

Open reddytocode opened 5 days ago

reddytocode commented 5 days ago

I tried the Testing example in the Readme, but I get: Cache is not found.

My action

name: test
on: pull_request
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - name: Check out repository
        uses: actions/checkout@v4
      - name: Set up python
        id: setup-python
        uses: actions/setup-python@v5
        with:
          python-version: '3.12'
      - name: Install Poetry
        uses: snok/install-poetry@v1
        with:
          virtualenvs-create: true
          virtualenvs-in-project: true
          virtualenvs-path: .venv
          installer-parallel: true
      - name: Load cached venv
        id: cached-poetry-dependencies
        uses: actions/cache@v4
        with:
          path: .venv
          key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
      - name: Install dependencies
        if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
        run: poetry install --no-interaction --no-root
      - name: Install project
        run: poetry install --no-interaction
      - name: Run tests
        run: |
          source .venv/bin/activate
          pytest tests/

Originally I tried this action on a big project and I thought that it was because of a conflict with another of the actions that I use, so I created a project just to try this action.

  1. First time running the action here
  2. Second time running the action, it says cache not found here
    Cache not found for input keys: venv-Linux-3.12.7-bb63a1c041782c930b462e4d43633fe388d4e789e6c4040accbd588f28d55846
  3. The cache with the id is present in the caches on GA Screenshot 2024-10-15 at 8 21 19 PM

Any ideas what I could be doing wrong?

sondrelg commented 5 days ago

At first glance it looks correct. Both use the same cache key. I find it a bit odd that your Post Load cached venv took over an hour to complete in the second run, with a bunch of errors.

The cache seems to have worked in this subsequent run. Is it possible this is just Github actions having problems?

reddytocode commented 5 days ago

@sondrelg Yeah, that subsequent run uses setup-python to use the cache:

steps:
- uses: actions/checkout@v4
- name: Install poetry
  run: pipx install poetry
- uses: actions/setup-python@v5
  with:
    python-version: '3.9'
    cache: 'poetry'
- run: poetry install
- run: poetry run pytest