mirror of
https://github.com/astral-sh/setup-uv.git
synced 2026-09-21 00:33:38 +00:00
Disable automatic cache saves for merge queues (#1056)
test / test-latest-version (>=0.8) (push) Failing after 2s
test / test-latest-version (latest) (push) Failing after 2s
test / test-specific-version (map[expected-version:0.3.0 version-input:0.3.0]) (push) Failing after 1m34s
test / test-specific-version (map[expected-version:0.4.25 resolution-strategy:lowest version-input:>=0.4.25,<0.5]) (push) Failing after 1m34s
test / test-specific-version (map[expected-version:0.4.25 resolution-strategy:lowest version-input:>=0.4.25]) (push) Failing after 1m34s
test / test-specific-version (map[expected-version:0.1.45 resolution-strategy:highest version-input:>=0.1,<0.2]) (push) Failing after 1m35s
test / test-specific-version (map[expected-version:0.3.5 version-input:0.3]) (push) Failing after 1m35s
test / test-specific-version (map[expected-version:0.3.5 version-input:0.3.x]) (push) Failing after 1m35s
test / test-default-version (ubuntu-latest) (push) Failing after 1m36s
test / test-specific-version (map[expected-version:0.3.2 version-input:0.3.2]) (push) Failing after 1m36s
test / test-from-working-directory-version (map[expected-version:0.5.14 working-directory:__tests__/fixtures/pyproject-toml-project]) (push) Failing after 1m35s
test / test-specific-version (map[expected-version:0.1.0 resolution-strategy:lowest version-input:>=0.1.0,<0.2]) (push) Failing after 1m36s
test / test-from-working-directory-version (map[expected-version:0.5.15 working-directory:__tests__/fixtures/uv-toml-project]) (push) Failing after 1m33s
test / test-specific-version (map[expected-version:0.4.30 version-input:>=0.4.25,<0.5]) (push) Failing after 1m37s
test / test-uv-no-modify-path (push) Failing after 1m38s
test / test-version-file-version (map[expected-version:0.5.15 version-file:__tests__/fixtures/.tool-versions]) (push) Failing after 1m34s
test / test-uvx (push) Failing after 5s
test / test-tool-install (ubuntu-latest) (push) Failing after 5s
test / test-activate-environment (ubuntu-latest) (push) Failing after 6s
test / test-activate-environment-no-project (push) Failing after 7s
test / test-activate-environment-custom-path (ubuntu-latest) (push) Failing after 6s
test / test-with-explicit-token (push) Failing after 11s
test / test-cache-key-os-version (ubuntu-22.04, ubuntu-22.04) (push) Failing after 24s
test / test-checksum (map[checksum:4d9279ad5ca596b1e2d703901d508430eb07564dc4d8837de9e2fca9c90f8ecd os:ubuntu-latest]) (push) Failing after 48s
test / test-malformed-pyproject-file-fallback (push) Failing after 51s
test / test-version-file-version (map[expected-version:0.6.17 version-file:__tests__/fixtures/uv-in-requirements-txt-project/requirements.txt]) (push) Failing after 52s
test / test-version-file-version (map[expected-version:0.8.3 version-file:__tests__/fixtures/uv-in-requirements-hash-txt-project/requirements.txt]) (push) Failing after 52s
test / test-tool-versions-python-version (push) Failing after 52s
test / test-python-version (ubuntu-latest) (push) Failing after 51s
test / test-musl (push) Failing after 52s
test / test-setup-cache (auto, ubuntu-latest) (push) Failing after 44s
test / test-setup-cache (true, ubuntu-latest) (push) Failing after 44s
test / test-setup-cache-save-cache-false (push) Failing after 19s
test / test-restore-cache-dependency-glob (push) Skipped
test / test-restore-cache-save-cache-false (push) Skipped
test / test-setup-cache-restore-cache-false (push) Failing after 9s
test / test-setup-cache-dependency-glob (push) Failing after 40s
test / test-restore-cache-requirements-txt (push) Skipped
test / test-restore-cache-restore-cache-false (push) Skipped
test / test-setup-cache (false, ubuntu-latest) (push) Failing after 47s
CodeQL / Analyze (TypeScript) (push) Failing after 2m38s
test / test-setup-cache-requirements-txt (push) Failing after 43s
test / test-cache-local (map[expected-cache-dir:/home/runner/work/_temp/setup-uv-cache os:ubuntu-latest]) (push) Failing after 6s
test / test-cache-local-cache-disabled (push) Failing after 6s
test / test-cache-local-cache-disabled-but-explicit-path (push) Failing after 6s
test / test-no-python-version (push) Failing after 8s
test / test-download-from-astral-mirror-false (push) Failing after 7s
test / test-cache-prune-force (push) Failing after 9s
test / test-relative-path (push) Failing after 6s
test / test-absolute-path (push) Failing after 6s
test / test-custom-manifest-file (push) Failing after 9s
test / test-python-install-dir (map[expected-python-dir:/home/runner/work/_temp/uv-python-dir os:ubuntu-latest]) (push) Failing after 5s
test / test-cache-python-installs (push) Failing after 21s
test / test-cache-dir-from-file (push) Failing after 23s
test / test-cache-python-missing-managed-install-dir (push) Failing after 22s
test / test-restore-python-installs (push) Skipped
test / test-workflow-run (push) Failing after 36s
test / test-debian-unstable (push) Failing after 1m44s
test / lint (push) Failing after 3m33s
test / validate-typings (push) Successful in 1m34s
test / test-default-version (macos-14) (push) Canceled after 0s
test / test-default-version (macos-latest) (push) Canceled after 0s
test / test-default-version (windows-latest) (push) Canceled after 0s
test / test-checksum (map[checksum:a70cbfbf3bb5c08b2f84963b4f12c94e08fbb2468ba418a3bfe1066fbe9e7218 os:macos-latest]) (push) Canceled after 0s
test / test-tool-install (macos-14) (push) Canceled after 0s
test / test-tool-install (macos-latest) (push) Canceled after 0s
test / test-tool-install (windows-latest) (push) Canceled after 0s
test / test-python-version (macos-latest) (push) Canceled after 0s
test / test-python-version (windows-latest) (push) Canceled after 0s
test / test-activate-environment (macos-latest) (push) Canceled after 0s
test / test-activate-environment (windows-latest) (push) Canceled after 0s
test / test-activate-environment-custom-path (macos-latest) (push) Canceled after 0s
test / test-activate-environment-custom-path (windows-latest) (push) Canceled after 0s
test / test-cache-key-os-version (macos-14, macos-14) (push) Canceled after 0s
test / test-cache-key-os-version (macos-15, macos-15) (push) Canceled after 0s
test / test-cache-key-os-version (ubuntu-24.04, ubuntu-24.04) (push) Canceled after 0s
test / test-cache-key-os-version (windows-2022, windows-2022) (push) Canceled after 0s
test / test-cache-key-os-version (windows-2025, windows-2025) (push) Canceled after 0s
test / test-setup-cache (auto, windows-latest) (push) Canceled after 0s
test / test-setup-cache (false, windows-latest) (push) Canceled after 0s
test / test-setup-cache (true, windows-latest) (push) Canceled after 0s
test / test-restore-cache (auto, ubuntu-latest) (push) Canceled after 0s
test / test-restore-cache (auto, windows-latest) (push) Canceled after 0s
test / test-restore-cache (false, ubuntu-latest) (push) Canceled after 0s
test / test-restore-cache (false, windows-latest) (push) Canceled after 0s
test / test-restore-cache (true, ubuntu-latest) (push) Canceled after 0s
test / test-restore-cache (true, windows-latest) (push) Canceled after 0s
test / test-cache-local (map[expected-cache-dir:D:\a\_temp\setup-uv-cache os:windows-latest]) (push) Canceled after 0s
test / test-python-install-dir (map[expected-python-dir:D:\a\_temp\uv-python-dir os:windows-latest]) (push) Canceled after 0s
test / all-tests-passed (push) Canceled after 0s
Release Drafter / ✏️ Draft release (push) Canceled after 0s
test / test-latest-version (>=0.8) (push) Failing after 2s
test / test-latest-version (latest) (push) Failing after 2s
test / test-specific-version (map[expected-version:0.3.0 version-input:0.3.0]) (push) Failing after 1m34s
test / test-specific-version (map[expected-version:0.4.25 resolution-strategy:lowest version-input:>=0.4.25,<0.5]) (push) Failing after 1m34s
test / test-specific-version (map[expected-version:0.4.25 resolution-strategy:lowest version-input:>=0.4.25]) (push) Failing after 1m34s
test / test-specific-version (map[expected-version:0.1.45 resolution-strategy:highest version-input:>=0.1,<0.2]) (push) Failing after 1m35s
test / test-specific-version (map[expected-version:0.3.5 version-input:0.3]) (push) Failing after 1m35s
test / test-specific-version (map[expected-version:0.3.5 version-input:0.3.x]) (push) Failing after 1m35s
test / test-default-version (ubuntu-latest) (push) Failing after 1m36s
test / test-specific-version (map[expected-version:0.3.2 version-input:0.3.2]) (push) Failing after 1m36s
test / test-from-working-directory-version (map[expected-version:0.5.14 working-directory:__tests__/fixtures/pyproject-toml-project]) (push) Failing after 1m35s
test / test-specific-version (map[expected-version:0.1.0 resolution-strategy:lowest version-input:>=0.1.0,<0.2]) (push) Failing after 1m36s
test / test-from-working-directory-version (map[expected-version:0.5.15 working-directory:__tests__/fixtures/uv-toml-project]) (push) Failing after 1m33s
test / test-specific-version (map[expected-version:0.4.30 version-input:>=0.4.25,<0.5]) (push) Failing after 1m37s
test / test-uv-no-modify-path (push) Failing after 1m38s
test / test-version-file-version (map[expected-version:0.5.15 version-file:__tests__/fixtures/.tool-versions]) (push) Failing after 1m34s
test / test-uvx (push) Failing after 5s
test / test-tool-install (ubuntu-latest) (push) Failing after 5s
test / test-activate-environment (ubuntu-latest) (push) Failing after 6s
test / test-activate-environment-no-project (push) Failing after 7s
test / test-activate-environment-custom-path (ubuntu-latest) (push) Failing after 6s
test / test-with-explicit-token (push) Failing after 11s
test / test-cache-key-os-version (ubuntu-22.04, ubuntu-22.04) (push) Failing after 24s
test / test-checksum (map[checksum:4d9279ad5ca596b1e2d703901d508430eb07564dc4d8837de9e2fca9c90f8ecd os:ubuntu-latest]) (push) Failing after 48s
test / test-malformed-pyproject-file-fallback (push) Failing after 51s
test / test-version-file-version (map[expected-version:0.6.17 version-file:__tests__/fixtures/uv-in-requirements-txt-project/requirements.txt]) (push) Failing after 52s
test / test-version-file-version (map[expected-version:0.8.3 version-file:__tests__/fixtures/uv-in-requirements-hash-txt-project/requirements.txt]) (push) Failing after 52s
test / test-tool-versions-python-version (push) Failing after 52s
test / test-python-version (ubuntu-latest) (push) Failing after 51s
test / test-musl (push) Failing after 52s
test / test-setup-cache (auto, ubuntu-latest) (push) Failing after 44s
test / test-setup-cache (true, ubuntu-latest) (push) Failing after 44s
test / test-setup-cache-save-cache-false (push) Failing after 19s
test / test-restore-cache-dependency-glob (push) Skipped
test / test-restore-cache-save-cache-false (push) Skipped
test / test-setup-cache-restore-cache-false (push) Failing after 9s
test / test-setup-cache-dependency-glob (push) Failing after 40s
test / test-restore-cache-requirements-txt (push) Skipped
test / test-restore-cache-restore-cache-false (push) Skipped
test / test-setup-cache (false, ubuntu-latest) (push) Failing after 47s
CodeQL / Analyze (TypeScript) (push) Failing after 2m38s
test / test-setup-cache-requirements-txt (push) Failing after 43s
test / test-cache-local (map[expected-cache-dir:/home/runner/work/_temp/setup-uv-cache os:ubuntu-latest]) (push) Failing after 6s
test / test-cache-local-cache-disabled (push) Failing after 6s
test / test-cache-local-cache-disabled-but-explicit-path (push) Failing after 6s
test / test-no-python-version (push) Failing after 8s
test / test-download-from-astral-mirror-false (push) Failing after 7s
test / test-cache-prune-force (push) Failing after 9s
test / test-relative-path (push) Failing after 6s
test / test-absolute-path (push) Failing after 6s
test / test-custom-manifest-file (push) Failing after 9s
test / test-python-install-dir (map[expected-python-dir:/home/runner/work/_temp/uv-python-dir os:ubuntu-latest]) (push) Failing after 5s
test / test-cache-python-installs (push) Failing after 21s
test / test-cache-dir-from-file (push) Failing after 23s
test / test-cache-python-missing-managed-install-dir (push) Failing after 22s
test / test-restore-python-installs (push) Skipped
test / test-workflow-run (push) Failing after 36s
test / test-debian-unstable (push) Failing after 1m44s
test / lint (push) Failing after 3m33s
test / validate-typings (push) Successful in 1m34s
test / test-default-version (macos-14) (push) Canceled after 0s
test / test-default-version (macos-latest) (push) Canceled after 0s
test / test-default-version (windows-latest) (push) Canceled after 0s
test / test-checksum (map[checksum:a70cbfbf3bb5c08b2f84963b4f12c94e08fbb2468ba418a3bfe1066fbe9e7218 os:macos-latest]) (push) Canceled after 0s
test / test-tool-install (macos-14) (push) Canceled after 0s
test / test-tool-install (macos-latest) (push) Canceled after 0s
test / test-tool-install (windows-latest) (push) Canceled after 0s
test / test-python-version (macos-latest) (push) Canceled after 0s
test / test-python-version (windows-latest) (push) Canceled after 0s
test / test-activate-environment (macos-latest) (push) Canceled after 0s
test / test-activate-environment (windows-latest) (push) Canceled after 0s
test / test-activate-environment-custom-path (macos-latest) (push) Canceled after 0s
test / test-activate-environment-custom-path (windows-latest) (push) Canceled after 0s
test / test-cache-key-os-version (macos-14, macos-14) (push) Canceled after 0s
test / test-cache-key-os-version (macos-15, macos-15) (push) Canceled after 0s
test / test-cache-key-os-version (ubuntu-24.04, ubuntu-24.04) (push) Canceled after 0s
test / test-cache-key-os-version (windows-2022, windows-2022) (push) Canceled after 0s
test / test-cache-key-os-version (windows-2025, windows-2025) (push) Canceled after 0s
test / test-setup-cache (auto, windows-latest) (push) Canceled after 0s
test / test-setup-cache (false, windows-latest) (push) Canceled after 0s
test / test-setup-cache (true, windows-latest) (push) Canceled after 0s
test / test-restore-cache (auto, ubuntu-latest) (push) Canceled after 0s
test / test-restore-cache (auto, windows-latest) (push) Canceled after 0s
test / test-restore-cache (false, ubuntu-latest) (push) Canceled after 0s
test / test-restore-cache (false, windows-latest) (push) Canceled after 0s
test / test-restore-cache (true, ubuntu-latest) (push) Canceled after 0s
test / test-restore-cache (true, windows-latest) (push) Canceled after 0s
test / test-cache-local (map[expected-cache-dir:D:\a\_temp\setup-uv-cache os:windows-latest]) (push) Canceled after 0s
test / test-python-install-dir (map[expected-python-dir:D:\a\_temp\uv-python-dir os:windows-latest]) (push) Canceled after 0s
test / all-tests-passed (push) Canceled after 0s
Release Drafter / ✏️ Draft release (push) Canceled after 0s
Amp-Thread-ID: https://ampcode.com/threads/T-01a0af68-f950-77dc-b9ae-9402987584c8 Closes: #1052 Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
@@ -90,8 +90,8 @@ Have a look under [Advanced Configuration](#advanced-configuration) for detailed
|
||||
# Whether to restore the cache if found
|
||||
restore-cache: "true"
|
||||
|
||||
# Whether to save the cache after the run
|
||||
save-cache: "true"
|
||||
# Whether to save the cache after the run: true, false, or auto (disabled for merge_group events)
|
||||
save-cache: "auto"
|
||||
|
||||
# Suffix for the cache key
|
||||
cache-suffix: ""
|
||||
|
||||
@@ -206,6 +206,51 @@ describe("loadInputs", () => {
|
||||
expect(inputs.enableCache).toBe(true);
|
||||
});
|
||||
|
||||
it("restores but does not save cache automatically for merge groups", () => {
|
||||
mockInputs["working-directory"] = "/workspace";
|
||||
mockInputs["enable-cache"] = "auto";
|
||||
mockInputs["restore-cache"] = "true";
|
||||
mockInputs["save-cache"] = "auto";
|
||||
process.env.RUNNER_ENVIRONMENT = "github-hosted";
|
||||
process.env.RUNNER_TEMP = "/runner-temp";
|
||||
process.env.GITHUB_EVENT_NAME = "merge_group";
|
||||
|
||||
const inputs = loadInputs();
|
||||
|
||||
expect(inputs.enableCache).toBe(true);
|
||||
expect(inputs.restoreCache).toBe(true);
|
||||
expect(inputs.saveCache).toBe(false);
|
||||
expect(mockInfo).toHaveBeenCalledWith(
|
||||
"Cache saving is disabled for the merge_group event",
|
||||
);
|
||||
});
|
||||
|
||||
it.each([
|
||||
["true", true],
|
||||
["false", false],
|
||||
])("honors save-cache %s for merge groups", (saveCacheInput, expected) => {
|
||||
mockInputs["working-directory"] = "/workspace";
|
||||
mockInputs["save-cache"] = saveCacheInput;
|
||||
process.env.GITHUB_EVENT_NAME = "merge_group";
|
||||
|
||||
const inputs = loadInputs();
|
||||
|
||||
expect(inputs.saveCache).toBe(expected);
|
||||
expect(mockInfo).not.toHaveBeenCalledWith(
|
||||
"Cache saving is disabled for the merge_group event",
|
||||
);
|
||||
});
|
||||
|
||||
it("automatically saves cache for other events", () => {
|
||||
mockInputs["working-directory"] = "/workspace";
|
||||
mockInputs["save-cache"] = "auto";
|
||||
process.env.GITHUB_EVENT_NAME = "push";
|
||||
|
||||
const inputs = loadInputs();
|
||||
|
||||
expect(inputs.saveCache).toBe(true);
|
||||
});
|
||||
|
||||
it("uses cache-dir from pyproject.toml when present", () => {
|
||||
mockInputs["working-directory"] = createTempProject({
|
||||
"pyproject.toml": `[project]
|
||||
|
||||
+5
-1
@@ -33,7 +33,11 @@ inputs:
|
||||
restore-cache:
|
||||
type: boolean
|
||||
save-cache:
|
||||
type: boolean
|
||||
type: enum
|
||||
allowed-values:
|
||||
- "true"
|
||||
- "false"
|
||||
- auto
|
||||
cache-suffix:
|
||||
type: string
|
||||
cache-local-path:
|
||||
|
||||
+2
-2
@@ -51,8 +51,8 @@ inputs:
|
||||
description: "Whether to restore the cache if found."
|
||||
default: "true"
|
||||
save-cache:
|
||||
description: "Whether to save the cache after the run."
|
||||
default: "true"
|
||||
description: "Whether to save the cache after the run. 'auto' disables saving for merge_group events."
|
||||
default: "auto"
|
||||
cache-suffix:
|
||||
description: "Suffix for the cache key"
|
||||
required: false
|
||||
|
||||
+12
-1
@@ -64490,7 +64490,7 @@ function loadInputs() {
|
||||
const checksum = getInput("checksum");
|
||||
const enableCache = getEnableCache();
|
||||
const restoreCache2 = getInput("restore-cache") === "true";
|
||||
const saveCache4 = getInput("save-cache") === "true";
|
||||
const saveCache4 = getSaveCache();
|
||||
const cacheSuffix = getInput("cache-suffix") || "";
|
||||
const cacheLocalPath = getCacheLocalPath(
|
||||
workingDirectory,
|
||||
@@ -64600,6 +64600,17 @@ function getEnableCache() {
|
||||
}
|
||||
return enableCacheInput === "true";
|
||||
}
|
||||
function getSaveCache() {
|
||||
const saveCacheInput = getInput("save-cache");
|
||||
if (saveCacheInput === "auto") {
|
||||
if (process.env.GITHUB_EVENT_NAME === "merge_group") {
|
||||
info2("Cache saving is disabled for the merge_group event");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return saveCacheInput === "true";
|
||||
}
|
||||
function getToolBinDir(workingDirectory) {
|
||||
const toolBinDirInput = getInput("tool-bin-dir");
|
||||
if (toolBinDirInput !== "") {
|
||||
|
||||
+12
-1
@@ -101889,7 +101889,7 @@ function loadInputs() {
|
||||
const checksum = getInput("checksum");
|
||||
const enableCache = getEnableCache();
|
||||
const restoreCache3 = getInput("restore-cache") === "true";
|
||||
const saveCache2 = getInput("save-cache") === "true";
|
||||
const saveCache2 = getSaveCache();
|
||||
const cacheSuffix = getInput("cache-suffix") || "";
|
||||
const cacheLocalPath = getCacheLocalPath(
|
||||
workingDirectory,
|
||||
@@ -101999,6 +101999,17 @@ function getEnableCache() {
|
||||
}
|
||||
return enableCacheInput === "true";
|
||||
}
|
||||
function getSaveCache() {
|
||||
const saveCacheInput = getInput("save-cache");
|
||||
if (saveCacheInput === "auto") {
|
||||
if (process.env.GITHUB_EVENT_NAME === "merge_group") {
|
||||
info2("Cache saving is disabled for the merge_group event");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return saveCacheInput === "true";
|
||||
}
|
||||
function getToolBinDir(workingDirectory) {
|
||||
const toolBinDirInput = getInput("tool-bin-dir");
|
||||
if (toolBinDirInput !== "") {
|
||||
|
||||
+4
-2
@@ -139,9 +139,11 @@ By default, the cache will be restored.
|
||||
|
||||
## Save cache
|
||||
|
||||
You can also disable saving the cache after the run with the `save-cache` input.
|
||||
You can control saving the cache after the run with the `save-cache` input.
|
||||
This can be useful to save cache storage when you know you will not use the cache of the run again.
|
||||
By default, the cache will be saved.
|
||||
By default, `save-cache: auto` saves the cache except for `merge_group` events, where caches created
|
||||
for temporary merge queue refs are unlikely to be reused. Cache restoration remains enabled for
|
||||
these events. Set `save-cache: true` to save the cache for all events.
|
||||
|
||||
```yaml
|
||||
- name: Don't save the cache after the run
|
||||
|
||||
+13
-1
@@ -60,7 +60,7 @@ export function loadInputs(): SetupInputs {
|
||||
const checksum = core.getInput("checksum");
|
||||
const enableCache = getEnableCache();
|
||||
const restoreCache = core.getInput("restore-cache") === "true";
|
||||
const saveCache = core.getInput("save-cache") === "true";
|
||||
const saveCache = getSaveCache();
|
||||
const cacheSuffix = core.getInput("cache-suffix") || "";
|
||||
const cacheLocalPath = getCacheLocalPath(
|
||||
workingDirectory,
|
||||
@@ -189,6 +189,18 @@ function getEnableCache(): boolean {
|
||||
return enableCacheInput === "true";
|
||||
}
|
||||
|
||||
function getSaveCache(): boolean {
|
||||
const saveCacheInput = core.getInput("save-cache");
|
||||
if (saveCacheInput === "auto") {
|
||||
if (process.env.GITHUB_EVENT_NAME === "merge_group") {
|
||||
log.info("Cache saving is disabled for the merge_group event");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return saveCacheInput === "true";
|
||||
}
|
||||
|
||||
function getToolBinDir(workingDirectory: string): string | undefined {
|
||||
const toolBinDirInput = core.getInput("tool-bin-dir");
|
||||
if (toolBinDirInput !== "") {
|
||||
|
||||
Reference in New Issue
Block a user