mirror of
https://github.com/actions/setup-python.git
synced 2025-06-28 05:33:47 +00:00
Added logic to facilitate the Cache even it's in out side of root folder also
This commit is contained in:
parent
5db1cf9a59
commit
acfd356f6e
3 changed files with 149 additions and 3 deletions
25
dist/setup/index.js
vendored
25
dist/setup/index.js
vendored
|
@ -96905,6 +96905,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.cacheDependencies = void 0;
|
||||
const core = __importStar(__nccwpck_require__(7484));
|
||||
const finder = __importStar(__nccwpck_require__(6843));
|
||||
const finderPyPy = __importStar(__nccwpck_require__(2625));
|
||||
|
@ -96923,10 +96924,32 @@ function isGraalPyVersion(versionSpec) {
|
|||
function cacheDependencies(cache, pythonVersion) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const cacheDependencyPath = core.getInput('cache-dependency-path') || undefined;
|
||||
const cacheDistributor = (0, cache_factory_1.getCacheDistributor)(cache, pythonVersion, cacheDependencyPath);
|
||||
let resolvedDependencyPath = undefined;
|
||||
if (cacheDependencyPath) {
|
||||
const actionPath = process.env.GITHUB_ACTION_PATH || '';
|
||||
const workspace = process.env.GITHUB_WORKSPACE || process.cwd();
|
||||
const sourcePath = path.resolve(actionPath, cacheDependencyPath);
|
||||
const targetPath = path.resolve(workspace, path.basename(cacheDependencyPath));
|
||||
if (!fs_1.default.existsSync(sourcePath)) {
|
||||
core.warning(`The resolved cache-dependency-path does not exist: ${sourcePath}`);
|
||||
}
|
||||
else {
|
||||
try {
|
||||
fs_1.default.copyFileSync(sourcePath, targetPath);
|
||||
core.info(`Copied ${sourcePath} to ${targetPath}`);
|
||||
}
|
||||
catch (error) {
|
||||
core.warning(`Failed to copy file from ${sourcePath} to ${targetPath}: ${error}`);
|
||||
}
|
||||
}
|
||||
resolvedDependencyPath = path.relative(workspace, targetPath);
|
||||
core.info(`Resolved cache-dependency-path: ${resolvedDependencyPath}`);
|
||||
}
|
||||
const cacheDistributor = (0, cache_factory_1.getCacheDistributor)(cache, pythonVersion, resolvedDependencyPath);
|
||||
yield cacheDistributor.restoreCache();
|
||||
});
|
||||
}
|
||||
exports.cacheDependencies = cacheDependencies;
|
||||
function resolveVersionInputFromDefaultFile() {
|
||||
const couples = [
|
||||
['.python-version', utils_1.getVersionsInputFromPlainFile]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue