Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test Example for GA not working #161

Open
reddytocode opened this issue Oct 16, 2024 · 2 comments
Open

Test Example for GA not working #161

reddytocode opened this issue Oct 16, 2024 · 2 comments

Comments

@reddytocode
Copy link

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
  1. 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
Copy link
Member

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
Copy link
Author

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants