From 0d5ceb47864d17728a8cf5fe207d356ddc4772c6 Mon Sep 17 00:00:00 2001 From: Daniel Fichtinger Date: Wed, 16 Jul 2025 00:55:54 -0400 Subject: [PATCH 1/4] Added cache-hit output --- README.md | 6 ++++++ action.yml | 5 +++++ 2 files changed, 11 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..bc18a23 --- /dev/null +++ b/README.md @@ -0,0 +1,6 @@ +# uv-cache + +This is a very simple action that sets up cache support for `uv`. It doesn't do +anything else. It's assumed that `uv`, as well as all the dependencies for +`actions/cache@v4` are available in the container. I wrote this to work well +with [based-alpine](https://git.ficd.sh/ficd/based-alpine). diff --git a/action.yml b/action.yml index 4ab22f8..5d4dfb5 100644 --- a/action.yml +++ b/action.yml @@ -1,6 +1,10 @@ name: Setup uv cache description: Composite action to determine uv cache dir and restore cache. author: Daniel Fichtinger +outputs: + uv-cache-hit: + description: "Whether the uv cache was restored" + value: ${{ steps.cache-restore.outputs.cache-hit }} runs: using: "composite" steps: @@ -10,6 +14,7 @@ runs: run: | echo "dir=$(uv cache dir)" >> "$GITHUB_OUTPUT" - name: Restore uv cache + id: cache-restoree uses: actions/cache@v4 with: path: ${{ steps.uv-cache.outputs.dir }} From dac7f7aea0e9210f9b764f1e779e58e9dac5b338 Mon Sep 17 00:00:00 2001 From: Daniel Fichtinger Date: Wed, 16 Jul 2025 01:01:56 -0400 Subject: [PATCH 2/4] fixed type in step id --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 5d4dfb5..0226a6c 100644 --- a/action.yml +++ b/action.yml @@ -14,7 +14,7 @@ runs: run: | echo "dir=$(uv cache dir)" >> "$GITHUB_OUTPUT" - name: Restore uv cache - id: cache-restoree + id: cache-restore uses: actions/cache@v4 with: path: ${{ steps.uv-cache.outputs.dir }} From f05f23362664efcf311cf81c157bce69b3ab6bcb Mon Sep 17 00:00:00 2001 From: Daniel Fichtinger Date: Wed, 16 Jul 2025 01:08:29 -0400 Subject: [PATCH 3/4] fix cache hit output --- action.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 0226a6c..909304f 100644 --- a/action.yml +++ b/action.yml @@ -2,9 +2,9 @@ name: Setup uv cache description: Composite action to determine uv cache dir and restore cache. author: Daniel Fichtinger outputs: - uv-cache-hit: + cache-hit: description: "Whether the uv cache was restored" - value: ${{ steps.cache-restore.outputs.cache-hit }} + value: ${{ steps.cache-output.outputs.cache-hit }} runs: using: "composite" steps: @@ -21,3 +21,8 @@ runs: key: ${{ runner.os }}-uv-${{ hashFiles('**/*requirements*.txt', '**/*requirements*.in', '**/*constraints*.txt', '**/*constraints*.in', '**/pyproject.toml', '**/uv.lock') }} restore-keys: | ${{ runner.os }}-uv- + - name: Capture cache-hit output + id: cache-output + shell: bash + run: | + echo "cache-hit=${{ steps.cache-restore.outputs.cache-hit }}" >> "$GITHUB_OUTPUT" From ed52ce502e0ddb7bfaee4bce49cbe8f66d22b811 Mon Sep 17 00:00:00 2001 From: Daniel Fichtinger Date: Wed, 16 Jul 2025 01:16:09 -0400 Subject: [PATCH 4/4] update docs --- README.md | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index bc18a23..999306d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,29 @@ # uv-cache This is a very simple action that sets up cache support for `uv`. It doesn't do -anything else. It's assumed that `uv`, as well as all the dependencies for -`actions/cache@v4` are available in the container. I wrote this to work well -with [based-alpine](https://git.ficd.sh/ficd/based-alpine). +anything else. I wrote this to work well with +[based-alpine](https://git.ficd.sh/ficd/based-alpine). + +## Requirements + +All dependencies `actions/cache@v4` must be satisfied, and `uv` must be +available on the path. + +## Usage + +Using this action is very simple. We also provide one output: `cache-hit`, which +is either "true" or "false". + +```yaml +# you should always checkout first +# otherwise there is nothing to check cache against +- name: checkout source + uses: actions/checkout@v4 +- name: setup cache + # assign the id if you want to check the boolean later + id: uv-cache + uses: https://git.ficd.sh/ficd/uv-cache@v1 +- name: Check cache status + run: | + echo "Cache hit? ${{ steps.uv-cache.outputs.cache-hit }}" +```