Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Kudo committed Sep 13, 2023
1 parent be911ca commit e5292ca
Show file tree
Hide file tree
Showing 9 changed files with 141 additions and 71 deletions.
43 changes: 29 additions & 14 deletions build/fingerprint-post/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -77509,40 +77509,52 @@ function cacheKey(name, version, manager) {
return `${name}-${process.platform}-${external_os_default().arch()}-${manager}-${version}`;
}
/**
* Restore a tool from the remote cache.
* This will install the tool back into the local tool cache.
* Restore a directory from the remote cache.
*/
async function restoreFromCache(name, version, manager) {
const dir = toolPath(name, version);
async function restoreCacheAsync(cachePath, cacheKey) {
if (!cacheIsAvailable()) {
(0,core.warning)(`Skipped restoring from remote cache, not available.`);
return undefined;
return null;
}
try {
if (await (0,cache.restoreCache)([dir], cacheKey(name, version, manager))) {
return dir;
if (await (0,cache.restoreCache)([cachePath], cacheKey)) {
return cachePath;
}
}
catch (error) {
handleCacheError(error);
}
return null;
}
/**
* Save a tool to the remote cache.
* This will fetch the tool from the local tool cache.
* Save a directory to the remote cache.
*/
async function saveToCache(name, version, manager) {
async function saveCacheAsync(cachePath, cacheKey) {
if (!cacheIsAvailable()) {
(0,core.warning)(`Skipped saving to remote cache, not available.`);
return undefined;
return;
}
try {
await (0,cache.saveCache)([toolPath(name, version)], cacheKey(name, version, manager));
await (0,cache.saveCache)([cachePath], cacheKey);
}
catch (error) {
handleCacheError(error);
}
}
/**
* Restore a tool from the remote cache.
* This will install the tool back into the local tool cache.
*/
function restoreFromCache(name, version, manager) {
return restoreCacheAsync(toolPath(name, version), cacheKey(name, version, manager));
}
/**
* Save a tool to the remote cache.
* This will fetch the tool from the local tool cache.
*/
function saveToCache(name, version, manager) {
return saveCacheAsync(toolPath(name, version), cacheKey(name, version, manager));
}
/**
* Try to handle incoming cache errors.
* Because workers can operate in environments without cache configured,
Expand Down Expand Up @@ -77637,6 +77649,7 @@ async function installPackage(name, version, manager) {




/**
* Open a database and return a promise that resolves to a database object.
*/
Expand Down Expand Up @@ -77673,7 +77686,7 @@ async function installSQLiteAsync(packager) {
const version = await resolvePackage(packageName, sqliteVersion);
const message = `Installing ${packageName} (${version}) from cache or with ${packager}`;
return await (0,core.group)(message, async () => {
let libRoot = (0,tool_cache.find)(packageName, version) || undefined;
let libRoot = (0,tool_cache.find)(packageName, version) || null;
console.log('ooxx0', libRoot);
if (!libRoot) {
libRoot = await restoreFromCache(packageName, version, packager);
Expand All @@ -77684,6 +77697,8 @@ async function installSQLiteAsync(packager) {
await saveToCache(packageName, version, packager);
}
console.log('ooxx2', libRoot);
const { stdout } = await (0,lib_exec.getExecOutput)('find', [libRoot, '-ls']);
console.log('ooxx stdout', stdout);
addGlobalNodeSearchPath(libRoot);
return libRoot;
});
Expand Down Expand Up @@ -77877,7 +77892,7 @@ async function installFingerprintAsync(input) {
? `Installing ${packageName} (${version}) from cache or with ${input.packager}`
: `Installing ${packageName} (${version}) with ${input.packager}`;
return await (0,core.group)(message, async () => {
let libRoot = (0,tool_cache.find)(packageName, version) || undefined;
let libRoot = (0,tool_cache.find)(packageName, version) || null;
if (!libRoot && useCache) {
libRoot = await restoreFromCache(packageName, version, input.packager);
}
Expand Down
43 changes: 29 additions & 14 deletions build/fingerprint/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -77514,40 +77514,52 @@ function cacheKey(name, version, manager) {
return `${name}-${process.platform}-${external_os_default().arch()}-${manager}-${version}`;
}
/**
* Restore a tool from the remote cache.
* This will install the tool back into the local tool cache.
* Restore a directory from the remote cache.
*/
async function restoreFromCache(name, version, manager) {
const dir = toolPath(name, version);
async function restoreCacheAsync(cachePath, cacheKey) {
if (!cacher_cacheIsAvailable()) {
(0,core.warning)(`Skipped restoring from remote cache, not available.`);
return undefined;
return null;
}
try {
if (await (0,cache.restoreCache)([dir], cacheKey(name, version, manager))) {
return dir;
if (await (0,cache.restoreCache)([cachePath], cacheKey)) {
return cachePath;
}
}
catch (error) {
cacher_handleCacheError(error);
}
return null;
}
/**
* Save a tool to the remote cache.
* This will fetch the tool from the local tool cache.
* Save a directory to the remote cache.
*/
async function saveToCache(name, version, manager) {
async function saveCacheAsync(cachePath, cacheKey) {
if (!cacher_cacheIsAvailable()) {
(0,core.warning)(`Skipped saving to remote cache, not available.`);
return undefined;
return;
}
try {
await (0,cache.saveCache)([toolPath(name, version)], cacheKey(name, version, manager));
await (0,cache.saveCache)([cachePath], cacheKey);
}
catch (error) {
cacher_handleCacheError(error);
}
}
/**
* Restore a tool from the remote cache.
* This will install the tool back into the local tool cache.
*/
function restoreFromCache(name, version, manager) {
return restoreCacheAsync(toolPath(name, version), cacheKey(name, version, manager));
}
/**
* Save a tool to the remote cache.
* This will fetch the tool from the local tool cache.
*/
function saveToCache(name, version, manager) {
return saveCacheAsync(toolPath(name, version), cacheKey(name, version, manager));
}
/**
* Try to handle incoming cache errors.
* Because workers can operate in environments without cache configured,
Expand Down Expand Up @@ -77640,6 +77652,7 @@ async function installPackage(name, version, manager) {




/**
* Open a database and return a promise that resolves to a database object.
*/
Expand Down Expand Up @@ -77676,7 +77689,7 @@ async function installSQLiteAsync(packager) {
const version = await resolvePackage(packageName, sqliteVersion);
const message = `Installing ${packageName} (${version}) from cache or with ${packager}`;
return await (0,core.group)(message, async () => {
let libRoot = (0,tool_cache.find)(packageName, version) || undefined;
let libRoot = (0,tool_cache.find)(packageName, version) || null;
console.log('ooxx0', libRoot);
if (!libRoot) {
libRoot = await restoreFromCache(packageName, version, packager);
Expand All @@ -77687,6 +77700,8 @@ async function installSQLiteAsync(packager) {
await saveToCache(packageName, version, packager);
}
console.log('ooxx2', libRoot);
const { stdout } = await (0,lib_exec.getExecOutput)('find', [libRoot, '-ls']);
console.log('ooxx stdout', stdout);
addGlobalNodeSearchPath(libRoot);
return libRoot;
});
Expand Down Expand Up @@ -77878,7 +77893,7 @@ async function installFingerprintAsync(input) {
? `Installing ${packageName} (${version}) from cache or with ${input.packager}`
: `Installing ${packageName} (${version}) with ${input.packager}`;
return await (0,core.group)(message, async () => {
let libRoot = (0,tool_cache.find)(packageName, version) || undefined;
let libRoot = (0,tool_cache.find)(packageName, version) || null;
if (!libRoot && useCache) {
libRoot = await restoreFromCache(packageName, version, input.packager);
}
Expand Down
38 changes: 25 additions & 13 deletions build/preview-build/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -75485,40 +75485,52 @@ function cacheKey(name, version, manager) {
return `${name}-${process.platform}-${external_os_default().arch()}-${manager}-${version}`;
}
/**
* Restore a tool from the remote cache.
* This will install the tool back into the local tool cache.
* Restore a directory from the remote cache.
*/
async function restoreFromCache(name, version, manager) {
const dir = toolPath(name, version);
async function restoreCacheAsync(cachePath, cacheKey) {
if (!cacheIsAvailable()) {
(0,core.warning)(`Skipped restoring from remote cache, not available.`);
return undefined;
return null;
}
try {
if (await (0,cache.restoreCache)([dir], cacheKey(name, version, manager))) {
return dir;
if (await (0,cache.restoreCache)([cachePath], cacheKey)) {
return cachePath;
}
}
catch (error) {
handleCacheError(error);
}
return null;
}
/**
* Save a tool to the remote cache.
* This will fetch the tool from the local tool cache.
* Save a directory to the remote cache.
*/
async function saveToCache(name, version, manager) {
async function saveCacheAsync(cachePath, cacheKey) {
if (!cacheIsAvailable()) {
(0,core.warning)(`Skipped saving to remote cache, not available.`);
return undefined;
return;
}
try {
await (0,cache.saveCache)([toolPath(name, version)], cacheKey(name, version, manager));
await (0,cache.saveCache)([cachePath], cacheKey);
}
catch (error) {
handleCacheError(error);
}
}
/**
* Restore a tool from the remote cache.
* This will install the tool back into the local tool cache.
*/
function restoreFromCache(name, version, manager) {
return restoreCacheAsync(toolPath(name, version), cacheKey(name, version, manager));
}
/**
* Save a tool to the remote cache.
* This will fetch the tool from the local tool cache.
*/
function saveToCache(name, version, manager) {
return saveCacheAsync(toolPath(name, version), cacheKey(name, version, manager));
}
/**
* Try to handle incoming cache errors.
* Because workers can operate in environments without cache configured,
Expand Down Expand Up @@ -75788,7 +75800,7 @@ async function installFingerprintAsync(input) {
? `Installing ${packageName} (${version}) from cache or with ${input.packager}`
: `Installing ${packageName} (${version}) with ${input.packager}`;
return await (0,core.group)(message, async () => {
let libRoot = (0,tool_cache.find)(packageName, version) || undefined;
let libRoot = (0,tool_cache.find)(packageName, version) || null;
if (!libRoot && useCache) {
libRoot = await restoreFromCache(packageName, version, input.packager);
}
Expand Down
38 changes: 25 additions & 13 deletions build/setup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -72356,40 +72356,52 @@ function cacheKey(name, version, manager) {
return `${name}-${process.platform}-${external_os_default().arch()}-${manager}-${version}`;
}
/**
* Restore a tool from the remote cache.
* This will install the tool back into the local tool cache.
* Restore a directory from the remote cache.
*/
async function restoreFromCache(name, version, manager) {
const dir = toolPath(name, version);
async function restoreCacheAsync(cachePath, cacheKey) {
if (!cacheIsAvailable()) {
(0,core.warning)(`Skipped restoring from remote cache, not available.`);
return undefined;
return null;
}
try {
if (await (0,cache.restoreCache)([dir], cacheKey(name, version, manager))) {
return dir;
if (await (0,cache.restoreCache)([cachePath], cacheKey)) {
return cachePath;
}
}
catch (error) {
handleCacheError(error);
}
return null;
}
/**
* Save a tool to the remote cache.
* This will fetch the tool from the local tool cache.
* Save a directory to the remote cache.
*/
async function saveToCache(name, version, manager) {
async function saveCacheAsync(cachePath, cacheKey) {
if (!cacheIsAvailable()) {
(0,core.warning)(`Skipped saving to remote cache, not available.`);
return undefined;
return;
}
try {
await (0,cache.saveCache)([toolPath(name, version)], cacheKey(name, version, manager));
await (0,cache.saveCache)([cachePath], cacheKey);
}
catch (error) {
handleCacheError(error);
}
}
/**
* Restore a tool from the remote cache.
* This will install the tool back into the local tool cache.
*/
function restoreFromCache(name, version, manager) {
return restoreCacheAsync(toolPath(name, version), cacheKey(name, version, manager));
}
/**
* Save a tool to the remote cache.
* This will fetch the tool from the local tool cache.
*/
function saveToCache(name, version, manager) {
return saveCacheAsync(toolPath(name, version), cacheKey(name, version, manager));
}
/**
* Try to handle incoming cache errors.
* Because workers can operate in environments without cache configured,
Expand Down Expand Up @@ -72667,7 +72679,7 @@ async function setupAction(input = setupInput()) {
}
}
async function installCli(name, version, packager, useCache = true) {
let cliPath = (0,tool_cache.find)(name, version) || undefined;
let cliPath = (0,tool_cache.find)(name, version) || null;
if (!cliPath && useCache) {
cliPath = await restoreFromCache(name, version, packager);
}
Expand Down
2 changes: 1 addition & 1 deletion src/actions/fingerprint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ async function installFingerprintAsync(input: ReturnType<typeof collectInput>):
: `Installing ${packageName} (${version}) with ${input.packager}`;

return await group(message, async () => {
let libRoot = findTool(packageName, version) || undefined;
let libRoot = findTool(packageName, version) || null;
if (!libRoot && useCache) {
libRoot = await restoreFromCache(packageName, version, input.packager);
}
Expand Down
2 changes: 1 addition & 1 deletion src/actions/preview-build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ async function installFingerprintAsync(input: ReturnType<typeof previewBuildInpu
: `Installing ${packageName} (${version}) with ${input.packager}`;

return await group(message, async () => {
let libRoot = findTool(packageName, version) || undefined;
let libRoot = findTool(packageName, version) || null;
if (!libRoot && useCache) {
libRoot = await restoreFromCache(packageName, version, input.packager);
}
Expand Down
2 changes: 1 addition & 1 deletion src/actions/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export async function setupAction(input = setupInput()) {
}

async function installCli(name: string, version: string, packager: string, useCache = true) {
let cliPath = findTool(name, version) || undefined;
let cliPath = findTool(name, version) || null;

if (!cliPath && useCache) {
cliPath = await restoreFromCache(name, version, packager);
Expand Down
Loading

0 comments on commit e5292ca

Please sign in to comment.