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

Incorrect cache loaded if default not found #43

Open
2e0byo opened this issue Sep 14, 2023 · 1 comment
Open

Incorrect cache loaded if default not found #43

2e0byo opened this issue Sep 14, 2023 · 1 comment

Comments

@2e0byo
Copy link

2e0byo commented Sep 14, 2023

With the following workflow definition (excerpted):

- run: echo '-G dev -G ci' > deps.groups
- name: Install PDM
  uses: pdm-project/setup-pdm@v3
  with:
    python-version: "3.10"
    cache: true
    # These files will be hashed to generate the cache key
    cache-dependency-path: |
      ./pdm.lock
      ./deps.groups
- run: pdm sync $(cat deps.groups)

I would expect the behaviour to be:

First run

  • pdm looks for a cache by hashing the contents of pdm.lock and deps.groups
  • pdm doesn't find anything, so no cache is pulled
  • pdm creates a cache with the deps installed in this run

Subsequent runs:

  • pdm looks for a cache by hashing pdm.lock and deps.groups
  • pdm finds the previous cache
  • installs are quick, since the cache is populated

In actual fact the behaviour is:

First run

  • pdm pulls another, unrelated pdm cache (with 7GB of unwanted deps)
  • pdm installs the desired groups
  • pdm creates a hash under the correct key, with 7GB of unwanted deps + new deps

Subsequent runs:

  • pdm pulls the cache made in the first run
  • installs take forever, because the cache is polluted

Presumably there's some fallback logic in cache.ts. I intend to PR a fix for this.

This breaks workflows where pdm is being used to handle multiple sets of deps (e.g. a tiny install for linting tools vs. everything for unit tests).

@2e0byo
Copy link
Author

2e0byo commented Sep 15, 2023

I have since worked out why this is the default behaviour: you want to pre-seed the cache when a dependency changes. I'll have a think and see if I can write a PR which satisfies both requirements.

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

1 participant