mamba-org / setup-micromamba

GitHub Action to set up micromamba
MIT License
97 stars 15 forks source link

Cache invalidation does not take into account files referenced by environment.yml #113

Closed chrispyles closed 9 months ago

chrispyles commented 1 year ago

In ucbds-infra/otter-grader#684, I am adding two new requirements for the package in the repo's requirements.txt file. This file is referenced by the environment.yml file. Our action is configured to cache the mamba environment but is currently failing because the new requirements were added to requirements.txt but environment.yml was not updated, so the setup-micromamba action assumes nothing has changed and uses the cached image.

It would be nice to be able to specify that the environment.yml depends on other files so that hashes of those files can also be used in the cache key, e.g.

- uses: mamba-org/setup-micromamba@v1
  with:
    environment-file: environment.yml
    init-shell: >-
      bash
    cache-environment: true
    cache-files:
      - requirements.txt

Alternatively, is there a way to manually invalidate the cache for force micromamba to rebuild it?

jonashaag commented 1 year ago

You can manually remove cache entries via GitHub's UI.

I don't think we want to be in the business of validating external files generally speaking but maybe we can support -r requirements.txt.

Otherwise you can add the hash of your file to cache-downloads-key

chrispyles commented 1 year ago

Thanks for pointing out that the cache can be deleted manually, @jonashaag; that's unblocked my PR. +1 to supporting -r requirements.txt.

pavelzw commented 1 year ago

You can already specify additional cache constraints by something like this:

cache-environment-key: micromamba-env-${{ hashFiles('requirements.txt', 'other-relevant-files') }}

I don't see much value from adding a cache-files option since this is probably not a very common use case and there already is the above mentioned way to solve it.