Add uv-cache-hit and test CI

This commit is contained in:
pollenjp 2024-11-30 01:46:41 +09:00
parent e85263fd93
commit 50d654e3c5
4 changed files with 26 additions and 7 deletions

View file

@ -35,6 +35,25 @@ jobs:
uses: ./
- run: uv sync
working-directory: __tests__/fixtures/uv-project
test-default-version-cache: # https://github.com/astral-sh/setup-uv/issues/171
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, macos-14]
steps:
- uses: actions/checkout@v4
- name: Install latest version
uses: ./
- name: Verify cache hit
id: re-setup-uv
uses: ./
- name: Verify uv cache hit
run: |
if [ "$UV_CACHE_HIT" != "true" ]; then
exit 1
fi
env:
UV_CACHE_HIT: ${{ steps.re-setup-uv.outputs.uv-cache-hit }}
test-specific-version:
runs-on: ubuntu-latest
strategy:
@ -105,13 +124,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
[
ubuntu-latest,
macos-latest,
macos-14,
windows-latest,
]
os: [ubuntu-latest, macos-latest, macos-14, windows-latest]
steps:
- uses: actions/checkout@v4
- name: Install default version

View file

@ -47,6 +47,8 @@ inputs:
outputs:
uv-version:
description: "The installed uv version. Useful when using latest."
uv-cache-hit:
description: "A boolean value to indicate a cache entry for uv was found"
cache-hit:
description: "A boolean value to indicate a cache entry was found"
runs:

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

@ -90010,8 +90010,10 @@ function setupUv(platform, arch, versionInput, checkSum, githubToken) {
const toolCacheResult = (0, download_version_1.tryGetFromToolCache)(arch, resolvedVersion);
if (toolCacheResult.installedPath) {
core.info(`Found uv in tool-cache for ${resolvedVersion}`);
core.setOutput("uv-cache-hit", true);
return { uvDir: toolCacheResult.installedPath, version: resolvedVersion };
}
core.setOutput("uv-cache-hit", false);
const versionResult = yield (0, download_version_1.downloadVersion)(platform, arch, resolvedVersion, checkSum, githubToken);
return { uvDir: versionResult.cachedToolDir, version: versionResult.version };
});

View file

@ -80,8 +80,10 @@ async function setupUv(
const toolCacheResult = tryGetFromToolCache(arch, resolvedVersion);
if (toolCacheResult.installedPath) {
core.info(`Found uv in tool-cache for ${resolvedVersion}`);
core.setOutput("uv-cache-hit", true);
return { uvDir: toolCacheResult.installedPath, version: resolvedVersion };
}
core.setOutput("uv-cache-hit", false);
const versionResult = await downloadVersion(
platform,