mirror of
https://github.com/actions/setup-python.git
synced 2025-06-28 05:33:47 +00:00
ehnace cache dependency path handling
This commit is contained in:
parent
5db1cf9a59
commit
f36c8371b9
4 changed files with 172 additions and 2 deletions
30
dist/setup/index.js
vendored
30
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,39 @@ function isGraalPyVersion(versionSpec) {
|
|||
function cacheDependencies(cache, pythonVersion) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const cacheDependencyPath = core.getInput('cache-dependency-path') || undefined;
|
||||
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 relativePath = path.relative(actionPath, sourcePath);
|
||||
const targetPath = path.resolve(workspace, relativePath);
|
||||
if (!fs_1.default.existsSync(sourcePath)) {
|
||||
core.warning(`The resolved cache-dependency-path does not exist: ${sourcePath}`);
|
||||
}
|
||||
else {
|
||||
if (sourcePath !== targetPath) {
|
||||
try {
|
||||
const targetDir = path.dirname(targetPath);
|
||||
if (!fs_1.default.existsSync(targetDir)) {
|
||||
fs_1.default.mkdirSync(targetDir, { recursive: true });
|
||||
}
|
||||
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, cacheDependencyPath);
|
||||
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