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

feat: use cache option #6

Merged
merged 2 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
hynek marked this conversation as resolved.
Show resolved Hide resolved
- uses: hynek/setup-cached-uv@v1
with:
cache-suffix: -tests-${{ env.WEEK }}
# ...
Expand All @@ -60,10 +60,25 @@ 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.

#### `use-cache`
henryiii marked this conversation as resolved.
Show resolved Hide resolved

This defaults to `true`, but can be used to disable the cache, since GitHub's
henryiii marked this conversation as resolved.
Show resolved Hide resolved
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:
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
Expand Down
8 changes: 7 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ inputs:
required: false
default: ""

use-cache:
henryiii marked this conversation as resolved.
Show resolved Hide resolved
description: Save the cache.
required: false
default: true

runs:
using: composite

Expand All @@ -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 == 'true'

- name: Load uv cache
uses: actions/cache@v4
if: inputs.use-cache == 'true'
with:
path: ${{ env.UV_CACHE }}
key: uv-${{ runner.os }}${{ inputs.cache-suffix }}${{ env.HASH_CACHE_SUFFIX }}