Skip to content

Commit

Permalink
Use different default cache dir for Windows (#16)
Browse files Browse the repository at this point in the history
* Use different default cache dir for Windows

* Add debug output

* quotes

* quote

* use input

* quoting

* Add PR#
  • Loading branch information
hynek authored Sep 9, 2024
1 parent 5957769 commit d4a5214
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 16 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/v2.1.0...main)

### Changed

- The default cache path for Windows is now `D:\a\_temp\scu-uv-cache`.
[#16](https://github.com/hynek/setup-cached-uv/pull/16)


## [2.1.0](https://github.com/hynek/setup-cached-uv/compare/v2.0.0...v2.1.0) - 2024-08-15

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ You may want to set this to `""` if you already use `cache-dependency-path` to i
#### `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`.
Due to path restrictions, it’s impossible to cache the default path, so we moved it to a path beneath `/tmp` for Linux/macOS and `D:\a\_temp` on Windows.
You can change it to elsewhere using this input, but make sure that [*actions/cache*](https://github.com/actions/cache) can find it.


Expand Down
45 changes: 30 additions & 15 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,34 +30,49 @@ inputs:
uv-cache-path:
description: Where to put uv's cache directory.
required: false
default: /tmp/scu-uv-cache
default: NOT_SET

runs:
using: composite

steps:
- name: Install uv on Linux or macOS
run: >
curl
--location
--silent
--show-error
--fail
--proto '=https'
--tlsv1.2
https://astral.sh/uv/install.sh | bash
run: |
if [ "${{ inputs.uv-cache-path }}" = "NOT_SET" ]; then
UV_CACHE_DIR="/tmp/scu-uv-cache"
else
UV_CACHE_DIR="${{ inputs.uv-cache-path }}"
fi
echo "UV_CACHE_DIR=\"$UV_CACHE_DIR\"" >>$GITHUB_ENV
echo "uv cache dir is $UV_CACHE_DIR"
curl \
--location \
--silent \
--show-error \
--fail \
--proto '=https' \
--tlsv1.2 \
https://astral.sh/uv/install.sh | bash
shell: bash
if: runner.os != 'Windows'

- name: Install uv on Windows
run: irm https://astral.sh/uv/install.ps1 | iex
run: |
if ("${{ inputs.uv-cache-path }}" -eq "NOT_SET") {
$UV_CACHE_DIR = "D:\a\_temp\scu-uv-cache"
} else {
$UV_CACHE_DIR = "${{ inputs.uv-cache-path }}"
}
echo "UV_CACHE_DIR=${{ inputs.uv-cache-path }}" >> $env:GITHUB_ENV
Write-Output "uv cache dir is $UV_CACHE_DIR"
irm https://astral.sh/uv/install.ps1 | iex
shell: pwsh
if: runner.os == 'Windows'

- 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 key suffix by hashing ${{ inputs.cache-dependency-path }}
run: >
echo
Expand Down

0 comments on commit d4a5214

Please sign in to comment.