| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 18566f8 commit bba65e5
6 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -87714,22 +87714,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( | |||
| 87714 | 87714 | }) : function(o, v) { | |
| 87715 | 87715 | o["default"] = v; | |
| 87716 | 87716 | }); | |
| 87717 | - var __importStar = (this && this.__importStar) || function (mod) { | ||
| 87718 | - if (mod && mod.__esModule) return mod; | ||
| 87719 | - var result = {}; | ||
| 87720 | - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
| 87721 | - __setModuleDefault(result, mod); | ||
| 87722 | - return result; | ||
| 87723 | - }; | ||
| 87724 | - var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
| 87725 | - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
| 87726 | - return new (P || (P = Promise))(function (resolve, reject) { | ||
| 87727 | - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
| 87728 | - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
| 87729 | - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
| 87730 | - step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
| 87731 | - }); | ||
| 87732 | - }; | ||
| 87717 | + var __importStar = (this && this.__importStar) || (function () { | ||
| 87718 | + var ownKeys = function(o) { | ||
| 87719 | + ownKeys = Object.getOwnPropertyNames || function (o) { | ||
| 87720 | + var ar = []; | ||
| 87721 | + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; | ||
| 87722 | + return ar; | ||
| 87723 | + }; | ||
| 87724 | + return ownKeys(o); | ||
| 87725 | + }; | ||
| 87726 | + return function (mod) { | ||
| 87727 | + if (mod && mod.__esModule) return mod; | ||
| 87728 | + var result = {}; | ||
| 87729 | + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); | ||
| 87730 | + __setModuleDefault(result, mod); | ||
| 87731 | + return result; | ||
| 87732 | + }; | ||
| 87733 | + })(); | ||
| 87733 | 87734 | Object.defineProperty(exports, "__esModule", ({ value: true })); | |
| 87734 | 87735 | exports.State = void 0; | |
| 87735 | 87736 | const cache = __importStar(__nccwpck_require__(5116)); | |
@@ -87742,41 +87743,39 @@ var State; | |||
| 87742 | 87743 | State["CACHE_PATHS"] = "cache-paths"; | |
| 87743 | 87744 | })(State || (exports.State = State = {})); | |
| 87744 | 87745 | class CacheDistributor { | |
| 87746 | + packageManager; | ||
| 87747 | + cacheDependencyPath; | ||
| 87748 | + CACHE_KEY_PREFIX = 'setup-python'; | ||
| 87745 | 87749 | constructor(packageManager, cacheDependencyPath) { | |
| 87746 | 87750 | this.packageManager = packageManager; | |
| 87747 | 87751 | this.cacheDependencyPath = cacheDependencyPath; | |
| 87748 | - this.CACHE_KEY_PREFIX = 'setup-python'; | ||
| 87749 | - } | ||
| 87750 | - handleLoadedCache() { | ||
| 87751 | - return __awaiter(this, void 0, void 0, function* () { }); | ||
| 87752 | 87752 | } | |
| 87753 | - restoreCache() { | ||
| 87754 | - return __awaiter(this, void 0, void 0, function* () { | ||
| 87755 | - const { primaryKey, restoreKey } = yield this.computeKeys(); | ||
| 87756 | - if (primaryKey.endsWith('-')) { | ||
| 87757 | - const file = this.packageManager === 'pip' | ||
| 87758 | - ? `${this.cacheDependencyPath | ||
| 87759 | - .split('\n') | ||
| 87760 | - .join(',')} or ${constants_1.CACHE_DEPENDENCY_BACKUP_PATH}` | ||
| 87761 | - : this.cacheDependencyPath.split('\n').join(','); | ||
| 87762 | - throw new Error(`No file in ${process.cwd()} matched to [${file}], make sure you have checked out the target repository`); | ||
| 87763 | - } | ||
| 87764 | - const cachePath = yield this.getCacheGlobalDirectories(); | ||
| 87765 | - core.saveState(State.CACHE_PATHS, cachePath); | ||
| 87766 | - let matchedKey; | ||
| 87767 | - try { | ||
| 87768 | - matchedKey = yield cache.restoreCache(cachePath, primaryKey, restoreKey); | ||
| 87769 | - } | ||
| 87770 | - catch (err) { | ||
| 87771 | - const message = err.message; | ||
| 87772 | - core.info(`[warning]${message}`); | ||
| 87773 | - core.setOutput('cache-hit', false); | ||
| 87774 | - return; | ||
| 87775 | - } | ||
| 87776 | - core.saveState(State.STATE_CACHE_PRIMARY_KEY, primaryKey); | ||
| 87777 | - yield this.handleLoadedCache(); | ||
| 87778 | - this.handleMatchResult(matchedKey, primaryKey); | ||
| 87779 | - }); | ||
| 87753 | + async handleLoadedCache() { } | ||
| 87754 | + async restoreCache() { | ||
| 87755 | + const { primaryKey, restoreKey } = await this.computeKeys(); | ||
| 87756 | + if (primaryKey.endsWith('-')) { | ||
| 87757 | + const file = this.packageManager === 'pip' | ||
| 87758 | + ? `${this.cacheDependencyPath | ||
| 87759 | + .split('\n') | ||
| 87760 | + .join(',')} or ${constants_1.CACHE_DEPENDENCY_BACKUP_PATH}` | ||
| 87761 | + : this.cacheDependencyPath.split('\n').join(','); | ||
| 87762 | + throw new Error(`No file in ${process.cwd()} matched to [${file}], make sure you have checked out the target repository`); | ||
| 87763 | + } | ||
| 87764 | + const cachePath = await this.getCacheGlobalDirectories(); | ||
| 87765 | + core.saveState(State.CACHE_PATHS, cachePath); | ||
| 87766 | + let matchedKey; | ||
| 87767 | + try { | ||
| 87768 | + matchedKey = await cache.restoreCache(cachePath, primaryKey, restoreKey); | ||
| 87769 | + } | ||
| 87770 | + catch (err) { | ||
| 87771 | + const message = err.message; | ||
| 87772 | + core.info(`[warning]${message}`); | ||
| 87773 | + core.setOutput('cache-hit', false); | ||
| 87774 | + return; | ||
| 87775 | + } | ||
| 87776 | + core.saveState(State.STATE_CACHE_PRIMARY_KEY, primaryKey); | ||
| 87777 | + await this.handleLoadedCache(); | ||
| 87778 | + this.handleMatchResult(matchedKey, primaryKey); | ||
| 87780 | 87779 | } | |
| 87781 | 87780 | handleMatchResult(matchedKey, primaryKey) { | |
| 87782 | 87781 | if (matchedKey) { | |
@@ -87827,90 +87826,86 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( | |||
| 87827 | 87826 | }) : function(o, v) { | |
| 87828 | 87827 | o["default"] = v; | |
| 87829 | 87828 | }); | |
| 87830 | - var __importStar = (this && this.__importStar) || function (mod) { | ||
| 87831 | - if (mod && mod.__esModule) return mod; | ||
| 87832 | - var result = {}; | ||
| 87833 | - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
| 87834 | - __setModuleDefault(result, mod); | ||
| 87835 | - return result; | ||
| 87836 | - }; | ||
| 87837 | - var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
| 87838 | - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
| 87839 | - return new (P || (P = Promise))(function (resolve, reject) { | ||
| 87840 | - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
| 87841 | - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
| 87842 | - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
| 87843 | - step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
| 87844 | - }); | ||
| 87845 | - }; | ||
| 87829 | + var __importStar = (this && this.__importStar) || (function () { | ||
| 87830 | + var ownKeys = function(o) { | ||
| 87831 | + ownKeys = Object.getOwnPropertyNames || function (o) { | ||
| 87832 | + var ar = []; | ||
| 87833 | + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; | ||
| 87834 | + return ar; | ||
| 87835 | + }; | ||
| 87836 | + return ownKeys(o); | ||
| 87837 | + }; | ||
| 87838 | + return function (mod) { | ||
| 87839 | + if (mod && mod.__esModule) return mod; | ||
| 87840 | + var result = {}; | ||
| 87841 | + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); | ||
| 87842 | + __setModuleDefault(result, mod); | ||
| 87843 | + return result; | ||
| 87844 | + }; | ||
| 87845 | + })(); | ||
| 87846 | 87846 | var __importDefault = (this && this.__importDefault) || function (mod) { | |
| 87847 | 87847 | return (mod && mod.__esModule) ? mod : { "default": mod }; | |
| 87848 | 87848 | }; | |
| 87849 | 87849 | Object.defineProperty(exports, "__esModule", ({ value: true })); | |
| 87850 | - exports.run = void 0; | ||
| 87850 | + exports.run = run; | ||
| 87851 | 87851 | const core = __importStar(__nccwpck_require__(7484)); | |
| 87852 | 87852 | const cache = __importStar(__nccwpck_require__(5116)); | |
| 87853 | 87853 | const fs_1 = __importDefault(__nccwpck_require__(9896)); | |
| 87854 | 87854 | const cache_distributor_1 = __nccwpck_require__(2326); | |
| 87855 | 87855 | // Added early exit to resolve issue with slow post action step: | |
| 87856 | 87856 | // - https://github.com/actions/setup-node/issues/878 | |
| 87857 | 87857 | // https://github.com/actions/cache/pull/1217 | |
| 87858 | - function run(earlyExit) { | ||
| 87859 | - return __awaiter(this, void 0, void 0, function* () { | ||
| 87860 | - try { | ||
| 87861 | - const cache = core.getInput('cache'); | ||
| 87862 | - if (cache) { | ||
| 87863 | - yield saveCache(cache); | ||
| 87864 | - if (earlyExit) { | ||
| 87865 | - process.exit(0); | ||
| 87866 | - } | ||
| 87858 | + async function run(earlyExit) { | ||
| 87859 | + try { | ||
| 87860 | + const cache = core.getInput('cache'); | ||
| 87861 | + if (cache) { | ||
| 87862 | + await saveCache(cache); | ||
| 87863 | + if (earlyExit) { | ||
| 87864 | + process.exit(0); | ||
| 87867 | 87865 | } | |
| 87868 | 87866 | } | |
| 87869 | - catch (error) { | ||
| 87870 | - const err = error; | ||
| 87871 | - core.setFailed(err.message); | ||
| 87872 | - } | ||
| 87873 | - }); | ||
| 87867 | + } | ||
| 87868 | + catch (error) { | ||
| 87869 | + const err = error; | ||
| 87870 | + core.setFailed(err.message); | ||
| 87871 | + } | ||
| 87874 | 87872 | } | |
| 87875 | - exports.run = run; | ||
| 87876 | - function saveCache(packageManager) { | ||
| 87877 | - return __awaiter(this, void 0, void 0, function* () { | ||
| 87878 | - const cachePathState = core.getState(cache_distributor_1.State.CACHE_PATHS); | ||
| 87879 | - if (!cachePathState) { | ||
| 87880 | - core.warning('Cache paths are empty. Please check the previous logs and make sure that the python version is specified'); | ||
| 87881 | - return; | ||
| 87882 | - } | ||
| 87883 | - const cachePaths = JSON.parse(cachePathState); | ||
| 87884 | - core.debug(`paths for caching are ${cachePaths.join(', ')}`); | ||
| 87885 | - if (!isCacheDirectoryExists(cachePaths)) { | ||
| 87886 | - core.warning(`Cache folder path is retrieved for ${packageManager} but doesn't exist on disk: ${cachePaths.join(', ')}. This likely indicates that there are no dependencies to cache. Consider removing the cache step if it is not needed.`); | ||
| 87887 | - return; | ||
| 87888 | - } | ||
| 87889 | - const primaryKey = core.getState(cache_distributor_1.State.STATE_CACHE_PRIMARY_KEY); | ||
| 87890 | - const matchedKey = core.getState(cache_distributor_1.State.CACHE_MATCHED_KEY); | ||
| 87891 | - if (!primaryKey) { | ||
| 87892 | - core.warning('Error retrieving key from state.'); | ||
| 87893 | - return; | ||
| 87894 | - } | ||
| 87895 | - else if (matchedKey === primaryKey) { | ||
| 87896 | - // no change in target directories | ||
| 87897 | - core.info(`Cache hit occurred on the primary key ${primaryKey}, not saving cache.`); | ||
| 87898 | - return; | ||
| 87899 | - } | ||
| 87900 | - let cacheId = 0; | ||
| 87901 | - try { | ||
| 87902 | - cacheId = yield cache.saveCache(cachePaths, primaryKey); | ||
| 87903 | - } | ||
| 87904 | - catch (err) { | ||
| 87905 | - const message = err.message; | ||
| 87906 | - core.info(`[warning]${message}`); | ||
| 87907 | - return; | ||
| 87908 | - } | ||
| 87909 | - if (cacheId == -1) { | ||
| 87910 | - return; | ||
| 87911 | - } | ||
| 87912 | - core.info(`Cache saved with the key: ${primaryKey}`); | ||
| 87913 | - }); | ||
| 87873 | + async function saveCache(packageManager) { | ||
| 87874 | + const cachePathState = core.getState(cache_distributor_1.State.CACHE_PATHS); | ||
| 87875 | + if (!cachePathState) { | ||
| 87876 | + core.warning('Cache paths are empty. Please check the previous logs and make sure that the python version is specified'); | ||
| 87877 | + return; | ||
| 87878 | + } | ||
| 87879 | + const cachePaths = JSON.parse(cachePathState); | ||
| 87880 | + core.debug(`paths for caching are ${cachePaths.join(', ')}`); | ||
| 87881 | + if (!isCacheDirectoryExists(cachePaths)) { | ||
| 87882 | + core.warning(`Cache folder path is retrieved for ${packageManager} but doesn't exist on disk: ${cachePaths.join(', ')}. This likely indicates that there are no dependencies to cache. Consider removing the cache step if it is not needed.`); | ||
| 87883 | + return; | ||
| 87884 | + } | ||
| 87885 | + const primaryKey = core.getState(cache_distributor_1.State.STATE_CACHE_PRIMARY_KEY); | ||
| 87886 | + const matchedKey = core.getState(cache_distributor_1.State.CACHE_MATCHED_KEY); | ||
| 87887 | + if (!primaryKey) { | ||
| 87888 | + core.warning('Error retrieving key from state.'); | ||
| 87889 | + return; | ||
| 87890 | + } | ||
| 87891 | + else if (matchedKey === primaryKey) { | ||
| 87892 | + // no change in target directories | ||
| 87893 | + core.info(`Cache hit occurred on the primary key ${primaryKey}, not saving cache.`); | ||
| 87894 | + return; | ||
| 87895 | + } | ||
| 87896 | + let cacheId = 0; | ||
| 87897 | + try { | ||
| 87898 | + cacheId = await cache.saveCache(cachePaths, primaryKey); | ||
| 87899 | + } | ||
| 87900 | + catch (err) { | ||
| 87901 | + const message = err.message; | ||
| 87902 | + core.info(`[warning]${message}`); | ||
| 87903 | + return; | ||
| 87904 | + } | ||
| 87905 | + if (cacheId == -1) { | ||
| 87906 | + return; | ||
| 87907 | + } | ||
| 87908 | + core.info(`Cache saved with the key: ${primaryKey}`); | ||
| 87914 | 87909 | } | |
| 87915 | 87910 | function isCacheDirectoryExists(cacheDirectory) { | |
| 87916 | 87911 | const result = cacheDirectory.reduce((previousValue, currentValue) => { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments