Skip to content

Commit a0f9da6

Browse files
authored
No default UV_CACHE_DIR on selfhosted runners (#380)
Closes: #371
1 parent ec4c691 commit a0f9da6

File tree

4 files changed

+54
-11
lines changed

4 files changed

+54
-11
lines changed

.github/workflows/test.yml

+25
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,30 @@ jobs:
408408
env:
409409
CACHE_HIT: ${{ steps.restore.outputs.cache-hit }}
410410

411+
test-cache-local:
412+
strategy:
413+
matrix:
414+
inputs:
415+
- os: ubuntu-latest
416+
expected-cache-dir: "/home/runner/work/_temp/setup-uv-cache"
417+
- os: windows-latest
418+
expected-cache-dir: "D:\\a\\_temp\\setup-uv-cache"
419+
- os: selfhosted-ubuntu-arm64
420+
expected-cache-dir: "/home/ubuntu/.cache/uv"
421+
runs-on: ${{ matrix.inputs.os }}
422+
steps:
423+
- uses: actions/checkout@v4
424+
- name: Setup with cache
425+
uses: ./
426+
with:
427+
cache-suffix: ${{ github.run_id }}-${{ github.run_attempt }}-test-cache-local
428+
- run: |
429+
if [ "$UV_CACHE_DIR" != "${{ matrix.inputs.expected-cache-dir }}" ]; then
430+
echo "UV_CACHE_DIR is not set to the expected value: $UV_CACHE_DIR"
431+
exit 1
432+
fi
433+
shell: bash
434+
411435
test-setup-cache-local:
412436
runs-on: selfhosted-ubuntu-arm64
413437
steps:
@@ -521,6 +545,7 @@ jobs:
521545
- test-python-version
522546
- test-activate-environment
523547
- test-musl
548+
- test-cache-local
524549
- test-restore-cache
525550
- test-restore-cache-requirements-txt
526551
- test-restore-cache-dependency-glob

dist/save-cache/index.js

+9-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/setup/index.js

+9-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/utils/inputs.ts

+11-5
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,18 @@ function getCacheLocalPath(): string {
6464
if (cacheLocalPathInput !== "") {
6565
return expandTilde(cacheLocalPathInput);
6666
}
67-
if (process.env.RUNNER_TEMP !== undefined) {
68-
return `${process.env.RUNNER_TEMP}${path.sep}setup-uv-cache`;
67+
if (process.env.RUNNER_ENVIRONMENT === "github-hosted") {
68+
if (process.env.RUNNER_TEMP !== undefined) {
69+
return `${process.env.RUNNER_TEMP}${path.sep}setup-uv-cache`;
70+
}
71+
throw Error(
72+
"Could not determine UV_CACHE_DIR. Please make sure RUNNER_TEMP is set or provide the cache-local-path input",
73+
);
74+
}
75+
if (process.platform === "win32") {
76+
return `${process.env.APPDATA}${path.sep}uv${path.sep}cache`;
6977
}
70-
throw Error(
71-
"Could not determine UV_CACHE_DIR. Please make sure RUNNER_TEMP is set or provide the cache-local-path input",
72-
);
78+
return `${process.env.HOME}${path.sep}.cache${path.sep}uv`;
7379
}
7480

7581
function expandTilde(input: string): string {

0 commit comments

Comments
 (0)