Skip to content

Commit

Permalink
Move cache dir to /tmp and make it configurable (#8)
Browse files Browse the repository at this point in the history
* Move cache dir to /tmp and make it configurable

* More consistent variable name

* Add docs

* Add PR#

* Wording
  • Loading branch information
hynek authored Jul 26, 2024
1 parent 523650a commit 291e973
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## [UNRELEASED](https://github.com/hynek/setup-cached-uv/compare/v1.2.0...main)

### Fixed

- The cache directory couldn't actually be... cached ...due to path restrictions (anymore?) so we moved it into `/tmp/` and made it configurable using the new action input `uv-cache-dir`.
[#8](https://github.com/hynek/setup-cached-uv/pull/8)


## [1.2.0](https://github.com/hynek/setup-cached-uv/compare/v1.1.0...v1.2.0) - 2024-07-22

Expand Down
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,16 @@ 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.


#### `uv-cache-path`

The path to *uv*'s cache.
Due to path restrictions, it's impossible to cache the default path, so we moved it to a path beneath `/tmp`.
You can change it to elsewhere using this input, but make sure, that [*actions/cache*](https://github.com/actions/cache) can find it.


#### `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.
This defaults to `true`, but can be used to disable the cache, since GitHub's default caching speed can be slower than an uncached *uv*.
For example, if you have dependencies that don't provide prebuilt PyPy wheels, you can only cache that run like this:

```yaml
Expand Down
11 changes: 8 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ inputs:
required: false
default: true

uv-cache-path:
description: Where to put uv's cache directory.
required: false
default: /tmp/scu-uv-cache

runs:
using: composite

Expand All @@ -36,8 +41,8 @@ runs:
shell: pwsh
if: runner.os == 'Windows'

- name: Find uv cache
run: echo "UV_CACHE=$(uv cache dir)" >>$GITHUB_ENV
- name: Set uv cache directory to ${{ inputs.uv-cache-path }}
run: echo "UV_CACHE_DIR=${{ inputs.uv-cache-path }}" >>$GITHUB_ENV
shell: bash

- name: Compute cache suffix by hashing ${{ inputs.cache-dependency-path }}
Expand All @@ -52,5 +57,5 @@ runs:
uses: actions/cache@v4
if: inputs.use-cache-if == 'true'
with:
path: ${{ env.UV_CACHE }}
path: ${{ env.UV_CACHE_DIR }}
key: uv-${{ runner.os }}${{ inputs.cache-suffix }}${{ env.HASH_CACHE_SUFFIX }}

0 comments on commit 291e973

Please sign in to comment.