Skip to content

Commit

Permalink
Use @tsonfig/node16
Browse files Browse the repository at this point in the history
  • Loading branch information
JamieMagee committed Apr 19, 2023
1 parent df6abcc commit 4e02585
Show file tree
Hide file tree
Showing 5 changed files with 658 additions and 834 deletions.
180 changes: 81 additions & 99 deletions dist/cache-save/index.js
Expand Up @@ -59977,7 +59977,11 @@ module.exports = v4;

var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
Expand All @@ -59994,15 +59998,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
__setModuleDefault(result, mod);
return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.State = void 0;
const cache = __importStar(__nccwpck_require__(7799));
Expand All @@ -60020,36 +60015,32 @@ class CacheDistributor {
this.cacheDependencyPath = cacheDependencyPath;
this.CACHE_KEY_PREFIX = 'setup-python';
}
handleLoadedCache() {
return __awaiter(this, void 0, void 0, function* () { });
}
restoreCache() {
return __awaiter(this, void 0, void 0, function* () {
const { primaryKey, restoreKey } = yield this.computeKeys();
if (primaryKey.endsWith('-')) {
const file = this.packageManager === 'pip'
? `${this.cacheDependencyPath
.split('\n')
.join(',')} or ${constants_1.CACHE_DEPENDENCY_BACKUP_PATH}`
: this.cacheDependencyPath.split('\n').join(',');
throw new Error(`No file in ${process.cwd()} matched to [${file}], make sure you have checked out the target repository`);
}
const cachePath = yield this.getCacheGlobalDirectories();
core.saveState(State.CACHE_PATHS, cachePath);
let matchedKey;
try {
matchedKey = yield cache.restoreCache(cachePath, primaryKey, restoreKey);
}
catch (err) {
const message = err.message;
core.info(`[warning]${message}`);
core.setOutput('cache-hit', false);
return;
}
core.saveState(State.STATE_CACHE_PRIMARY_KEY, primaryKey);
yield this.handleLoadedCache();
this.handleMatchResult(matchedKey, primaryKey);
});
async handleLoadedCache() { }
async restoreCache() {
const { primaryKey, restoreKey } = await this.computeKeys();
if (primaryKey.endsWith('-')) {
const file = this.packageManager === 'pip'
? `${this.cacheDependencyPath
.split('\n')
.join(',')} or ${constants_1.CACHE_DEPENDENCY_BACKUP_PATH}`
: this.cacheDependencyPath.split('\n').join(',');
throw new Error(`No file in ${process.cwd()} matched to [${file}], make sure you have checked out the target repository`);
}
const cachePath = await this.getCacheGlobalDirectories();
core.saveState(State.CACHE_PATHS, cachePath);
let matchedKey;
try {
matchedKey = await cache.restoreCache(cachePath, primaryKey, restoreKey);
}
catch (err) {
const message = err.message;
core.info(`[warning]${message}`);
core.setOutput('cache-hit', false);
return;
}
core.saveState(State.STATE_CACHE_PRIMARY_KEY, primaryKey);
await this.handleLoadedCache();
this.handleMatchResult(matchedKey, primaryKey);
}
handleMatchResult(matchedKey, primaryKey) {
if (matchedKey) {
Expand Down Expand Up @@ -60086,7 +60077,11 @@ exports.CACHE_DEPENDENCY_BACKUP_PATH = '**/pyproject.toml';

var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
Expand All @@ -60103,15 +60098,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
__setModuleDefault(result, mod);
return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Expand All @@ -60121,58 +60107,54 @@ const core = __importStar(__nccwpck_require__(2186));
const cache = __importStar(__nccwpck_require__(7799));
const fs_1 = __importDefault(__nccwpck_require__(7147));
const cache_distributor_1 = __nccwpck_require__(8953);
function run() {
return __awaiter(this, void 0, void 0, function* () {
try {
const cache = core.getInput('cache');
if (cache) {
yield saveCache(cache);
}
}
catch (error) {
const err = error;
core.setFailed(err.message);
async function run() {
try {
const cache = core.getInput('cache');
if (cache) {
await saveCache(cache);
}
});
}
catch (error) {
const err = error;
core.setFailed(err.message);
}
}
exports.run = run;
function saveCache(packageManager) {
return __awaiter(this, void 0, void 0, function* () {
const cachePathState = core.getState(cache_distributor_1.State.CACHE_PATHS);
if (!cachePathState) {
core.warning('Cache paths are empty. Please check the previous logs and make sure that the python version is specified');
return;
}
const cachePaths = JSON.parse(cachePathState);
core.debug(`paths for caching are ${cachePaths.join(', ')}`);
if (!isCacheDirectoryExists(cachePaths)) {
throw new Error(`Cache folder path is retrieved for ${packageManager} but doesn't exist on disk: ${cachePaths.join(', ')}`);
}
const primaryKey = core.getState(cache_distributor_1.State.STATE_CACHE_PRIMARY_KEY);
const matchedKey = core.getState(cache_distributor_1.State.CACHE_MATCHED_KEY);
if (!primaryKey) {
core.warning('Error retrieving key from state.');
return;
}
else if (matchedKey === primaryKey) {
// no change in target directories
core.info(`Cache hit occurred on the primary key ${primaryKey}, not saving cache.`);
return;
}
let cacheId = 0;
try {
cacheId = yield cache.saveCache(cachePaths, primaryKey);
}
catch (err) {
const message = err.message;
core.info(`[warning]${message}`);
return;
}
if (cacheId == -1) {
return;
}
core.info(`Cache saved with the key: ${primaryKey}`);
});
async function saveCache(packageManager) {
const cachePathState = core.getState(cache_distributor_1.State.CACHE_PATHS);
if (!cachePathState) {
core.warning('Cache paths are empty. Please check the previous logs and make sure that the python version is specified');
return;
}
const cachePaths = JSON.parse(cachePathState);
core.debug(`paths for caching are ${cachePaths.join(', ')}`);
if (!isCacheDirectoryExists(cachePaths)) {
throw new Error(`Cache folder path is retrieved for ${packageManager} but doesn't exist on disk: ${cachePaths.join(', ')}`);
}
const primaryKey = core.getState(cache_distributor_1.State.STATE_CACHE_PRIMARY_KEY);
const matchedKey = core.getState(cache_distributor_1.State.CACHE_MATCHED_KEY);
if (!primaryKey) {
core.warning('Error retrieving key from state.');
return;
}
else if (matchedKey === primaryKey) {
// no change in target directories
core.info(`Cache hit occurred on the primary key ${primaryKey}, not saving cache.`);
return;
}
let cacheId = 0;
try {
cacheId = await cache.saveCache(cachePaths, primaryKey);
}
catch (err) {
const message = err.message;
core.info(`[warning]${message}`);
return;
}
if (cacheId == -1) {
return;
}
core.info(`Cache saved with the key: ${primaryKey}`);
}
function isCacheDirectoryExists(cacheDirectory) {
const result = cacheDirectory.reduce((previousValue, currentValue) => {
Expand Down

0 comments on commit 4e02585

Please sign in to comment.