diff --git a/README.md b/README.md index 71c66a7..f35791e 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ This could, for example, be the name of the job, or the current week number to b - run: echo WEEK=$(date +%V) >>$GITHUB_ENV shell: bash - - uses: ./action + - uses: hynek/setup-cached-uv@v1 with: cache-suffix: -tests-${{ env.WEEK }} # ... @@ -61,9 +61,23 @@ Internally, the GitHub Actions function `hashFiles` is used to hash the passed p Using this with a fully pinned `requirements.txt` file is the most efficient use of this action because it automatically invalidates the cache. +#### `if-use-cache` + +This defaults to `true`, but can be used to disable the cache, since GitHub's default caching speed is slower than uv in many cases. +For example, if you have dependencies that don't provide prebuilt PyPy wheels, you can only cache that run like this: + +```yaml + # ... + - uses: hynek/setup-cached-uv@v1 + with: + if-use-cache: ${{ startsWith(matrix.python-version, 'pypy') }} + # ... +``` + + ### Examples -Check out [our CI](.github/workflows/ci.yml) to see both inputs in action. +Check out [our CI](.github/workflows/ci.yml) to see some inputs in action. ## License diff --git a/action.yml b/action.yml index 3f8bdad..d6768d9 100644 --- a/action.yml +++ b/action.yml @@ -17,6 +17,11 @@ inputs: required: false default: "" + use-cache-if: + description: Save the cache. + required: false + default: true + runs: using: composite @@ -41,10 +46,11 @@ runs: "HASH_CACHE_SUFFIX=-${{ hashFiles(inputs.cache-dependency-path) }}" >>$GITHUB_ENV shell: bash - if: inputs.cache-dependency-path != '' + if: inputs.cache-dependency-path != '' && inputs.use-cache-if == 'true' - name: Load uv cache uses: actions/cache@v4 + if: inputs.use-cache-if == 'true' with: path: ${{ env.UV_CACHE }} key: uv-${{ runner.os }}${{ inputs.cache-suffix }}${{ env.HASH_CACHE_SUFFIX }}