diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5a9c0a2..541fada 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -397,6 +397,30 @@ jobs: env: CACHE_HIT: ${{ steps.restore.outputs.cache-hit }} + test-cache-local: + strategy: + matrix: + inputs: + - os: ubuntu-latest + expected-cache-dir: "/home/runner/work/_temp/setup-uv-cache" + - os: windows-latest + expected-cache-dir: "D:\\a\\_temp\\setup-uv-cache" + - os: selfhosted-ubuntu-arm64 + expected-cache-dir: "/home/ubuntu/.cache/uv" + runs-on: ${{ matrix.inputs.os }} + steps: + - uses: actions/checkout@v4 + - name: Setup with cache + uses: ./ + with: + cache-suffix: ${{ github.run_id }}-${{ github.run_attempt }}-test-cache-local + - run: | + if [ "$UV_CACHE_DIR" != "${{ matrix.inputs.expected-cache-dir }}" ]; then + echo "UV_CACHE_DIR is not set to the expected value: $UV_CACHE_DIR" + exit 1 + fi + shell: bash + test-setup-cache-local: runs-on: selfhosted-ubuntu-arm64 steps: @@ -509,6 +533,7 @@ jobs: - test-tilde-expansion-tool-dirs - test-python-version - test-musl + - test-cache-local - test-restore-cache - test-restore-cache-requirements-txt - test-restore-cache-dependency-glob diff --git a/dist/save-cache/index.js b/dist/save-cache/index.js index c80c0c5..7c23e37 100644 --- a/dist/save-cache/index.js +++ b/dist/save-cache/index.js @@ -89053,10 +89053,16 @@ function getCacheLocalPath() { if (cacheLocalPathInput !== "") { return expandTilde(cacheLocalPathInput); } - if (process.env.RUNNER_TEMP !== undefined) { - return `${process.env.RUNNER_TEMP}${node_path_1.default.sep}setup-uv-cache`; + if (process.env.RUNNER_ENVIRONMENT === "github-hosted") { + if (process.env.RUNNER_TEMP !== undefined) { + return `${process.env.RUNNER_TEMP}${node_path_1.default.sep}setup-uv-cache`; + } + throw Error("Could not determine UV_CACHE_DIR. Please make sure RUNNER_TEMP is set or provide the cache-local-path input"); } - throw Error("Could not determine UV_CACHE_DIR. Please make sure RUNNER_TEMP is set or provide the cache-local-path input"); + if (process.platform === "win32") { + return `${process.env.APPDATA}${node_path_1.default.sep}uv${node_path_1.default.sep}cache`; + } + return `${process.env.HOME}${node_path_1.default.sep}.cache${node_path_1.default.sep}uv`; } function expandTilde(input) { if (input.startsWith("~")) { diff --git a/dist/setup/index.js b/dist/setup/index.js index d101e50..e270af6 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -124564,10 +124564,16 @@ function getCacheLocalPath() { if (cacheLocalPathInput !== "") { return expandTilde(cacheLocalPathInput); } - if (process.env.RUNNER_TEMP !== undefined) { - return `${process.env.RUNNER_TEMP}${node_path_1.default.sep}setup-uv-cache`; + if (process.env.RUNNER_ENVIRONMENT === "github-hosted") { + if (process.env.RUNNER_TEMP !== undefined) { + return `${process.env.RUNNER_TEMP}${node_path_1.default.sep}setup-uv-cache`; + } + throw Error("Could not determine UV_CACHE_DIR. Please make sure RUNNER_TEMP is set or provide the cache-local-path input"); } - throw Error("Could not determine UV_CACHE_DIR. Please make sure RUNNER_TEMP is set or provide the cache-local-path input"); + if (process.platform === "win32") { + return `${process.env.APPDATA}${node_path_1.default.sep}uv${node_path_1.default.sep}cache`; + } + return `${process.env.HOME}${node_path_1.default.sep}.cache${node_path_1.default.sep}uv`; } function expandTilde(input) { if (input.startsWith("~")) { diff --git a/src/utils/inputs.ts b/src/utils/inputs.ts index cb1dcc5..726f571 100644 --- a/src/utils/inputs.ts +++ b/src/utils/inputs.ts @@ -64,12 +64,18 @@ function getCacheLocalPath(): string { if (cacheLocalPathInput !== "") { return expandTilde(cacheLocalPathInput); } - if (process.env.RUNNER_TEMP !== undefined) { - return `${process.env.RUNNER_TEMP}${path.sep}setup-uv-cache`; + if (process.env.RUNNER_ENVIRONMENT === "github-hosted") { + if (process.env.RUNNER_TEMP !== undefined) { + return `${process.env.RUNNER_TEMP}${path.sep}setup-uv-cache`; + } + throw Error( + "Could not determine UV_CACHE_DIR. Please make sure RUNNER_TEMP is set or provide the cache-local-path input", + ); } - throw Error( - "Could not determine UV_CACHE_DIR. Please make sure RUNNER_TEMP is set or provide the cache-local-path input", - ); + if (process.platform === "win32") { + return `${process.env.APPDATA}${path.sep}uv${path.sep}cache`; + } + return `${process.env.HOME}${path.sep}.cache${path.sep}uv`; } function expandTilde(input: string): string {