No default UV_CACHE_DIR on selfhosted runners

This commit is contained in:
Kevin Stillhammer 2025-04-22 20:37:20 +02:00
parent aa1290542e
commit 4f85e26dd6
No known key found for this signature in database
4 changed files with 54 additions and 11 deletions

View file

@ -397,6 +397,30 @@ jobs:
env: env:
CACHE_HIT: ${{ steps.restore.outputs.cache-hit }} 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: test-setup-cache-local:
runs-on: selfhosted-ubuntu-arm64 runs-on: selfhosted-ubuntu-arm64
steps: steps:
@ -509,6 +533,7 @@ jobs:
- test-tilde-expansion-tool-dirs - test-tilde-expansion-tool-dirs
- test-python-version - test-python-version
- test-musl - test-musl
- test-cache-local
- test-restore-cache - test-restore-cache
- test-restore-cache-requirements-txt - test-restore-cache-requirements-txt
- test-restore-cache-dependency-glob - test-restore-cache-dependency-glob

6
dist/save-cache/index.js generated vendored
View file

@ -89053,11 +89053,17 @@ function getCacheLocalPath() {
if (cacheLocalPathInput !== "") { if (cacheLocalPathInput !== "") {
return expandTilde(cacheLocalPathInput); return expandTilde(cacheLocalPathInput);
} }
if (process.env.RUNNER_ENVIRONMENT === "github-hosted") {
if (process.env.RUNNER_TEMP !== undefined) { if (process.env.RUNNER_TEMP !== undefined) {
return `${process.env.RUNNER_TEMP}${node_path_1.default.sep}setup-uv-cache`; 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) { function expandTilde(input) {
if (input.startsWith("~")) { if (input.startsWith("~")) {
return `${process.env.HOME}${input.substring(1)}`; return `${process.env.HOME}${input.substring(1)}`;

6
dist/setup/index.js generated vendored
View file

@ -124564,11 +124564,17 @@ function getCacheLocalPath() {
if (cacheLocalPathInput !== "") { if (cacheLocalPathInput !== "") {
return expandTilde(cacheLocalPathInput); return expandTilde(cacheLocalPathInput);
} }
if (process.env.RUNNER_ENVIRONMENT === "github-hosted") {
if (process.env.RUNNER_TEMP !== undefined) { if (process.env.RUNNER_TEMP !== undefined) {
return `${process.env.RUNNER_TEMP}${node_path_1.default.sep}setup-uv-cache`; 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) { function expandTilde(input) {
if (input.startsWith("~")) { if (input.startsWith("~")) {
return `${process.env.HOME}${input.substring(1)}`; return `${process.env.HOME}${input.substring(1)}`;

View file

@ -64,6 +64,7 @@ function getCacheLocalPath(): string {
if (cacheLocalPathInput !== "") { if (cacheLocalPathInput !== "") {
return expandTilde(cacheLocalPathInput); return expandTilde(cacheLocalPathInput);
} }
if (process.env.RUNNER_ENVIRONMENT === "github-hosted") {
if (process.env.RUNNER_TEMP !== undefined) { if (process.env.RUNNER_TEMP !== undefined) {
return `${process.env.RUNNER_TEMP}${path.sep}setup-uv-cache`; return `${process.env.RUNNER_TEMP}${path.sep}setup-uv-cache`;
} }
@ -71,6 +72,11 @@ function getCacheLocalPath(): string {
"Could not determine UV_CACHE_DIR. Please make sure RUNNER_TEMP is set or provide the cache-local-path input", "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 { function expandTilde(input: string): string {
if (input.startsWith("~")) { if (input.startsWith("~")) {