Skip to content

Commit b07838e

Browse files
committed
feat: add ability to restore cache by exact match
Signed-off-by: szymonmaszke <[email protected]>
1 parent 176c044 commit b07838e

File tree

4 files changed

+2259
-1838
lines changed

4 files changed

+2259
-1838
lines changed

action.yml

+6
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ inputs:
3737
description: The dependency file(s) to cache.
3838
default: pdm.lock
3939
required: false
40+
cache-restore-exact-match:
41+
description: >
42+
Restore cache ONLY on exact match with the primary key.
43+
Note: Post-installation cache will still be saved if cache is 'true'.
44+
default: 'false'
45+
required: false
4046
update-python:
4147
description: Whether to update the environment with the requested Python
4248
default: 'true'

dist/setup-pdm.js

+13-9
Original file line numberDiff line numberDiff line change
@@ -2085,7 +2085,7 @@ var require_core = __commonJS({
20852085
return inputs.map((input) => input.trim());
20862086
}
20872087
exports2.getMultilineInput = getMultilineInput2;
2088-
function getBooleanInput3(name, options) {
2088+
function getBooleanInput4(name, options) {
20892089
const trueValue = ["true", "True", "TRUE"];
20902090
const falseValue = ["false", "False", "FALSE"];
20912091
const val = getInput5(name, options);
@@ -2096,7 +2096,7 @@ var require_core = __commonJS({
20962096
throw new TypeError(`Input does not meet YAML 1.2 "Core Schema" specification: ${name}
20972097
Support boolean input list: \`true | True | TRUE | false | False | FALSE\``);
20982098
}
2099-
exports2.getBooleanInput = getBooleanInput3;
2099+
exports2.getBooleanInput = getBooleanInput4;
21002100
function setOutput5(name, value) {
21012101
const filePath = process.env["GITHUB_OUTPUT"] || "";
21022102
if (filePath) {
@@ -84127,7 +84127,7 @@ var import_node_process4 = __toESM(require("node:process"));
8412784127
var core8 = __toESM(require_core());
8412884128
var import_exec2 = __toESM(require_exec());
8412984129

84130-
// node_modules/.pnpm/github.com+actions+setup-python@2f078955e4d0f34cc7a8b0108b2eb7bbe154438e/node_modules/setup-python/src/utils.ts
84130+
// node_modules/.pnpm/setup-python@https+++codeload.github.com+actions+setup-python+tar.gz+2f078955e4d0f34cc7a8b0108b2eb7bbe154438e/node_modules/setup-python/src/utils.ts
8413184131
var cache = __toESM(require_cache2());
8413284132
var core = __toESM(require_core());
8413384133
var import_fs = __toESM(require("fs"));
@@ -90391,12 +90391,12 @@ var defaults = {
9039190391
var got = create_default(defaults);
9039290392
var source_default2 = got;
9039390393

90394-
// node_modules/.pnpm/github.com+actions+setup-python@2f078955e4d0f34cc7a8b0108b2eb7bbe154438e/node_modules/setup-python/src/find-python.ts
90394+
// node_modules/.pnpm/setup-python@https+++codeload.github.com+actions+setup-python+tar.gz+2f078955e4d0f34cc7a8b0108b2eb7bbe154438e/node_modules/setup-python/src/find-python.ts
9039590395
var os2 = __toESM(require("os"));
9039690396
var path3 = __toESM(require("path"));
9039790397
var semver2 = __toESM(require_semver4());
9039890398

90399-
// node_modules/.pnpm/github.com+actions+setup-python@2f078955e4d0f34cc7a8b0108b2eb7bbe154438e/node_modules/setup-python/src/install-python.ts
90399+
// node_modules/.pnpm/setup-python@https+++codeload.github.com+actions+setup-python+tar.gz+2f078955e4d0f34cc7a8b0108b2eb7bbe154438e/node_modules/setup-python/src/install-python.ts
9040090400
var path2 = __toESM(require("path"));
9040190401
var core2 = __toESM(require_core());
9040290402
var tc = __toESM(require_tool_cache());
@@ -90485,7 +90485,7 @@ async function installCpythonFromRelease(release) {
9048590485
}
9048690486
}
9048790487

90488-
// node_modules/.pnpm/github.com+actions+setup-python@2f078955e4d0f34cc7a8b0108b2eb7bbe154438e/node_modules/setup-python/src/find-python.ts
90488+
// node_modules/.pnpm/setup-python@https+++codeload.github.com+actions+setup-python+tar.gz+2f078955e4d0f34cc7a8b0108b2eb7bbe154438e/node_modules/setup-python/src/find-python.ts
9048990489
var core3 = __toESM(require_core());
9049090490
var tc2 = __toESM(require_tool_cache());
9049190491
function binDir(installDir) {
@@ -90608,10 +90608,10 @@ function pythonVersionToSemantic(versionSpec, allowPreReleases) {
9060890608
return result;
9060990609
}
9061090610

90611-
// node_modules/.pnpm/github.com+actions+setup-python@2f078955e4d0f34cc7a8b0108b2eb7bbe154438e/node_modules/setup-python/src/find-pypy.ts
90611+
// node_modules/.pnpm/setup-python@https+++codeload.github.com+actions+setup-python+tar.gz+2f078955e4d0f34cc7a8b0108b2eb7bbe154438e/node_modules/setup-python/src/find-pypy.ts
9061290612
var path5 = __toESM(require("path"));
9061390613

90614-
// node_modules/.pnpm/github.com+actions+setup-python@2f078955e4d0f34cc7a8b0108b2eb7bbe154438e/node_modules/setup-python/src/install-pypy.ts
90614+
// node_modules/.pnpm/setup-python@https+++codeload.github.com+actions+setup-python+tar.gz+2f078955e4d0f34cc7a8b0108b2eb7bbe154438e/node_modules/setup-python/src/install-pypy.ts
9061590615
var os3 = __toESM(require("os"));
9061690616
var path4 = __toESM(require("path"));
9061790617
var core4 = __toESM(require_core());
@@ -90811,7 +90811,7 @@ function replaceX32toX86(architecture) {
9081190811
return architecture;
9081290812
}
9081390813

90814-
// node_modules/.pnpm/github.com+actions+setup-python@2f078955e4d0f34cc7a8b0108b2eb7bbe154438e/node_modules/setup-python/src/find-pypy.ts
90814+
// node_modules/.pnpm/setup-python@https+++codeload.github.com+actions+setup-python+tar.gz+2f078955e4d0f34cc7a8b0108b2eb7bbe154438e/node_modules/setup-python/src/find-pypy.ts
9081590815
var semver4 = __toESM(require_semver4());
9081690816
var core5 = __toESM(require_core());
9081790817
var tc4 = __toESM(require_tool_cache());
@@ -91050,6 +91050,10 @@ async function calculateCacheKeys(pythonVersion, cacheDependencyPath) {
9105091050
const hash = await (0, import_glob.hashFiles)(cacheDependencyPath);
9105191051
const primaryKey = `setup-pdm-${import_node_process3.default.env.RUNNER_OS}-${import_node_process3.default.env.RUNNER_ARCH}-python-${pythonVersion}-${hash}`;
9105291052
const restoreKey = `setup-pdm-${import_node_process3.default.env.RUNNER_OS}-${import_node_process3.default.env.RUNNER_ARCH}-python-${pythonVersion}-`;
91053+
const restoreExactMatch = core7.getBooleanInput("cache-restore-exact-match");
91054+
if (restoreExactMatch) {
91055+
return { primaryKey, restoreKeys: [] };
91056+
}
9105391057
return { primaryKey, restoreKeys: [restoreKey] };
9105491058
}
9105591059
async function cacheDependencies(pdmBin, pythonVersion) {

0 commit comments

Comments
 (0)