Skip to content

Commit

Permalink
feat: add ability to restore cache by exact match (#60)
Browse files Browse the repository at this point in the history
Signed-off-by: szymonmaszke <github@maszke.co>
  • Loading branch information
szymonmaszke authored Aug 9, 2024
1 parent 176c044 commit 2f3a9be
Show file tree
Hide file tree
Showing 4 changed files with 2,259 additions and 1,838 deletions.
6 changes: 6 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ inputs:
description: The dependency file(s) to cache.
default: pdm.lock
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:
description: Whether to update the environment with the requested Python
default: 'true'
Expand Down
22 changes: 13 additions & 9 deletions dist/setup-pdm.js
Original file line number Diff line number Diff line change
Expand Up @@ -2085,7 +2085,7 @@ var require_core = __commonJS({
return inputs.map((input) => input.trim());
}
exports2.getMultilineInput = getMultilineInput2;
function getBooleanInput3(name, options) {
function getBooleanInput4(name, options) {
const trueValue = ["true", "True", "TRUE"];
const falseValue = ["false", "False", "FALSE"];
const val = getInput5(name, options);
Expand All @@ -2096,7 +2096,7 @@ var require_core = __commonJS({
throw new TypeError(`Input does not meet YAML 1.2 "Core Schema" specification: ${name}
Support boolean input list: \`true | True | TRUE | false | False | FALSE\``);
}
exports2.getBooleanInput = getBooleanInput3;
exports2.getBooleanInput = getBooleanInput4;
function setOutput5(name, value) {
const filePath = process.env["GITHUB_OUTPUT"] || "";
if (filePath) {
Expand Down Expand Up @@ -84127,7 +84127,7 @@ var import_node_process4 = __toESM(require("node:process"));
var core8 = __toESM(require_core());
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 core = __toESM(require_core());
var import_fs = __toESM(require("fs"));
Expand Down Expand Up @@ -90391,12 +90391,12 @@ var defaults = {
var got = create_default(defaults);
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 path3 = __toESM(require("path"));
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 core2 = __toESM(require_core());
var tc = __toESM(require_tool_cache());
Expand Down Expand Up @@ -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 tc2 = __toESM(require_tool_cache());
function binDir(installDir) {
Expand Down Expand Up @@ -90608,10 +90608,10 @@ function pythonVersionToSemantic(versionSpec, allowPreReleases) {
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"));

// 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 path4 = __toESM(require("path"));
var core4 = __toESM(require_core());
Expand Down Expand Up @@ -90811,7 +90811,7 @@ function replaceX32toX86(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 core5 = __toESM(require_core());
var tc4 = __toESM(require_tool_cache());
Expand Down Expand Up @@ -91050,6 +91050,10 @@ async function calculateCacheKeys(pythonVersion, 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 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] };
}
async function cacheDependencies(pdmBin, pythonVersion) {
Expand Down
Loading

0 comments on commit 2f3a9be

Please sign in to comment.