feat: add ability to restore cache by exact match (#60)
Signed-off-by: szymonmaszke <github@maszke.co>
This commit is contained in:
parent
176c044a20
commit
2f3a9be7ac
@ -37,6 +37,12 @@ inputs:
|
|||||||
description: The dependency file(s) to cache.
|
description: The dependency file(s) to cache.
|
||||||
default: pdm.lock
|
default: pdm.lock
|
||||||
required: false
|
required: false
|
||||||
|
cache-restore-exact-match:
|
||||||
|
description: >
|
||||||
|
Restore cache ONLY on exact match with the primary key.
|
||||||
|
Note: Post-installation cache will still be saved if cache is 'true'.
|
||||||
|
default: 'false'
|
||||||
|
required: false
|
||||||
update-python:
|
update-python:
|
||||||
description: Whether to update the environment with the requested Python
|
description: Whether to update the environment with the requested Python
|
||||||
default: 'true'
|
default: 'true'
|
||||||
|
22
dist/setup-pdm.js
vendored
22
dist/setup-pdm.js
vendored
@ -2085,7 +2085,7 @@ var require_core = __commonJS({
|
|||||||
return inputs.map((input) => input.trim());
|
return inputs.map((input) => input.trim());
|
||||||
}
|
}
|
||||||
exports2.getMultilineInput = getMultilineInput2;
|
exports2.getMultilineInput = getMultilineInput2;
|
||||||
function getBooleanInput3(name, options) {
|
function getBooleanInput4(name, options) {
|
||||||
const trueValue = ["true", "True", "TRUE"];
|
const trueValue = ["true", "True", "TRUE"];
|
||||||
const falseValue = ["false", "False", "FALSE"];
|
const falseValue = ["false", "False", "FALSE"];
|
||||||
const val = getInput5(name, options);
|
const val = getInput5(name, options);
|
||||||
@ -2096,7 +2096,7 @@ var require_core = __commonJS({
|
|||||||
throw new TypeError(`Input does not meet YAML 1.2 "Core Schema" specification: ${name}
|
throw new TypeError(`Input does not meet YAML 1.2 "Core Schema" specification: ${name}
|
||||||
Support boolean input list: \`true | True | TRUE | false | False | FALSE\``);
|
Support boolean input list: \`true | True | TRUE | false | False | FALSE\``);
|
||||||
}
|
}
|
||||||
exports2.getBooleanInput = getBooleanInput3;
|
exports2.getBooleanInput = getBooleanInput4;
|
||||||
function setOutput5(name, value) {
|
function setOutput5(name, value) {
|
||||||
const filePath = process.env["GITHUB_OUTPUT"] || "";
|
const filePath = process.env["GITHUB_OUTPUT"] || "";
|
||||||
if (filePath) {
|
if (filePath) {
|
||||||
@ -84127,7 +84127,7 @@ var import_node_process4 = __toESM(require("node:process"));
|
|||||||
var core8 = __toESM(require_core());
|
var core8 = __toESM(require_core());
|
||||||
var import_exec2 = __toESM(require_exec());
|
var import_exec2 = __toESM(require_exec());
|
||||||
|
|
||||||
// node_modules/.pnpm/github.com+actions+setup-python@2f078955e4d0f34cc7a8b0108b2eb7bbe154438e/node_modules/setup-python/src/utils.ts
|
// node_modules/.pnpm/setup-python@https+++codeload.github.com+actions+setup-python+tar.gz+2f078955e4d0f34cc7a8b0108b2eb7bbe154438e/node_modules/setup-python/src/utils.ts
|
||||||
var cache = __toESM(require_cache2());
|
var cache = __toESM(require_cache2());
|
||||||
var core = __toESM(require_core());
|
var core = __toESM(require_core());
|
||||||
var import_fs = __toESM(require("fs"));
|
var import_fs = __toESM(require("fs"));
|
||||||
@ -90391,12 +90391,12 @@ var defaults = {
|
|||||||
var got = create_default(defaults);
|
var got = create_default(defaults);
|
||||||
var source_default2 = got;
|
var source_default2 = got;
|
||||||
|
|
||||||
// node_modules/.pnpm/github.com+actions+setup-python@2f078955e4d0f34cc7a8b0108b2eb7bbe154438e/node_modules/setup-python/src/find-python.ts
|
// node_modules/.pnpm/setup-python@https+++codeload.github.com+actions+setup-python+tar.gz+2f078955e4d0f34cc7a8b0108b2eb7bbe154438e/node_modules/setup-python/src/find-python.ts
|
||||||
var os2 = __toESM(require("os"));
|
var os2 = __toESM(require("os"));
|
||||||
var path3 = __toESM(require("path"));
|
var path3 = __toESM(require("path"));
|
||||||
var semver2 = __toESM(require_semver4());
|
var semver2 = __toESM(require_semver4());
|
||||||
|
|
||||||
// node_modules/.pnpm/github.com+actions+setup-python@2f078955e4d0f34cc7a8b0108b2eb7bbe154438e/node_modules/setup-python/src/install-python.ts
|
// node_modules/.pnpm/setup-python@https+++codeload.github.com+actions+setup-python+tar.gz+2f078955e4d0f34cc7a8b0108b2eb7bbe154438e/node_modules/setup-python/src/install-python.ts
|
||||||
var path2 = __toESM(require("path"));
|
var path2 = __toESM(require("path"));
|
||||||
var core2 = __toESM(require_core());
|
var core2 = __toESM(require_core());
|
||||||
var tc = __toESM(require_tool_cache());
|
var tc = __toESM(require_tool_cache());
|
||||||
@ -90485,7 +90485,7 @@ async function installCpythonFromRelease(release) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// node_modules/.pnpm/github.com+actions+setup-python@2f078955e4d0f34cc7a8b0108b2eb7bbe154438e/node_modules/setup-python/src/find-python.ts
|
// node_modules/.pnpm/setup-python@https+++codeload.github.com+actions+setup-python+tar.gz+2f078955e4d0f34cc7a8b0108b2eb7bbe154438e/node_modules/setup-python/src/find-python.ts
|
||||||
var core3 = __toESM(require_core());
|
var core3 = __toESM(require_core());
|
||||||
var tc2 = __toESM(require_tool_cache());
|
var tc2 = __toESM(require_tool_cache());
|
||||||
function binDir(installDir) {
|
function binDir(installDir) {
|
||||||
@ -90608,10 +90608,10 @@ function pythonVersionToSemantic(versionSpec, allowPreReleases) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// node_modules/.pnpm/github.com+actions+setup-python@2f078955e4d0f34cc7a8b0108b2eb7bbe154438e/node_modules/setup-python/src/find-pypy.ts
|
// node_modules/.pnpm/setup-python@https+++codeload.github.com+actions+setup-python+tar.gz+2f078955e4d0f34cc7a8b0108b2eb7bbe154438e/node_modules/setup-python/src/find-pypy.ts
|
||||||
var path5 = __toESM(require("path"));
|
var path5 = __toESM(require("path"));
|
||||||
|
|
||||||
// node_modules/.pnpm/github.com+actions+setup-python@2f078955e4d0f34cc7a8b0108b2eb7bbe154438e/node_modules/setup-python/src/install-pypy.ts
|
// node_modules/.pnpm/setup-python@https+++codeload.github.com+actions+setup-python+tar.gz+2f078955e4d0f34cc7a8b0108b2eb7bbe154438e/node_modules/setup-python/src/install-pypy.ts
|
||||||
var os3 = __toESM(require("os"));
|
var os3 = __toESM(require("os"));
|
||||||
var path4 = __toESM(require("path"));
|
var path4 = __toESM(require("path"));
|
||||||
var core4 = __toESM(require_core());
|
var core4 = __toESM(require_core());
|
||||||
@ -90811,7 +90811,7 @@ function replaceX32toX86(architecture) {
|
|||||||
return architecture;
|
return architecture;
|
||||||
}
|
}
|
||||||
|
|
||||||
// node_modules/.pnpm/github.com+actions+setup-python@2f078955e4d0f34cc7a8b0108b2eb7bbe154438e/node_modules/setup-python/src/find-pypy.ts
|
// node_modules/.pnpm/setup-python@https+++codeload.github.com+actions+setup-python+tar.gz+2f078955e4d0f34cc7a8b0108b2eb7bbe154438e/node_modules/setup-python/src/find-pypy.ts
|
||||||
var semver4 = __toESM(require_semver4());
|
var semver4 = __toESM(require_semver4());
|
||||||
var core5 = __toESM(require_core());
|
var core5 = __toESM(require_core());
|
||||||
var tc4 = __toESM(require_tool_cache());
|
var tc4 = __toESM(require_tool_cache());
|
||||||
@ -91050,6 +91050,10 @@ async function calculateCacheKeys(pythonVersion, cacheDependencyPath) {
|
|||||||
const hash = await (0, import_glob.hashFiles)(cacheDependencyPath);
|
const hash = await (0, import_glob.hashFiles)(cacheDependencyPath);
|
||||||
const primaryKey = `setup-pdm-${import_node_process3.default.env.RUNNER_OS}-${import_node_process3.default.env.RUNNER_ARCH}-python-${pythonVersion}-${hash}`;
|
const primaryKey = `setup-pdm-${import_node_process3.default.env.RUNNER_OS}-${import_node_process3.default.env.RUNNER_ARCH}-python-${pythonVersion}-${hash}`;
|
||||||
const restoreKey = `setup-pdm-${import_node_process3.default.env.RUNNER_OS}-${import_node_process3.default.env.RUNNER_ARCH}-python-${pythonVersion}-`;
|
const restoreKey = `setup-pdm-${import_node_process3.default.env.RUNNER_OS}-${import_node_process3.default.env.RUNNER_ARCH}-python-${pythonVersion}-`;
|
||||||
|
const restoreExactMatch = core7.getBooleanInput("cache-restore-exact-match");
|
||||||
|
if (restoreExactMatch) {
|
||||||
|
return { primaryKey, restoreKeys: [] };
|
||||||
|
}
|
||||||
return { primaryKey, restoreKeys: [restoreKey] };
|
return { primaryKey, restoreKeys: [restoreKey] };
|
||||||
}
|
}
|
||||||
async function cacheDependencies(pdmBin, pythonVersion) {
|
async function cacheDependencies(pdmBin, pythonVersion) {
|
||||||
|
4223
pnpm-lock.yaml
generated
4223
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@ -9,6 +9,12 @@ async function calculateCacheKeys(pythonVersion: string, cacheDependencyPath: st
|
|||||||
const hash = await hashFiles(cacheDependencyPath)
|
const hash = await hashFiles(cacheDependencyPath)
|
||||||
const primaryKey = `setup-pdm-${process.env.RUNNER_OS}-${process.env.RUNNER_ARCH}-python-${pythonVersion}-${hash}`
|
const primaryKey = `setup-pdm-${process.env.RUNNER_OS}-${process.env.RUNNER_ARCH}-python-${pythonVersion}-${hash}`
|
||||||
const restoreKey = `setup-pdm-${process.env.RUNNER_OS}-${process.env.RUNNER_ARCH}-python-${pythonVersion}-`
|
const restoreKey = `setup-pdm-${process.env.RUNNER_OS}-${process.env.RUNNER_ARCH}-python-${pythonVersion}-`
|
||||||
|
|
||||||
|
const restoreExactMatch = core.getBooleanInput('cache-restore-exact-match')
|
||||||
|
if (restoreExactMatch) {
|
||||||
|
return { primaryKey, restoreKeys: [] }
|
||||||
|
}
|
||||||
|
|
||||||
return { primaryKey, restoreKeys: [restoreKey] }
|
return { primaryKey, restoreKeys: [restoreKey] }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user