mirror of
https://github.com/astral-sh/setup-uv.git
synced 2025-02-23 17:15:20 +08:00
Default to enable-cache: true on GitHub hosted runners (#193)
Closes: #54
This commit is contained in:
parent
3460fe1a9a
commit
e3017a763c
29
.github/workflows/test-cache.yml
vendored
29
.github/workflows/test-cache.yml
vendored
@ -11,18 +11,26 @@ concurrency:
|
||||
|
||||
jobs:
|
||||
test-setup-cache:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
enable-cache: [ "true", "false", "auto" ]
|
||||
os: ["ubuntu-latest", "selfhosted-ubuntu-arm64"]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Setup with cache
|
||||
uses: ./
|
||||
with:
|
||||
enable-cache: true
|
||||
cache-suffix: ${{ github.run_id }}-${{ github.run_attempt }}-test-setup-cache
|
||||
enable-cache: ${{ matrix.enable-cache }}
|
||||
cache-suffix: ${{ github.run_id }}-${{ github.run_attempt }}-test-setup-cache-${{ matrix.os }}-${{ matrix.enable-cache }}
|
||||
- run: uv sync
|
||||
working-directory: __tests__/fixtures/uv-project
|
||||
test-restore-cache:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
enable-cache: [ "true", "false", "auto" ]
|
||||
os: [ "ubuntu-latest", "selfhosted-ubuntu-arm64" ]
|
||||
needs: test-setup-cache
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
@ -30,15 +38,24 @@ jobs:
|
||||
id: restore
|
||||
uses: ./
|
||||
with:
|
||||
enable-cache: true
|
||||
cache-suffix: ${{ github.run_id }}-${{ github.run_attempt }}-test-setup-cache
|
||||
enable-cache: ${{ matrix.enable-cache }}
|
||||
cache-suffix: ${{ github.run_id }}-${{ github.run_attempt }}-test-setup-cache-${{ matrix.os }}-${{ matrix.enable-cache }}
|
||||
- name: Cache was hit
|
||||
if: ${{ matrix.enable-cache == 'true' || (matrix.enable-cache == 'auto' && matrix.os == 'ubuntu-latest') }}
|
||||
run: |
|
||||
if [ "$CACHE_HIT" != "true" ]; then
|
||||
exit 1
|
||||
fi
|
||||
env:
|
||||
CACHE_HIT: ${{ steps.restore.outputs.cache-hit }}
|
||||
- name: Cache was not hit
|
||||
if: ${{ matrix.enable-cache == 'false' || (matrix.enable-cache == 'auto' && matrix.os == 'selfhosted-ubuntu-arm64') }}
|
||||
run: |
|
||||
if [ "$CACHE_HIT" == "true" ]; then
|
||||
exit 1
|
||||
fi
|
||||
env:
|
||||
CACHE_HIT: ${{ steps.restore.outputs.cache-hit }}
|
||||
- run: uv sync
|
||||
working-directory: __tests__/fixtures/uv-project
|
||||
test-setup-cache-requirements-txt:
|
||||
|
2
.github/workflows/test.yml
vendored
2
.github/workflows/test.yml
vendored
@ -84,6 +84,8 @@ jobs:
|
||||
with:
|
||||
version: "0.3.2"
|
||||
checksum: ${{ matrix.checksum }}
|
||||
- run: uv sync
|
||||
working-directory: __tests__/fixtures/uv-project
|
||||
test-with-explicit-token:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
@ -20,7 +20,7 @@ inputs:
|
||||
default: ${{ github.token }}
|
||||
enable-cache:
|
||||
description: "Enable caching of the uv cache"
|
||||
default: "false"
|
||||
default: "auto"
|
||||
cache-dependency-glob:
|
||||
description:
|
||||
"Glob pattern to match files relative to the repository root to control
|
||||
|
9
dist/save-cache/index.js
generated
vendored
9
dist/save-cache/index.js
generated
vendored
@ -91803,7 +91803,7 @@ const node_path_1 = __importDefault(__nccwpck_require__(6760));
|
||||
exports.version = core.getInput("version");
|
||||
exports.pythonVersion = core.getInput("python-version");
|
||||
exports.checkSum = core.getInput("checksum");
|
||||
exports.enableCache = core.getInput("enable-cache") === "true";
|
||||
exports.enableCache = getEnableCache();
|
||||
exports.cacheSuffix = core.getInput("cache-suffix") || "";
|
||||
exports.cacheLocalPath = getCacheLocalPath();
|
||||
exports.cacheDependencyGlob = core.getInput("cache-dependency-glob");
|
||||
@ -91812,6 +91812,13 @@ exports.ignoreNothingToCache = core.getInput("ignore-nothing-to-cache") === "tru
|
||||
exports.toolBinDir = getToolBinDir();
|
||||
exports.toolDir = getToolDir();
|
||||
exports.githubToken = core.getInput("github-token");
|
||||
function getEnableCache() {
|
||||
const enableCacheInput = core.getInput("enable-cache");
|
||||
if (enableCacheInput === "auto") {
|
||||
return process.env.RUNNER_ENVIRONMENT === "github-hosted";
|
||||
}
|
||||
return enableCacheInput === "true";
|
||||
}
|
||||
function getToolBinDir() {
|
||||
const toolBinDirInput = core.getInput("tool-bin-dir");
|
||||
if (toolBinDirInput !== "") {
|
||||
|
9
dist/setup/index.js
generated
vendored
9
dist/setup/index.js
generated
vendored
@ -99334,7 +99334,7 @@ const node_path_1 = __importDefault(__nccwpck_require__(6760));
|
||||
exports.version = core.getInput("version");
|
||||
exports.pythonVersion = core.getInput("python-version");
|
||||
exports.checkSum = core.getInput("checksum");
|
||||
exports.enableCache = core.getInput("enable-cache") === "true";
|
||||
exports.enableCache = getEnableCache();
|
||||
exports.cacheSuffix = core.getInput("cache-suffix") || "";
|
||||
exports.cacheLocalPath = getCacheLocalPath();
|
||||
exports.cacheDependencyGlob = core.getInput("cache-dependency-glob");
|
||||
@ -99343,6 +99343,13 @@ exports.ignoreNothingToCache = core.getInput("ignore-nothing-to-cache") === "tru
|
||||
exports.toolBinDir = getToolBinDir();
|
||||
exports.toolDir = getToolDir();
|
||||
exports.githubToken = core.getInput("github-token");
|
||||
function getEnableCache() {
|
||||
const enableCacheInput = core.getInput("enable-cache");
|
||||
if (enableCacheInput === "auto") {
|
||||
return process.env.RUNNER_ENVIRONMENT === "github-hosted";
|
||||
}
|
||||
return enableCacheInput === "true";
|
||||
}
|
||||
function getToolBinDir() {
|
||||
const toolBinDirInput = core.getInput("tool-bin-dir");
|
||||
if (toolBinDirInput !== "") {
|
||||
|
@ -4,7 +4,7 @@ import path from "node:path";
|
||||
export const version = core.getInput("version");
|
||||
export const pythonVersion = core.getInput("python-version");
|
||||
export const checkSum = core.getInput("checksum");
|
||||
export const enableCache = core.getInput("enable-cache") === "true";
|
||||
export const enableCache = getEnableCache();
|
||||
export const cacheSuffix = core.getInput("cache-suffix") || "";
|
||||
export const cacheLocalPath = getCacheLocalPath();
|
||||
export const cacheDependencyGlob = core.getInput("cache-dependency-glob");
|
||||
@ -15,6 +15,14 @@ export const toolBinDir = getToolBinDir();
|
||||
export const toolDir = getToolDir();
|
||||
export const githubToken = core.getInput("github-token");
|
||||
|
||||
function getEnableCache(): boolean {
|
||||
const enableCacheInput = core.getInput("enable-cache");
|
||||
if (enableCacheInput === "auto") {
|
||||
return process.env.RUNNER_ENVIRONMENT === "github-hosted";
|
||||
}
|
||||
return enableCacheInput === "true";
|
||||
}
|
||||
|
||||
function getToolBinDir(): string | undefined {
|
||||
const toolBinDirInput = core.getInput("tool-bin-dir");
|
||||
if (toolBinDirInput !== "") {
|
||||
|
Loading…
x
Reference in New Issue
Block a user