Caching cleanup

pull/310/head
Frostebite 2022-01-02 17:02:13 +00:00
parent 2b3f235527
commit 212c29e52a
3 changed files with 12 additions and 31 deletions

17
dist/index.js vendored
View File

@ -544,16 +544,14 @@ class Caching {
process.chdir(`${sourceFolder}/..`); process.chdir(`${sourceFolder}/..`);
if (__1.Input.cloudRunnerTests) { if (__1.Input.cloudRunnerTests) {
cloud_runner_logger_1.default.log(`Hashed cache folder ${yield lfs_hashing_1.LFSHashing.hashAllFiles(sourceFolder)}`); cloud_runner_logger_1.default.log(`Hashed cache folder ${yield lfs_hashing_1.LFSHashing.hashAllFiles(sourceFolder)}`);
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`tree ${sourceFolder}`);
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`tree ${cacheFolder}`);
} }
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`zip -q -r ${cacheKey} ${path_1.default.basename(sourceFolder)}`); yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`zip -q -r ${cacheKey} ${path_1.default.basename(sourceFolder)}`);
console_1.assert(fs_1.default.existsSync(`${cacheKey}`)); console_1.assert(fs_1.default.existsSync(`${cacheKey}`));
console_1.assert(cacheFolder);
console_1.assert(sourceFolder);
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`mv ${cacheKey}.zip ${cacheFolder}`); yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`mv ${cacheKey}.zip ${cacheFolder}`);
remote_client_logger_1.RemoteClientLogger.log(`moved ${cacheKey}.zip to ${cacheFolder}`); remote_client_logger_1.RemoteClientLogger.log(`moved ${cacheKey}.zip to ${cacheFolder}`);
if (__1.Input.cloudRunnerTests) { console_1.assert(path_1.default.join(cacheFolder, `${cacheKey}.zip`));
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`tree ${cacheFolder}`);
}
if (__1.Input.cloudRunnerTests) { if (__1.Input.cloudRunnerTests) {
yield Caching.printFullCacheHierarchySize(); yield Caching.printFullCacheHierarchySize();
} }
@ -577,13 +575,8 @@ class Caching {
.replace(/\n/g, ``) .replace(/\n/g, ``)
.replace('.zip', ''); .replace('.zip', '');
process.chdir(cacheFolder); process.chdir(cacheFolder);
if (__1.Input.cloudRunnerTests) {
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`tree ${cacheFolder}`);
}
const cacheSelection = cacheKey !== `` && fs_1.default.existsSync(cacheKey) ? cacheKey : latestInBranch; const cacheSelection = cacheKey !== `` && fs_1.default.existsSync(cacheKey) ? cacheKey : latestInBranch;
if (__1.Input.cloudRunnerTests) {
yield cloud_runner_logger_1.default.log(`cache key ${cacheKey} selection ${cacheSelection}`); yield cloud_runner_logger_1.default.log(`cache key ${cacheKey} selection ${cacheSelection}`);
}
if (fs_1.default.existsSync(cacheSelection)) { if (fs_1.default.existsSync(cacheSelection)) {
if (__1.Input.cloudRunnerTests) { if (__1.Input.cloudRunnerTests) {
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`tree ${destinationFolder}`); yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`tree ${destinationFolder}`);
@ -592,9 +585,7 @@ class Caching {
console_1.assert(fs_1.default.existsSync(destinationFolder)); console_1.assert(fs_1.default.existsSync(destinationFolder));
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`unzip -q ${cacheSelection}.zip -d ${path_1.default.basename(destinationFolder)}`); yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`unzip -q ${cacheSelection}.zip -d ${path_1.default.basename(destinationFolder)}`);
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`mv ${path_1.default.basename(destinationFolder)}/* ${destinationFolder}`); yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`mv ${path_1.default.basename(destinationFolder)}/* ${destinationFolder}`);
if (__1.Input.cloudRunnerTests) { console_1.assert(path_1.default.join(destinationFolder, `${cacheSelection}.zip`));
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`tree ${destinationFolder}`);
}
} }
else { else {
remote_client_logger_1.RemoteClientLogger.logWarning(`cache item ${cacheKey} doesn't exist ${destinationFolder}`); remote_client_logger_1.RemoteClientLogger.logWarning(`cache item ${cacheKey} doesn't exist ${destinationFolder}`);

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -18,17 +18,16 @@ export class Caching {
if (Input.cloudRunnerTests) { if (Input.cloudRunnerTests) {
CloudRunnerLogger.log(`Hashed cache folder ${await LFSHashing.hashAllFiles(sourceFolder)}`); CloudRunnerLogger.log(`Hashed cache folder ${await LFSHashing.hashAllFiles(sourceFolder)}`);
await CloudRunnerAgentSystem.Run(`tree ${sourceFolder}`);
await CloudRunnerAgentSystem.Run(`tree ${cacheFolder}`);
} }
await CloudRunnerAgentSystem.Run(`zip -q -r ${cacheKey} ${path.basename(sourceFolder)}`); await CloudRunnerAgentSystem.Run(`zip -q -r ${cacheKey} ${path.basename(sourceFolder)}`);
assert(fs.existsSync(`${cacheKey}`)); assert(fs.existsSync(`${cacheKey}`));
assert(cacheFolder);
assert(sourceFolder);
await CloudRunnerAgentSystem.Run(`mv ${cacheKey}.zip ${cacheFolder}`); await CloudRunnerAgentSystem.Run(`mv ${cacheKey}.zip ${cacheFolder}`);
RemoteClientLogger.log(`moved ${cacheKey}.zip to ${cacheFolder}`); RemoteClientLogger.log(`moved ${cacheKey}.zip to ${cacheFolder}`);
assert(path.join(cacheFolder, `${cacheKey}.zip`));
if (Input.cloudRunnerTests) {
await CloudRunnerAgentSystem.Run(`tree ${cacheFolder}`);
}
if (Input.cloudRunnerTests) { if (Input.cloudRunnerTests) {
await Caching.printFullCacheHierarchySize(); await Caching.printFullCacheHierarchySize();
} }
@ -53,15 +52,8 @@ export class Caching {
process.chdir(cacheFolder); process.chdir(cacheFolder);
if (Input.cloudRunnerTests) {
await CloudRunnerAgentSystem.Run(`tree ${cacheFolder}`);
}
const cacheSelection = cacheKey !== `` && fs.existsSync(cacheKey) ? cacheKey : latestInBranch; const cacheSelection = cacheKey !== `` && fs.existsSync(cacheKey) ? cacheKey : latestInBranch;
if (Input.cloudRunnerTests) {
await CloudRunnerLogger.log(`cache key ${cacheKey} selection ${cacheSelection}`); await CloudRunnerLogger.log(`cache key ${cacheKey} selection ${cacheSelection}`);
}
if (fs.existsSync(cacheSelection)) { if (fs.existsSync(cacheSelection)) {
if (Input.cloudRunnerTests) { if (Input.cloudRunnerTests) {
@ -71,9 +63,7 @@ export class Caching {
assert(fs.existsSync(destinationFolder)); assert(fs.existsSync(destinationFolder));
await CloudRunnerAgentSystem.Run(`unzip -q ${cacheSelection}.zip -d ${path.basename(destinationFolder)}`); await CloudRunnerAgentSystem.Run(`unzip -q ${cacheSelection}.zip -d ${path.basename(destinationFolder)}`);
await CloudRunnerAgentSystem.Run(`mv ${path.basename(destinationFolder)}/* ${destinationFolder}`); await CloudRunnerAgentSystem.Run(`mv ${path.basename(destinationFolder)}/* ${destinationFolder}`);
if (Input.cloudRunnerTests) { assert(path.join(destinationFolder, `${cacheSelection}.zip`));
await CloudRunnerAgentSystem.Run(`tree ${destinationFolder}`);
}
} else { } else {
RemoteClientLogger.logWarning(`cache item ${cacheKey} doesn't exist ${destinationFolder}`); RemoteClientLogger.logWarning(`cache item ${cacheKey} doesn't exist ${destinationFolder}`);
if (cacheSelection !== ``) { if (cacheSelection !== ``) {