Skip to content

Commit e322719

Browse files
committed
feat: use cache option
1 parent 47408fd commit e322719

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

README.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ This could, for example, be the name of the job, or the current week number to b
4545
- run: echo WEEK=$(date +%V) >>$GITHUB_ENV
4646
shell: bash
4747
48-
- uses: ./action
48+
- uses: hynek/setup-cached-uv@v1
4949
with:
5050
cache-suffix: -tests-${{ env.WEEK }}
5151
# ...
@@ -60,10 +60,25 @@ Internally, the GitHub Actions function `hashFiles` is used to hash the passed p
6060

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

63+
#### `use-cache`
64+
65+
This defaults to `true`, but can be used to disable the cache, since GitHub's
66+
default caching speed is slower than uv in many cases. For example, if you have
67+
dependencies that don't provide prebuilt PyPy wheels, you can only cache that
68+
run like this:
69+
70+
```yaml
71+
# ...
72+
- uses: hynek/setup-cached-uv@v1
73+
with:
74+
use-cache: ${{ startsWith(matrix.python-version, 'pypy') }}
75+
# ...
76+
```
77+
6378

6479
### Examples
6580

66-
Check out [our CI](.github/workflows/ci.yml) to see both inputs in action.
81+
Check out [our CI](.github/workflows/ci.yml) to see some inputs in action.
6782

6883

6984
## License

action.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ inputs:
1717
required: false
1818
default: ""
1919

20+
use-cache:
21+
description: Save the cache.
22+
required: false
23+
default: true
24+
2025
runs:
2126
using: composite
2227

@@ -41,10 +46,11 @@ runs:
4146
"HASH_CACHE_SUFFIX=-${{ hashFiles(inputs.cache-dependency-path) }}"
4247
>>$GITHUB_ENV
4348
shell: bash
44-
if: inputs.cache-dependency-path != ''
49+
if: inputs.cache-dependency-path != '' && inputs.use-cache == 'true'
4550

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

0 commit comments

Comments
 (0)