Skip to content

hynek/setup-cached-uv

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Setup uv and Handle Its Cache

Warning

This action is still semi-experimental. I’m happy to hear feedback, though!

This action will download and install the latest version of uv using the official installer and handle its package cache for you.

jobs:
  tests:
    runs-on: ubuntu-latest  # or macOS, or Windows
    steps:
      - uses: hynek/setup-cached-uv@v1

      - run: uv ...

Cache Management

Caution

It’s important to understand that once a cache of a certain name has been created, it will be used in all subsequent jobs within the same workflow and will not be updated.

This means that if you create the cache in the first job that installs only, say, build and twine, and later load the cache again and install more packages, those packages will not be cached for the next run.

A cache also doesn’t expire as long as it has been used in the last 7 days. That does not mean that you’re getting obsolete package versions – just that they’re not cached.

To work around this, setup-cached-uv allows you to add two types of suffixes as inputs to the cache name. This way you can have multiple caches per workflow that contain different sets of packages.

Note that the operating system of the runner is automatically added to the cache name – meaning, without adding suffixes, the names of the caches are uv-Linux, uv-macOS, and uv-Windows.

Optional Inputs

cache-suffix

A static string to append to the cache name. This could, for example, be the name of the job, or the current week number to bust the cache weekly:

      # ...
      - run: echo WEEK=$(date +%V) >>$GITHUB_ENV
        shell: bash

      - uses: ./action
        with:
          cache-suffix: -tests-${{ env.WEEK }}
      # ...

cache-dependency-path

A path to a file whose contents is hashed and appended to the cache name. May contain glob-style patterns and match more than one file. Internally, the GitHub Actions function hashFiles is used to hash the passed path.

Using this with a fully pinned requirements.txt file is the most efficient use of this action because it automatically invalidates the cache.

Examples

Check out our CI to see both inputs in action.

License

The scripts and documentation in this project are released under the MIT License.

About

No description, website, or topics provided.

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Sponsor this project

 

Packages