From d4a5214fcfa35e56cc0a5589c736e7ca98e7d650 Mon Sep 17 00:00:00 2001 From: Hynek Schlawack Date: Mon, 9 Sep 2024 07:25:21 +0200 Subject: [PATCH] Use different default cache dir for Windows (#16) * Use different default cache dir for Windows * Add debug output * quotes * quote * use input * quoting * Add PR# --- CHANGELOG.md | 5 +++++ README.md | 2 +- action.yml | 45 ++++++++++++++++++++++++++++++--------------- 3 files changed, 36 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c3276bb..8337023 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/README.md b/README.md index 0365c4c..b7da116 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/action.yml b/action.yml index 4b76cb9..80d4394 100644 --- a/action.yml +++ b/action.yml @@ -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